From 436b420c1c6bb9db569d6ce4be2d06cff829aea9 Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Mon, 6 Jan 2014 22:10:51 -0500 Subject: =?UTF-8?q?Support=20syntax=20for=20highlighted=20lines=20like:=20?= =?UTF-8?q?```python=20hl=5Flines=3D=E2=80=9C1=203=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_extensions.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'tests') 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): '') 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') + 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), + '
'
+                    '#line 1\n'
+                    '#line 2\n'
+                    '#line 3\n'
+                    '
') + else: + self.assertEqual(md.convert(text), + '
#line 1\n'
+                    '#line 2\n'
+                    '#line 3
') + class TestHeaderId(unittest.TestCase): """ Test HeaderId Extension. """ -- cgit v1.2.3