aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_extensions.py
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@10gen.com>2014-01-06 22:10:51 -0500
committerA. Jesse Jiryu Davis <jesse@10gen.com>2014-01-06 22:10:51 -0500
commit436b420c1c6bb9db569d6ce4be2d06cff829aea9 (patch)
treebb15cbf1a860b9e161a290d782e358725eb3a25c /tests/test_extensions.py
parentc18ce238e39c2ccac92da25a6429bdade0db4dff (diff)
downloadmarkdown-436b420c1c6bb9db569d6ce4be2d06cff829aea9.tar.gz
markdown-436b420c1c6bb9db569d6ce4be2d06cff829aea9.tar.bz2
markdown-436b420c1c6bb9db569d6ce4be2d06cff829aea9.zip
Support syntax for highlighted lines like: ```python hl_lines=“1 3”
Diffstat (limited to 'tests/test_extensions.py')
-rw-r--r--tests/test_extensions.py37
1 files changed, 35 insertions, 2 deletions
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index e918695..ea4adad 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -127,7 +127,7 @@ class TestCodeHilite(unittest.TestCase):
'</code></pre>')
def testHighlightLinesWithColon(self):
- text = '\t:::Python{2}\n\t#line 1\n\t#line 2\n\t#line 3'
+ text = '\t:::Python hl_lines="2"\n\t#line 1\n\t#line 2\n\t#line 3'
md = markdown.Markdown(extensions=['codehilite'])
if self.has_pygments:
@@ -216,7 +216,7 @@ Fenced code block
""" Test Fenced Code with Highlighted Lines. """
text = '''
-```{1,3}
+```hl_lines="1 3"
line 1
line 2
line 3
@@ -238,6 +238,39 @@ line 3
'line 2\n'
'line 3</code></pre>')
+ def testFencedLanguageAndHighlightLines(self):
+ """ Test Fenced Code with Highlighted Lines. """
+
+ text0 = '''
+```.python hl_lines="1 3"
+#line 1
+#line 2
+#line 3
+```'''
+ text1 = '''
+~~~{.python hl_lines="1 3"}
+#line 1
+#line 2
+#line 3
+~~~'''
+ for text in (text0, text1):
+ 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"><span class="c">#line 1</span>\n</span>'
+ '<span class="c">#line 2</span>\n'
+ '<span class="hll"><span class="c">#line 3</span>\n</span>'
+ '</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 TestHeaderId(unittest.TestCase):
""" Test HeaderId Extension. """