Opened 16 years ago

Closed 13 years ago

#9504 closed New feature (duplicate)

Extension for restructuredtext filter a django.contrib.markup

Reported by: jjconti Owned by: nobody
Component: contrib.markup Version: 1.0
Severity: Normal Keywords: markup restructuredtext
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As suggested at 0 I browserd markup sorce code1 to see how does restructuredtext filter work. I founded that it returns only the fragment part instead on other contet. I suggest an argument fot the filter to be used in parts[arg].

The suggested implementation is, as follow (two small changes):

def restructuredtext(value, arg="fragment"):
    try:
        from docutils.core import publish_parts
    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 mark_safe(force_unicode(parts[arg]))
restructuredtext.is_safe = True

[0] http://docs.djangoproject.com/en/dev/ref/contrib/#ref-contrib-markup

[1] http://code.djangoproject.com/browser/django/trunk/django/contrib/markup/templatetags/markup.py

Attachments (1)

9504.patch (892 bytes ) - added by Aymeric Augustin 13 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by jjconti, 16 years ago

Component: UncategorizedContrib apps

comment:2 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 by Jacob, 16 years ago

Triage Stage: UnreviewedDesign decision needed

comment:4 by Chris Beaven, 16 years ago

See also: #11342

comment:5 by Gabriel Hurley, 14 years ago

Component: Contrib appscontrib.markup

comment:6 by Luke Plant, 14 years ago

Severity: Normal
Type: New feature

by Aymeric Augustin, 13 years ago

Attachment: 9504.patch added

comment:7 by Aymeric Augustin, 13 years ago

Easy pickings: unset
Resolution: duplicate
Status: newclosed
UI/UX: unset

I just turned the snippet into a diff for ease of reviewing. This ticket conflicts with #11342 which has a much better explanation of the issue at hand. I'll close it as a duplicate of #11342 and leave a note over there.

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