PEPs: ``.. code:: python`` or ``::`` (syntax highlighting)
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 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? [1] http://docutils.sourceforge.net/docs/ref/rst/directives.html#code [2] http://www.sphinx-doc.org/en/stable/markup/code.html [3] http://www.sphinx-doc.org/en/stable/config.html#confval-highlight_language [4] https://github.com/python/peps/blob/master/pep-0557.rst [5] https://www.python.org/dev/peps/pep-0557/ https://www.python.org/dev/peps/pep-0458/
I tried using code blocks while writing PEP 551 but they weren’t highlighted on the python.org rendering. Personally I think it would be great, provided a good colour scheme is available (some default schemes are... not always works of art). I’m not sure who is responsible for that side of things though – presumably it’s just a case of installing pygments. (FWIW, I’m not keen on going back and modifying old PEPs, but I won’t stop someone doing it on their own terms.) Cheers, Steve Top-posted from my Windows phone at North Bay Python From: Wes Turner Sent: Thursday, November 30, 2017 5:06 To: Python-Dev Subject: [Python-Dev] PEPs: ``.. code:: python`` or ``::`` (syntaxhighlighting) 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 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? [1] http://docutils.sourceforge.net/docs/ref/rst/directives.html#code [2] http://www.sphinx-doc.org/en/stable/markup/code.html [3] http://www.sphinx-doc.org/en/stable/config.html#confval-highlight_language [4] https://github.com/python/peps/blob/master/pep-0557.rst [5] https://www.python.org/dev/peps/pep-0557/ https://www.python.org/dev/peps/pep-0458/
If we were to add Pygments support, it is to be done in pythondotorg project. I recalled the decision was to get PEPs rendered using Sphinx and host it at Read The Docs, so we don't have to worry about updating pythondotorg. Mariatta Wijaya
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.
participants (4)
-
Mariatta Wijaya
-
Serhiy Storchaka
-
Steve Dower
-
Wes Turner