[Catalog-sig] Syntax highlighting for code examples on PyPI

Georg Brandl g.brandl at gmx.net
Fri Oct 15 22:56:18 CEST 2010


Am 15.10.2010 12:40, schrieb Michael Foord:
> Hello guys,
> 
> Can I make a feature request for PyPI. Please allow syntax highlighting for code
> examples using pygments and the rest code-block directive.
> 
> Pygments includes a rest directive:
> 
>     http://pygments.org/docs/rstdirective/
> 
> It would require the addition of pygments css (not big) to the pages.

Rather than requiring a custom directive (which most people won't know about,
and probably don't want to have in their "pure" reST), I'd suggest the strategy
that Sphinx follows: for any code block, if it parses as Python, highlight it
as Python.  If it is a doctest block, highlight it as such.  Otherwise, don't
highlight it.  Since most code blocks are expected to be Python, I think that
should be sufficient.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Catalog-SIG mailing list