Opened 9 years ago

Closed 6 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


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"):
        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)
        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



Attachments (1)

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

Download all attachments as: .zip

Change History (8)

comment:1 Changed 9 years ago by jjconti

Component: UncategorizedContrib apps

comment:2 Changed 9 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 Changed 9 years ago by Jacob

Triage Stage: UnreviewedDesign decision needed

comment:4 Changed 9 years ago by Chris Beaven

See also: #11342

comment:5 Changed 7 years ago by Gabriel Hurley

Component: Contrib appscontrib.markup

comment:6 Changed 7 years ago by Luke Plant

Severity: Normal
Type: New feature

Changed 6 years ago by Aymeric Augustin

Attachment: 9504.patch added

comment:7 Changed 6 years ago by Aymeric Augustin

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