Bug report: Code with line numbers in RestructuredText is not rendered

Summary: Github displays a preview of repository files in reStructuredText format. However, a code block with line number is not rendered at all.

Steps to reproduce:

  1. In any repository, create a file test.rst
  2. Add the following content to this file:
::

    This is a basic literal block
    whose formatting is preserved

.. code-block:: python

    def foo():
        print("you don't say")

.. code:: python

    def foo():
        print("you don't say")

.. code-block:: python
    :linenos:

    def foo():
        print("you don't say")

.. code:: python
    :number-lines:

    def foo():
        print("you don't say")
  1. Save the file and view it on github (e.g. https://github.com/myusername/myrepository/blob/master/test.rst)

Expected result: I would have expected to see 5 literal blocks.

Actual result
In Github, only the first three literal blocks are displayed:

This is a basic literal block
whose formatting is preserved

def foo():
    print("you don't say")

def foo():
    print("you don't say")

The two code blocks with line numbers (using either the Sphinx directive code-block or the vanilla docutils directive code) are neither displayed by Github.

Note: I’ve been looking for the relevant repository to create an issue or PR, but I was informed this is the place to report bug reports. So here it is. Let me know if you can reproduce it, or need any help.
Edit: moved to “How to use Git and Github”, let me know if you can find a more fitting category.

I stand corrected.

.. code:: python
    :number-lines:

now seems to work, see code-number-lines.rst test file.

.. code-block:: python
    :linenos:

still doesn’t work, see code-block-linenos.rst test file.

However, since code-block is a Sphinx-specific directive, I’m not going to expect full support, especially not with the code directive as workaround.

So feel free to ignore this report.

:wave: @macfreek –– we use the open source tool github-markup to determine which markup library to use to render a content file (e.g. README) on GitHub (as noted in Rendering differences in prose documents - GitHub Docs).

Admittedly, I’m unfamiliar towards how RST files are handled or processed by that parser. As a next step, my recommendation is to open an issue or submit a pull request improving it by following their contributing guide.