Example #1
0
 def test_hard_wrap(self):
     renderer = mistune.HTMLRenderer()
     inline = mistune.InlineParser(renderer, hard_wrap=True)
     md = mistune.Markdown(renderer, inline=inline)
     result = md('foo\nbar')
     expected = '<p>foo<br />\nbar</p>'
     self.assertEqual(result.strip(), expected)
Example #2
0
def markdown(text):
    renderer = mistune.HTMLRenderer()
    markdown = mistune.Markdown(renderer)
    return markdown(text)[3:-5].replace("\n", "<br>")
Example #3
0
 def test_use_plugin(self):
     from mistune.plugins import plugin_url
     md = mistune.Markdown(mistune.HTMLRenderer())
     md.use(plugin_url)
Example #4
0
 def test_allow_data_protocols(self):
     renderer = mistune.HTMLRenderer(allow_harmful_protocols=['data:'])
     md = mistune.Markdown(renderer)
     result = md('[h](data:alert)')
     expected = '<p><a href="data:alert">h</a></p>'
     self.assertEqual(result.strip(), expected)