diff options
| author | Georg Brandl <georg@python.org> | 2008-11-30 19:58:29 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2008-11-30 19:58:29 +0100 |
| commit | 0647cdecb439fa4dfd9bbdf094409e262cf33483 (patch) | |
| tree | 26ed7d538b8b814aeb402bc5cb9767c7b1b6b28c /tests/test_highlighting.py | |
| parent | 4b201975a442d45a3ae5118a38c3baa07940f9b3 (diff) | |
| download | sphinx-0647cdecb439fa4dfd9bbdf094409e262cf33483.tar.gz | |
Add Sphinx.add_lexer().
Diffstat (limited to 'tests/test_highlighting.py')
| -rw-r--r-- | tests/test_highlighting.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_highlighting.py b/tests/test_highlighting.py new file mode 100644 index 00000000..5c353946 --- /dev/null +++ b/tests/test_highlighting.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +""" + test_highlighting + ~~~~~~~~~~~~~~~~~ + + Test the Pygments highlighting bridge. + + :copyright: 2008 by Georg Brandl. + :license: BSD. +""" + +from util import * + +from pygments.lexer import RegexLexer +from pygments.token import Text, Name + +from sphinx.highlighting import PygmentsBridge + + +class MyLexer(RegexLexer): + name = 'testlexer' + + tokens = { + 'root': [ + ('a', Name), + ('b', Text), + ], + } + + +@with_app() +def test_add_lexer(app): + app.add_lexer('test', MyLexer()) + + bridge = PygmentsBridge('html') + ret = bridge.highlight_block('ab', 'test') + assert '<span class="n">a</span>b' in ret |
