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 whenadd_spaceis 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<bodytoutf-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>.