Skip to main content

Module html

Module html 

Source
Expand description

HTML to text, text to HTML, and HTML charset declarations.

Functionsยง

add_html_token
Appends one text token of an HTML document to result, decoded when it is an entity (&, é), after a space when add_space is set. Invalid UTF-8 becomes U+FFFD. For callers with their own HTML tokenizer.
html_to_text
Converts HTML to plain text: tags are removed, entities decoded and white space collapsed; <br> and </p> become line breaks; the content of <head>, <style>, <script> and <template> is skipped.
strip_charset_meta
Rewrites the charset of the <meta charset> and <meta http-equiv="Content-Type"> declarations before <body to utf-8 (issue #109), so that a browser does not decode HTML that is already UTF-8 a second time. Borrowed when there is nothing to rewrite.
text_to_html
Converts plain text to HTML: <, > and & are escaped, line breaks become <br/>, carriage returns are dropped, and the result is wrapped in <html><body>.