Esempio n. 1
0
 def test_fenced_code(self):
     md = markdown.Markdown(
         extensions=['extra', WikiCodeHiliteExtension()]
     )
     text = (
         "Code:\n"
         "\n"
         "```python\n"
         "echo 'line 1'\n"
         "echo 'line 2'\n"
         "```\n"
     )
     result = (
         """<p>Code:</p>\n"""
         """<div class="codehilite-wrap"><div class="codehilite"><pre><span></span><span class="n">echo</span> <span class="s1">&#39;line 1&#39;</span>\n"""
         """<span class="n">echo</span> <span class="s1">&#39;line 2&#39;</span>\n"""
         """</pre></div>\n"""
         """</div>"""
     ) if pygments else (
         """<p>Code:</p>\n"""
         """<div class="codehilite-wrap"><pre class="codehilite"><code class="language-python">echo 'line 1'\n"""
         """echo 'line 2'</code></pre>\n"""
         """</div>"""
     )
     self.assertEqual(
         md.convert(text),
         result,
     )
Esempio n. 2
0
 def core_extensions(self):
     """List of core extensions found in the mdx folder"""
     return [
         PreviewLinksExtension(),
         ResponsiveTableExtension(),
         WikiCodeHiliteExtension(),
     ]
 def test_indented_code(self):
     md = markdown.Markdown(extensions=['extra', WikiCodeHiliteExtension()])
     text = ("Code:\n"
             "\n"
             "    #!/usr/bin/python\n"
             "    print('line 1')\n"
             "    print('line 2')\n"
             "    print('æøå')\n"
             "\n")
     result = (
         """<p>Code:</p>\n"""
         """<div class="codehilite-wrap"><table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1\n"""
         """2\n"""
         """3\n"""
         """4</pre></div></td><td class="code"><div class="codehilite"><pre><span></span><span class="ch">#!/usr/bin/python</span>\n"""
         """<span class="k">print</span><span class="p">(</span><span class="s1">&#39;line 1&#39;</span><span class="p">)</span>\n"""
         """<span class="k">print</span><span class="p">(</span><span class="s1">&#39;line 2&#39;</span><span class="p">)</span>\n"""
         """<span class="k">print</span><span class="p">(</span><span class="s1">&#39;æøå&#39;</span><span class="p">)</span>\n"""
         """</pre></div>\n"""
         """</td></tr></table></div>"""
     ) if pygments else (
         """<p>Code:</p>\n"""
         """<div class="codehilite-wrap"><pre class="codehilite"><code class="language-python linenums">#!/usr/bin/python\n"""
         """print('line 1')\n"""
         """print('line 2')\n"""
         """print('æøå')</code></pre>\n"""
         """</div>""")
     self.assertEqual(
         md.convert(text),
         result,
     )