Ticket #14449: markup-rest.diff

File markup-rest.diff, 2.7 KB (added by Julian, 14 years ago)
  • django/contrib/markup/templatetags/markup.py

    diff -r 6098bc1d5160 -r fc0cdc82a6a7 django/contrib/markup/templatetags/markup.py
    a b  
    8383    else:
    8484        docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
    8585        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"]))
    8787restructuredtext.is_safe = True
    8888
    8989register.filter(textile)
  • django/contrib/markup/tests.py

    diff -r 6098bc1d5160 -r fc0cdc82a6a7 django/contrib/markup/tests.py
    a b  
    3838
    3939.. _link: http://www.example.com/"""
    4040
     41    rest_headline_content = """Headline
     42========
     43   
     44This is text."""
     45
    4146
    4247    @unittest.skipUnless(textile, 'texttile not installed')
    4348    def test_textile(self):
     
    7378        # Different versions of docutils return slightly different HTML
    7479        try:
    7580            # 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>""")
    7885        except AssertionError, e:
    7986            # 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>""")
    8291
    8392    @unittest.skipIf(docutils, 'docutils is installed')
    8493    def test_no_docutils(self):
    8594        t = Template("{{ rest_content|restructuredtext }}")
    8695        rendered = t.render(Context({'rest_content':self.rest_content})).strip()
    8796        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>""")
    89106
    90107if __name__ == '__main__':
    91108    unittest.main()
Back to Top