Package lxml :: Package html :: Module clean
[frames] | no frames]

Module clean

source code

A cleanup tool for HTML.

Removes unwanted tags and content. See the Cleaner class for details.

Classes
  Cleaner
Instances cleans the document of each of the possible offending elements.
Functions
 
clean_html(html) source code
 
autolink(el, link_regexes=[re.compile(r'(?i)(?P<body>https?://(?P<host>[a-z0-9\._-]+)(?:..., avoid_elements=['textarea', 'pre', 'code', 'head', 'select', 'a'], avoid_hosts=[re.compile(r'(?i)^localhost'), re.compile(r'(?i)\bexample\.(?..., avoid_classes=['nolink'])
Turn any URLs into links.
source code
 
autolink_html(html, *args, **kw)
Turn any URLs into links.
source code
 
word_break(el, max_width=40, avoid_elements=['pre', 'textarea', 'code'], avoid_classes=['nobreak'], break_character=u'')
Breaks any long words found in the body of the text (not attributes).
source code
 
word_break_html(html, *args, **kw) source code
Variables
  clean = Cleaner()
Function Details

autolink(el, link_regexes=[re.compile(r'(?i)(?P<body>https?://(?P<host>[a-z0-9\._-]+)(?:..., avoid_elements=['textarea', 'pre', 'code', 'head', 'select', 'a'], avoid_hosts=[re.compile(r'(?i)^localhost'), re.compile(r'(?i)\bexample\.(?..., avoid_classes=['nolink'])

source code 

Turn any URLs into links.

It will search for links identified by the given regular expressions (by default mailto and http(s) links).

It won't link text in an element in avoid_elements, or an element with a class in avoid_classes. It won't link to anything with a host that matches one of the regular expressions in avoid_hosts (default localhost and 127.0.0.1).

If you pass in an element, the elements tail will not be substituted, only the contents of the element.

autolink_html(html, *args, **kw)

source code 

Turn any URLs into links.

It will search for links identified by the given regular expressions (by default mailto and http(s) links).

It won't link text in an element in avoid_elements, or an element with a class in avoid_classes. It won't link to anything with a host that matches one of the regular expressions in avoid_hosts (default localhost and 127.0.0.1).

If you pass in an element, the elements tail will not be substituted, only the contents of the element.

word_break(el, max_width=40, avoid_elements=['pre', 'textarea', 'code'], avoid_classes=['nobreak'], break_character=u'')

source code 

Breaks any long words found in the body of the text (not attributes).

Doesn't effect any of the tags in avoid_elements, by default <textarea> and <pre>

Breaks words by inserting &#8203;, which is a unicode character for Zero Width Space character. This generally takes up no space in rendering, but does copy as a space, and in monospace contexts usually takes up space.

See http://www.cs.tut.fi/~jkorpela/html/nobr.html for a discussion