Expand description
A small, std-only HTML-to-text converter for the fetch tool.
This is a readable approximation, not a renderer: it strips tags, drops the contents
of <script>/<style> and similar, decodes common entities, collapses whitespace and
keeps rough structure (blank lines between blocks, - for list items, preserved
<pre> text, link targets in parentheses). It does not run scripts, apply CSS, lay out
tables, or repair badly broken markup, so complex pages can come out noisy or lose
content that only exists after JavaScript runs.
Functionsยง
- decode_
entities - Decode the common named entities and numeric references; anything else is kept as is.
- looks_
like_ html - Whether a response should be treated as HTML: the content type says so, or the body
starts with
<!doctype html/<html(unless the content type is JSON or binary). - to_text
- Convert an HTML document or fragment to plain text. Never fails; malformed input just produces less tidy output.