On Oct 17, 10:37 pm, Georg Brandl <[EMAIL PROTECTED]> wrote:
> The tricky part is what to do in the extension so that Pygments knows
> about the lexer :)
Yes, that was the problem. Just importing newly-defined lexers from
conf.py doesn't work -- Pygments doesn't implement any metaclass which
detects them. But I finally figured out the "proper" way, alluded to
in the Pygments docs -- create and install a package via setuptools
which contains one or more Pygments entry points. That way, the
'pygmentize' script also knows about the extension.
To save others the hassle of trawling through the docs, here's an
outline of the package (called 'hilite'):
setup.py
hilite
__init__.py
hilitecode.py
setup.py contains:
"""
My syntax highlighting for Pygments.
"""
from setuptools import setup
entry_points = """
[pygments.lexers]
myhighlight = hilite.hilitecode:MyHighlighter
"""
setup(
name = 'pyhilite',
version = '0.1',
description = __doc__,
author = "Glenn Hutchings",
packages = ['hilite'],
entry_points = entry_points
)
hilitecode.py contains the Pygments implementation of MyHighlighter,
as described in the Pygments docs.
After this package is installed, the new highlighter is registered
with Pygments (and listed with 'pygmentize -L').
Glenn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---