Ejemplo n.º 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>')
Ejemplo n.º 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.")
Ejemplo n.º 3
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.")
Ejemplo n.º 4
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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 8
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
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 def test_restructuredtext(self):
     self.assertEqual(restructuredtext(self.text).strip(),
                      '<p>Hello <em>World</em> !</p>')