Skip to main content

Module html_to_text

Module html_to_text 

Source
Expand description

Dependency-free HTML → Markdown / plain-text conversion.

A small tag tokenizer feeds a state-machine renderer. The goal is clean, readable content for an LLM, not a faithful DOM: noise elements (script, style, nav chrome) are dropped, block structure becomes Markdown headings / lists / paragraphs, links become [text](href), and <pre> becomes fenced code. Implemented without an HTML crate to stay in line with the project’s zero-heavy-dependency stance.

Structs§

HtmlDoc
Parsed document: optional <title>, rendered Markdown, and extracted links.
Link
A hyperlink extracted from the document.

Functions§

decode_entities
Decode HTML/XML character entities (&amp;, &#39;, &#x2019;, …).
markdown_to_text
Strip Markdown decorations to obtain flowing plain text.
parse
Convert an HTML document into Markdown plus extracted metadata.
title
Extract just the document <title> without rendering the body.