diff options
author | A. Jesse Jiryu Davis <jesse@10gen.com> | 2014-01-03 18:03:15 -0500 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@10gen.com> | 2014-01-03 18:03:15 -0500 |
commit | c18ce238e39c2ccac92da25a6429bdade0db4dff (patch) | |
tree | 6f0caa4392c98dc9e10824bb0d1e8530310548d2 /tests | |
parent | b6ed501695ea5f8029a228686f84c163c0cdc50b (diff) | |
download | markdown-c18ce238e39c2ccac92da25a6429bdade0db4dff.tar.gz markdown-c18ce238e39c2ccac92da25a6429bdade0db4dff.tar.bz2 markdown-c18ce238e39c2ccac92da25a6429bdade0db4dff.zip |
Add feature for emphasizing some lines in a code block.
A code blocked headed by “:::python{1,3}” now emphasizes the first and third lines. With fences enabled, ```python{1,3} has the same effect.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_extensions.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_extensions.py b/tests/test_extensions.py index add759a..e918695 100644 --- a/tests/test_extensions.py +++ b/tests/test_extensions.py @@ -126,12 +126,33 @@ class TestCodeHilite(unittest.TestCase): '<pre class="codehilite"><code class="language-python"># A Code Comment' '</code></pre>') + def testHighlightLinesWithColon(self): + text = '\t:::Python{2}\n\t#line 1\n\t#line 2\n\t#line 3' + + md = markdown.Markdown(extensions=['codehilite']) + if self.has_pygments: + self.assertEqual(md.convert(text), + '<div class="codehilite"><pre>' + '<span class="c">#line 1</span>\n' + '<span class="hll"><span class="c">#line 2</span>\n</span>' + '<span class="c">#line 3</span>\n' + '</pre></div>') + else: + self.assertEqual(md.convert(text), + '<pre class="codehilite"><code class="language-python">#line 1\n' + '#line 2\n' + '#line 3</code></pre>') class TestFencedCode(unittest.TestCase): """ Test fenced_code extension. """ def setUp(self): self.md = markdown.Markdown(extensions=['fenced_code']) + self.has_pygments = True + try: + import pygments + except ImportError: + self.has_pygments = False def testBasicFence(self): """ Test Fenced Code Blocks. """ @@ -191,6 +212,32 @@ Fenced code block '~~~~~ # these tildes will not close the block\n' '</code></pre>') + def testFencedCodeWithHighlightLines(self): + """ Test Fenced Code with Highlighted Lines. """ + + text = ''' +```{1,3} +line 1 +line 2 +line 3 +```''' + md = markdown.Markdown(extensions=[ + 'codehilite(linenums=None,guess_lang=False)', + 'fenced_code']) + + if self.has_pygments: + self.assertEqual(md.convert(text), + '<div class="codehilite"><pre>' + '<span class="hll">line 1\n</span>' + 'line 2\n' + '<span class="hll">line 3\n</span>' + '</pre></div>') + else: + self.assertEqual(md.convert(text), + '<pre class="codehilite"><code>line 1\n' + 'line 2\n' + 'line 3</code></pre>') + class TestHeaderId(unittest.TestCase): """ Test HeaderId Extension. """ |