Opened 8 years ago

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


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:

def textile(value, arg=''):
        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)
        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 Changed 8 years ago by anonymous

Cc: luckyluke56@… added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 Changed 8 years ago by Jacob

Triage Stage: UnreviewedDesign decision needed

comment:4 Changed 6 years ago by Gabriel Hurley

Component: Contrib appscontrib.markup

comment:5 Changed 6 years ago by Chris Beaven

Severity: Normal
Type: New feature

comment:6 Changed 5 years ago by Aymeric Augustin

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