示例#1
0
 def test_restructuredtext_settings_override(self):
     text = 'My email is [email protected]'
     self.assertEqual(restructuredtext(text).strip(),
                      '<p>My email is <a class="reference external" '
                      'href="mailto:toto&#64;example.com">'
                      'toto&#64;example.com</a></p>')
     self.assertEqual(
         restructuredtext(text, {'cloak_email_addresses': True}).strip(),
         '<p>My email is <a class="reference external" '
         'href="mailto:toto&#37;&#52;&#48;example&#46;com">'
         'toto<span>&#64;</span>example<span>&#46;</span>com</a></p>')
示例#2
0
 def test_restructuredtext(self):
     with warnings.catch_warnings(record=True) as w:
         result = restructuredtext('My *text*')
     self.tearDown()
     self.assertEqual(result, 'My *text*')
     self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
     self.assertEqual(str(w[-1].message),
                      "The Python docutils library isn't installed.")
 def test_restructuredtext(self):
     with warnings.catch_warnings(record=True) as w:
         result = restructuredtext('My *text*')
     self.tearDown()
     self.assertEqual(result, 'My *text*')
     self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
     self.assertEqual(
         str(w[-1].message),
         "The Python docutils library isn't installed.")
示例#4
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)
示例#5
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)
示例#6
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)
示例#7
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
 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
示例#9
0
文件: models.py 项目: Starsam80/www
 def html_content(self):
     """
     Returns the "content" field formatted in HTML.
     """
     if MARKUP_LANGUAGE == 'markdown':
         # TODO: Remove when Zinnia supports non-string Markdown exts.
         import markdown
         from zinnia.settings import MARKDOWN_EXTENSIONS
         from django.utils.encoding import force_text
         return markdown.markdown(force_text(self.content),
                                  extensions=MARKDOWN_EXTENSIONS,
                                  safe_mode=False)
     elif MARKUP_LANGUAGE == 'textile':
         return textile(self.content)
     elif MARKUP_LANGUAGE == 'restructuredtext':
         return restructuredtext(self.content)
     return linebreaks(self.content)
示例#10
0
文件: models.py 项目: greg100795/www
 def html_content(self):
     """
     Returns the "content" field formatted in HTML.
     """
     if MARKUP_LANGUAGE == 'markdown':
         # TODO: Remove when Zinnia supports non-string Markdown exts.
         import markdown
         from zinnia.settings import MARKDOWN_EXTENSIONS
         from django.utils.encoding import force_text
         return markdown.markdown(force_text(self.content),
                                  extensions=MARKDOWN_EXTENSIONS,
                                  safe_mode=False)
     elif MARKUP_LANGUAGE == 'textile':
         return textile(self.content)
     elif MARKUP_LANGUAGE == 'restructuredtext':
         return restructuredtext(self.content)
     return linebreaks(self.content)
示例#11
0
 def test_restructuredtext(self):
     self.assertEqual(restructuredtext(self.text).strip(),
                      '<p>Hello <em>World</em> !</p>')