Opened 8 years ago

Closed 8 years ago

#4881 closed (fixed)

strange behaviour of rst from django.contrib.markup

Reported by: Rafael Weber Owned by: adrian
Component: Contrib apps Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:



I'm using django svn at revision 5699 and docutils 0.4.

To use rst, i use the template tags from django.contrib.markup with the following code:

{% load markup %}
{{ flatpage.content|restructuredtext }}

If I write


in flatpage.content, the page has no content (rendered in the browser).

But if I write




it is rendered as normal <h1>. That's just one strange behaviour.

I already searched through the tickets and asked in the IRC - without any success.

Attachments (2)

rst_django_bug.diff (1.0 KB) - added by Rafael Weber 8 years ago.
rst_django_bug.2.diff (1.0 KB) - added by Rafael Weber 8 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 follow-up: Changed 8 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

This is normal docutils behaviour. The first heading counts as the page title. See this django-users thread for more information.

Changed 8 years ago by Rafael Weber

comment:2 in reply to: ↑ 1 ; follow-up: Changed 8 years ago by anonymous

  • Has patch set
  • Resolution invalid deleted
  • Status changed from closed to reopened

I patched it. Just use publish_string instead of publish_parts.


Rafael Weber

Changed 8 years ago by Rafael Weber

comment:3 in reply to: ↑ 2 Changed 8 years ago by anonymous

  • Resolution set to fixed
  • Status changed from reopened to closed

Hmm -- I uploaded the patch but the trac shows that the file is empty (not correct, the patch is in the file).

So, here is the patch:

Index: django/trunk/django/contrib/markup/templatetags/
@@ -42,18 +42,17 @@
 def restructuredtext(value):
-        from docutils.core import publish_parts
+        from docutils.core import publish_string
     except ImportError:
         if settings.DEBUG:
             raise template.TemplateSyntaxError, "Error in {% restructuredtext %} filter: The Python docutils library isn't installed."
         return force_unicode(value)
         docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
-        parts = publish_parts(source=smart_str(value), writer_name="html4css1", settings_overrides=docutils_settings)
-        return force_unicode(parts["fragment"])
+        result = publish_string(source=smart_str(value), writer_name="html4css1", settings_overrides=docutils_settings)
+        return force_unicode(result)

Sorry for this two attachments but it didn't work though the patch was in the correct file.

Note: See TracTickets for help on using tickets.
Back to Top