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@example.com">' 'toto@example.com</a></p>') self.assertEqual( restructuredtext(text, {'cloak_email_addresses': True}).strip(), '<p>My email is <a class="reference external" ' 'href="mailto:toto%40example.com">' 'toto<span>@</span>example<span>.</span>com</a></p>')
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.")
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 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 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)
def test_restructuredtext(self): self.assertEqual(restructuredtext(self.text).strip(), '<p>Hello <em>World</em> !</p>')