Opened 17 years ago
Closed 17 years ago
#4881 closed (fixed)
strange behaviour of rst from django.contrib.markup
Reported by: | Rafael Weber | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Contrib apps | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hoi,
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
aa ~~
in flatpage.content
, the page has no content (rendered in the browser).
But if I write
asdfjslkdfjlk lkdjfkl sdjfsdfsdfjowier sdfklj aa ~~
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)
Change History (5)
follow-up: 2 comment:1 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
by , 17 years ago
Attachment: | rst_django_bug.diff added |
---|
follow-up: 3 comment:2 by , 17 years ago
Has patch: | set |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
I patched it. Just use publish_string
instead of publish_parts
.
Cheers,
Rafael Weber
by , 17 years ago
Attachment: | rst_django_bug.2.diff added |
---|
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → 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/markup.py =================================================================== @@ -42,18 +42,17 @@ def restructuredtext(value): try: - 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) else: 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) register.filter(textile) register.filter(markdown) register.filter(restructuredtext) -
Sorry for this two attachments but it didn't work though the patch was in the correct file.
This is normal docutils behaviour. The first heading counts as the page title. See this django-users thread for more information.