diff -r 6098bc1d5160 -r fc0cdc82a6a7 django/contrib/markup/templatetags/markup.py
a
|
b
|
|
83 | 83 | else: |
84 | 84 | docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {}) |
85 | 85 | parts = publish_parts(source=smart_str(value), writer_name="html4css1", settings_overrides=docutils_settings) |
86 | | return mark_safe(force_unicode(parts["fragment"])) |
| 86 | return mark_safe(force_unicode(parts["html_body"])) |
87 | 87 | restructuredtext.is_safe = True |
88 | 88 | |
89 | 89 | register.filter(textile) |
diff -r 6098bc1d5160 -r fc0cdc82a6a7 django/contrib/markup/tests.py
a
|
b
|
|
38 | 38 | |
39 | 39 | .. _link: http://www.example.com/""" |
40 | 40 | |
| 41 | rest_headline_content = """Headline |
| 42 | ======== |
| 43 | |
| 44 | This is text.""" |
| 45 | |
41 | 46 | |
42 | 47 | @unittest.skipUnless(textile, 'texttile not installed') |
43 | 48 | def test_textile(self): |
… |
… |
|
73 | 78 | # Different versions of docutils return slightly different HTML |
74 | 79 | try: |
75 | 80 | # Docutils v0.4 and earlier |
76 | | self.assertEqual(rendered, """<p>Paragraph 1</p> |
77 | | <p>Paragraph 2 with a <a class="reference" href="http://www.example.com/">link</a></p>""") |
| 81 | self.assertEqual(rendered, """<div class="document"> |
| 82 | <p>Paragraph 1</p> |
| 83 | <p>Paragraph 2 with a <a class="reference" href="http://www.example.com/">link</a></p> |
| 84 | </div>""") |
78 | 85 | except AssertionError, e: |
79 | 86 | # Docutils from SVN (which will become 0.5) |
80 | | self.assertEqual(rendered, """<p>Paragraph 1</p> |
81 | | <p>Paragraph 2 with a <a class="reference external" href="http://www.example.com/">link</a></p>""") |
| 87 | self.assertEqual(rendered, """<div class="document"> |
| 88 | <p>Paragraph 1</p> |
| 89 | <p>Paragraph 2 with a <a class="reference external" href="http://www.example.com/">link</a></p> |
| 90 | </div>""") |
82 | 91 | |
83 | 92 | @unittest.skipIf(docutils, 'docutils is installed') |
84 | 93 | def test_no_docutils(self): |
85 | 94 | t = Template("{{ rest_content|restructuredtext }}") |
86 | 95 | rendered = t.render(Context({'rest_content':self.rest_content})).strip() |
87 | 96 | self.assertEqual(rendered, self.rest_content) |
88 | | |
| 97 | |
| 98 | @unittest.skipUnless(docutils, 'docutils not installed') |
| 99 | def test_docutils_headline(self): |
| 100 | t = Template("{{ rest_content|restructuredtext }}") |
| 101 | rendered = t.render(Context({'rest_content': self.rest_headline_content})).strip() |
| 102 | self.assertEqual(rendered, """<div class="document" id="headline"> |
| 103 | <h1 class="title">Headline</h1> |
| 104 | <p>This is text.</p> |
| 105 | </div>""") |
89 | 106 | |
90 | 107 | if __name__ == '__main__': |
91 | 108 | unittest.main() |