Gabriel Gellner schrieb:

> You can register an extension in the Sphinx conf.py file, say you have a
> pygments extension called foo_highlighting (which is an importable module or
> package . . .). Then add the lines:
> 
>     # If your extensions are in another directory, add it here.
>     sys.path.append('sphinxext')
> 
>     # Import support for  foo syntax highlighting (lives
>     # in the sphinxext directory defined above)
>     import foo_highlighting

No need to import it, btw.

>     # General configuration
>     # ---------------------
> 
>     # Add any Sphinx extension module names here, as strings. They can be
>     # extensions
>     # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
>     extensions = ['foo_highlighting']

The tricky part is what to do in the extension so that Pygments knows
about the lexer :)

Pygments has no API to add a lexer with aliases, because in normal usage
you'd just directly pass the lexer class to highlight(). In this case,
however, Sphinx looks up the lexer via its alias, so this isn't possible.

The solution I'd suggest is to extend the "sphinx.highlighting.lexers"
dictionary, like so:

# e.g. in conf.py
def setup(app):
    from sphinx.highlighting import lexers
    lexers['alias'] = MyLexer()

where 'alias' is the name you want to use in your code block directives.

cheers,
Georg

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to sphinx-dev@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to