diff options
| author | Georg Brandl <georg@python.org> | 2008-11-30 20:29:34 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2008-11-30 20:29:34 +0100 |
| commit | c001d82adcbb31d9c392ed5dd77a821f96a0c8db (patch) | |
| tree | cf78c7bf063ebaabcc84e44cdcf4259bfed0979e /tests/test_highlighting.py | |
| parent | 0647cdecb439fa4dfd9bbdf094409e262cf33483 (diff) | |
| download | sphinx-c001d82adcbb31d9c392ed5dd77a821f96a0c8db.tar.gz | |
Allow using different Pygments formatters.
Diffstat (limited to 'tests/test_highlighting.py')
| -rw-r--r-- | tests/test_highlighting.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_highlighting.py b/tests/test_highlighting.py index 5c353946..067c37cb 100644 --- a/tests/test_highlighting.py +++ b/tests/test_highlighting.py @@ -13,6 +13,7 @@ from util import * from pygments.lexer import RegexLexer from pygments.token import Text, Name +from pygments.formatters.html import HtmlFormatter from sphinx.highlighting import PygmentsBridge @@ -27,6 +28,10 @@ class MyLexer(RegexLexer): ], } +class MyFormatter(HtmlFormatter): + def format(self, tokensource, outfile): + outfile.write('test') + @with_app() def test_add_lexer(app): @@ -35,3 +40,12 @@ def test_add_lexer(app): bridge = PygmentsBridge('html') ret = bridge.highlight_block('ab', 'test') assert '<span class="n">a</span>b' in ret + +def test_set_formatter(): + PygmentsBridge.html_formatter = MyFormatter + try: + bridge = PygmentsBridge('html') + ret = bridge.highlight_block('foo', 'python') + assert ret == 'test' + finally: + PygmentsBridge.html_formatter = HtmlFormatter |
