#202 Add support for `code-block` directive in docutils-0.9


docutils-0.9 added support for a `code-block` directive in reST. It does color syntax highlighting of code using Pygments.

Sphinx supports this and GitHub added support for this a few months ago so that I can have syntax-highlighted code in my project description (yay!) Unfortunately, when I publish the package on PyPI, it doesn't like this directive and in fact when it sees it, it decides that the entire description is plain-text instead of reST so I get an ugly description, unless I remove my `code-block` directives.

`sourcecode` (a seeminglyunofficial directive that some stuff used before docutils added `code-block`) doesn't work either.

The `code-block` directive was added recently in docutils-0.9; adding support for it _might_ be as simple as upgrading the installation of docutils on the pypi servers and installing Pygments.


  • Richard Jones

    Richard Jones - 2012-10-25

    docutils is currently installed from a debian package and I don't think there's a version newer than 0.7 (on test pypi) or 0.8 (on production pypi) available to install. Martin, is that correct?

    • marcman

      marcman - 2015-01-06

      PyPI supports code-block now.

      I think this can be closed.

  • Richard Jones

    Richard Jones - 2015-01-06
    • status: open --> closed
    • Group: --> v1.0_(example)
  • marcman

    marcman - 2015-01-06

    Oh by the way I came upon this while convincing someone that PyPI does in fact support code-block for syntax highlighting:


    I think it is common that people think that PyPI doesn't support advanced markup because:

    1. Historically it didn't and perhaps the change wasn't publicized a lot.
    2. It is extremely easy to have a problem in the markup that caused a warning that doesn't bother most tools that people use to check their markup, but PyPI treats even warnings as a reason to skip rendering. It's easy to have this problem and hard to get the info to fix it. This is why I suggest making PyPI more lenient - i.e.: https://bitbucket.org/pypa/pypi/pull-request/60/fix-bb-214-make-rst-rendering-not-fail-for/diff

    What do you think of the idea of doing that?


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks