Opened 16 years ago

Closed 13 years ago

#10126 closed New feature (invalid)

Add sanitize and tidy options to textile filter.

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

Description

The current textile filter is really basic, you can't set any options, like validating the HTML, or sanitizing the HTML.

I made a simple workaround for this problem:
django/contrib/markup/templatetags/markup.py

def textile(value, arg=''):
    try:
        import textile
    except ImportError:
        if settings.DEBUG:
            raise template.TemplateSyntaxError, "Error in {% textile %} filter: The Python textile library isn't installed."
        return force_unicode(value)
    else:
        args = arg.split(',')
        
        sanitize = 'sanitize' in args
        tidy = 'tidy' in args
        
        return mark_safe(force_unicode(textile.textile(smart_str(value), sanitize=sanitize, validate=tidy, encoding='utf-8', output='utf-8')))
textile.is_safe = True

Now you can add a comma seperated list of args to the textile filter, to validate the output, or sanitizing it.

Change History (6)

comment:1 by anonymous, 16 years ago

Cc: luckyluke56@… added

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 Gabriel Hurley, 14 years ago

Component: Contrib appscontrib.markup

comment:5 by Chris Beaven, 14 years ago

Severity: Normal
Type: New feature

comment:6 by Aymeric Augustin, 13 years ago

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

I went to read the source for the latest version of textile.textile(), and it doesn't acccept validate or sanitize. Here's the signature of the function:

textile(text, head_offset=0, html_type='xhtml', encoding=None, output=None)
Note: See TracTickets for help on using tickets.
Back to Top