htmlfilter 0.2

White list HTML filter

  Add it to your Download Basket!

 Add it to your Watch List!

0/5

Rate it!
send us
an update
LICENSE TYPE:
BSD License 
USER RATING:
UNRATED
  0.0/5
DEVELOPED BY:
Samuel Adam
HOMEPAGE:
github.com
CATEGORY:
ROOT \ Text Editing&Processing \ Markup
htmlfilter is a very simple white list HTML filter.

Use it with a WYSIWYG editor on the client side.

Usage:

::
 from htmlfilter import HTMLFilter hf = HTMLFilter() cleaned_html = hf.filter(dirty_html)

Rules file

The filter is instanciated with a predefined set of rules. http://github.com/samueladam/htmlfilter/blob/master/htmlfilter/rules.py

You can create your own rules file:

# file: my_rules.py
TAGS = {
 'a': ('href', 'name',),
 'p': ('class',),
}

# define filters on attributes data (tag_attr)
def p_class(data):
 if data not in ('class1', 'class2',):
 data = ''
 return data


And use them this way:

from htmlfilter import HTMLFilter
import my_rules

hf = HTMLFilter(rules=my_rules)
cleaned_html = hf.filter(dirty_html)

Last updated on May 4th, 2010

requirements

#white list #HTML filter #HTML #filter #white #list

Add your review!

SUBMIT