diff options
author | Ana Nelson <ana@ananelson.com> | 2011-10-02 11:36:48 -0700 |
---|---|---|
committer | Ana Nelson <ana@ananelson.com> | 2011-10-02 11:36:48 -0700 |
commit | 067693dc8c01a9635bc4dd9a33d3b8737b372347 (patch) | |
tree | e9321aef7125c8568717da49fae0835558cff986 /tests/test_html_formatter.py | |
parent | f83a828ec5ff775cd313213385d4bce06efda8e6 (diff) | |
download | pygments-067693dc8c01a9635bc4dd9a33d3b8737b372347.tar.gz |
Fix specifyng the starting line number in lineanchors mode. Add tests for line numbering.
Diffstat (limited to 'tests/test_html_formatter.py')
-rw-r--r-- | tests/test_html_formatter.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_html_formatter.py b/tests/test_html_formatter.py index 5a506755..58a50c74 100644 --- a/tests/test_html_formatter.py +++ b/tests/test_html_formatter.py @@ -75,6 +75,38 @@ class HtmlFormatterTest(unittest.TestCase): fmt = HtmlFormatter(**optdict) fmt.format(tokensource, outfile) + def test_linenos(self): + optdict = dict(linenos=True) + outfile = StringIO.StringIO() + fmt = HtmlFormatter(**optdict) + fmt.format(tokensource, outfile) + html = outfile.getvalue() + self.assert_(re.search("<pre>\s+1\s+2\s+3", html)) + + def test_linenos_with_startnum(self): + optdict = dict(linenos=True, linenostart=5) + outfile = StringIO.StringIO() + fmt = HtmlFormatter(**optdict) + fmt.format(tokensource, outfile) + html = outfile.getvalue() + self.assert_(re.search("<pre>\s+5\s+6\s+7", html)) + + def test_lineanchors(self): + optdict = dict(lineanchors="foo") + outfile = StringIO.StringIO() + fmt = HtmlFormatter(**optdict) + fmt.format(tokensource, outfile) + html = outfile.getvalue() + self.assert_(re.search("<pre><a name=\"foo-1\">", html)) + + def test_lineanchors_with_startnum(self): + optdict = dict(lineanchors="foo", linenostart=5) + outfile = StringIO.StringIO() + fmt = HtmlFormatter(**optdict) + fmt.format(tokensource, outfile) + html = outfile.getvalue() + self.assert_(re.search("<pre><a name=\"foo-5\">", html)) + def test_valid_output(self): # test all available wrappers fmt = HtmlFormatter(full=True, linenos=True, noclasses=True, |