コード例 #1
0
 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>'
     )
コード例 #2
0
 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>')
コード例 #3
0
 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>')
コード例 #4
0
ファイル: test_markups.py プロジェクト: 17-1-SKKU-OSS/116A
 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.")
コード例 #5
0
 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.")
コード例 #6
0
ファイル: models.py プロジェクト: kissthink/www
 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)
コード例 #7
0
 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)
コード例 #8
0
 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>')
コード例 #9
0
 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)
コード例 #10
0
ファイル: entry.py プロジェクト: Cryhelyxx/django-blog-zinnia
 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
コード例 #11
0
 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
コード例 #12
0
ファイル: test_markups.py プロジェクト: paradizer/blog1
 def test_markdown(self):
     self.assertEqual(markdown(self.text).strip(),
                      '<p>Hello <em>World</em> !</p>')