def test_markdown_extensions(self): text = '[TOC]\n\n# Header 1\n\n## Header 2' self.assertHTMLEqual( markdown(text).strip(), '<p>[TOC]</p>\n<h1>Header 1</h1>' '\n<h2>Header 2</h2>' ) self.assertHTMLEqual( markdown(text, extensions=['markdown.extensions.toc']).strip(), '<div class="toc">\n<ul>\n<li><a href="#header-1">' 'Header 1</a><ul>\n<li><a href="#header-2">' 'Header 2</a></li>\n</ul>\n</li>\n</ul>\n</div>' '\n<h1 id="header-1">Header 1</h1>\n' '<h2 id="header-2">Header 2</h2>' ) from markdown.extensions.toc import TocExtension tocext = TocExtension(marker='--TOC--', permalink='PL') self.assertHTMLEqual( markdown(text, extensions=[tocext]).strip(), '<p>[TOC]</p>\n<h1 id="header-1">Header 1' '<a class="headerlink" href="#header-1" ' 'title="Permanent link">PL</a></h1>\n' '<h2 id="header-2">Header 2' '<a class="headerlink" href="#header-2" ' 'title="Permanent link">PL</a></h2>' )
def test_markdown_extensions(self): text = '[TOC]\n\n# Header 1\n\n## Header 2' self.assertEqual(markdown(text).strip(), '<p>[TOC]</p>\n<h1>Header 1</h1>' '\n<h2>Header 2</h2>') self.assertEqual(markdown(text, extensions='toc').strip(), '<div class="toc">\n<ul>\n<li><a href="#header-1">' 'Header 1</a><ul>\n<li><a href="#header-2">' 'Header 2</a></li>\n</ul>\n</li>\n</ul>\n</div>' '\n<h1 id="header-1">Header 1</h1>\n' '<h2 id="header-2">Header 2</h2>')
def test_markdown_extensions(self): text = '[TOC]\n\n# Header 1\n\n## Header 2' self.assertEquals( markdown(text).strip(), '<p>[TOC]</p>\n<h1>Header 1</h1>' '\n<h2>Header 2</h2>') self.assertEquals( markdown(text, extensions='toc').strip(), '<div class="toc">\n<ul>\n<li><a href="#header-1">' 'Header 1</a><ul>\n<li><a href="#header-2">' 'Header 2</a></li>\n</ul>\n</li>\n</ul>\n</div>' '\n<h1 id="header-1">Header 1</h1>\n' '<h2 id="header-2">Header 2</h2>')
def test_markdown(self): with warnings.catch_warnings(record=True) as w: result = markdown('My *text*') self.tearDown() self.assertEqual(result, 'My *text*') self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEqual(str(w[-1].message), "The Python markdown library isn't installed.")
def test_markdown(self): with warnings.catch_warnings(record=True) as w: result = markdown('My *text*') self.tearDown() self.assertEqual(result, 'My *text*') self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEqual( str(w[-1].message), "The Python markdown library isn't installed.")
def html_content(self): """ Returns the "content" field formatted in HTML. """ if MARKUP_LANGUAGE == 'markdown': return markdown(self.content) elif MARKUP_LANGUAGE == 'textile': return textile(self.content) elif MARKUP_LANGUAGE == 'restructuredtext': return restructuredtext(self.content) return linebreaks(self.content)
def test_markdown_extensions(self): text = '[TOC]\n\n# Header 1\n\n## Header 2' self.assertEqual(markdown(text).strip(), '<p>[TOC]</p>\n<h1>Header 1</h1>' '\n<h2>Header 2</h2>') self.assertEqual( markdown(text, extensions=['markdown.extensions.toc']).strip(), '<div class="toc">\n<ul>\n<li><a href="#header-1">' 'Header 1</a><ul>\n<li><a href="#header-2">' 'Header 2</a></li>\n</ul>\n</li>\n</ul>\n</div>' '\n<h1 id="header-1">Header 1</h1>\n' '<h2 id="header-2">Header 2</h2>') from markdown.extensions.toc import TocExtension tocext = TocExtension(marker='--TOC--', permalink='PL') self.assertEqual(markdown(text, extensions=[tocext]).strip(), '<p>[TOC]</p>\n<h1 id="header-1">Header 1' '<a class="headerlink" href="#header-1" ' 'title="Permanent link">PL</a></h1>\n' '<h2 id="header-2">Header 2' '<a class="headerlink" href="#header-2" ' 'title="Permanent link">PL</a></h2>')
def html_content(self): """ Returns the "content" field formatted in HTML. """ if "</p>" in self.content: return self.content elif MARKUP_LANGUAGE == "markdown": return markdown(self.content) elif MARKUP_LANGUAGE == "textile": return textile(self.content) elif MARKUP_LANGUAGE == "restructuredtext": return restructuredtext(self.content) return linebreaks(self.content)
def html_content(self): """ Returns the "content" field formatted in HTML. """ content = self.content if not content: return '' elif MARKUP_LANGUAGE == 'markdown': return markdown(content) elif MARKUP_LANGUAGE == 'textile': return textile(content) elif MARKUP_LANGUAGE == 'restructuredtext': return restructuredtext(content) elif '</p>' not in content: return linebreaks(content) return content
def test_markdown(self): self.assertEqual(markdown(self.text).strip(), '<p>Hello <em>World</em> !</p>')