Opened 7 years ago

Closed 4 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 7 years ago by anonymous

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

comment:2 Changed 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:3 Changed 7 years ago by jacob

  • Triage Stage changed from Unreviewed to Design decision needed

comment:4 Changed 5 years ago by gabrielhurley

  • Component changed from Contrib apps to contrib.markup

comment:5 Changed 5 years ago by SmileyChris

  • Severity set to Normal
  • Type set to New feature

comment:6 Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Resolution set to invalid
  • Status changed from new to closed
  • 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