python - Custom Syntax Highlighting with Sphinx -
good afternoon,
i interested in creating custom syntax highlighter can used in sphinx environment. possible? if how go doing it?
any appreciated!
-sean
background
sphinx (http://sphinx-doc.org/) internally uses pygments (http://pygments.org/) syntax highligher. pygments supports adding custom syntax highlighter (lexer) described here http://pygments.org/docs/lexerdevelopment/.
example usage
i try define new custom lexer in pygments , initialize new custom lexer in conf.py
sphinx configuration file. small example should started:
from pygments.lexer import regexlexer pygments import token sphinx.highlighting import lexers class bcllexer(regexlexer): name = 'mylang' tokens = { 'root': [ (r'mykeyword', token.keyword), (r'[a-za-z]', token.name), (r'\s', token.text) ] } lexers['mylang'] = bcllexer(startinline=true)
Comments
Post a Comment