diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 11:33:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 11:33:32 +0000 |
commit | 1f403ad2197fc7442409f434ee574f3e6b46fb73 (patch) | |
tree | 0299c6dd11d5edfa918a29b6456bc1875f1d288c /tests/test_pangomarkup_formatter.py | |
parent | Initial commit. (diff) | |
download | pygments-1f403ad2197fc7442409f434ee574f3e6b46fb73.tar.xz pygments-1f403ad2197fc7442409f434ee574f3e6b46fb73.zip |
Adding upstream version 2.14.0+dfsg.upstream/2.14.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_pangomarkup_formatter.py')
-rw-r--r-- | tests/test_pangomarkup_formatter.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_pangomarkup_formatter.py b/tests/test_pangomarkup_formatter.py new file mode 100644 index 0000000..e468546 --- /dev/null +++ b/tests/test_pangomarkup_formatter.py @@ -0,0 +1,44 @@ +""" + Pygments Pango Markup formatter tests + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments import highlight +from pygments.formatters import PangoMarkupFormatter +from pygments.lexers import JavascriptLexer + +INPUT = r""" +function foobar(a, b) { + if (a > b) { + return a & b; + } + if (a < b) { + return true; + } + console.log("single quote ' and double quote \"") + console.log('single quote \' and double quote "') + // comment with äöü ç +} +""" + +OUTPUT = r"""<tt><span fgcolor="#"><b>function</b></span><span fgcolor="#"> </span>foobar(a,<span fgcolor="#"> </span>b)<span fgcolor="#"> </span>{<span fgcolor="#"> + </span><span fgcolor="#"><b>if</b></span><span fgcolor="#"> </span>(a<span fgcolor="#"> </span><span fgcolor="#">></span><span fgcolor="#"> </span>b)<span fgcolor="#"> </span>{<span fgcolor="#"> + </span><span fgcolor="#"><b>return</b></span><span fgcolor="#"> </span>a<span fgcolor="#"> </span><span fgcolor="#">&</span><span fgcolor="#"> </span>b;<span fgcolor="#"> + </span>}<span fgcolor="#"> + </span><span fgcolor="#"><b>if</b></span><span fgcolor="#"> </span>(a<span fgcolor="#"> </span><span fgcolor="#"><</span><span fgcolor="#"> </span>b)<span fgcolor="#"> </span>{<span fgcolor="#"> + </span><span fgcolor="#"><b>return</b></span><span fgcolor="#"> </span><span fgcolor="#"><b>true</b></span>;<span fgcolor="#"> + </span>}<span fgcolor="#"> + </span>console.log(<span fgcolor="#">"single quote ' and double quote \""</span>)<span fgcolor="#"> + </span>console.log(<span fgcolor="#">'single quote \' and double quote "'</span>)<span fgcolor="#"> + </span><span fgcolor="#"><i>// comment with äöü ç</i></span><span fgcolor="#"> +</span>}<span fgcolor="#"> +</span></tt>""" + +def test_correct_output(): + markup = highlight(INPUT, JavascriptLexer(), PangoMarkupFormatter()) + assert OUTPUT == re.sub('<span fgcolor="#[^"]{6}">', '<span fgcolor="#">', markup) |