[Python-Dev] PEPs: ``.. code:: python`` or ``::`` (syntax highlighting)

Serhiy Storchaka storchaka at gmail.com
Sun Dec 3 01:52:44 EST 2017


30.11.17 15:00, Wes Turner пише:
> In ReStructuredText, this gets syntax highlighted
> because of the code directive [1][2][3]:
> 
> .. code:: python
> 
>     import this
>     def func(*args, **kwargs):
>         pass
> 
> This also gets syntax highlighted as python[3]:
> 
> .. code:: python
> 
>     import this
>     def func(*args, **kwargs):
>         pass
> 
> This does not::
> 
>     import this
>     def func(*args, **kwargs):
>         pass
> 
> Syntax highlighting in Docutils 0.9+ is powered by Pygments.
> If Pygments is not installed, or there is a syntax error,
> syntax highlighting is absent.
> 
> GitHub does show Pygments syntax highlighting
> in .. code:: blocks for .rst and .restructuredtext documents [4]
> 
> 1. Does the python.org <http://python.org> PEP view support .. code:: 
> blocks? [5]
> 2. Syntax highlighting is an advantage for writers, editors, and readers.
> 3. Should PEPs use .. code:: blocks to provide this advantage?

This was discussed when PEPs were converted to the .rst format. At that 
time this didn't work. I'm sure there is an open issue about adding 
support of Pygments. If this isn't, open the one.



More information about the Python-Dev mailing list