Documentation
¶
Overview ¶
Package markup strips HTML/XML markup, leaving normalized plain text.
Unlike formatting-oriented html2text converters, StripTags produces strictly normalized text under normtext's determinism and golden-freeze guarantees: tags dropped, entities decoded, block boundaries becoming single newlines, script/style/title contents dropped. It is not a boilerplate or readability extractor — structural stripping only.
Behavior is pinned by the golang.org/x/net version in go.mod (its tokenizer and entity table are the Unicode-dependent surface here).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StripTags ¶
StripTags returns a Transform that removes HTML/XML tags and decodes entities, leaving plain text. It uses x/net/html tokenization (not regexes), so malformed markup degrades deterministically rather than catastrophically. Rules (frozen):
- Tag and attribute content, comments, and doctypes are dropped.
- The contents of the raw-text elements script, style, title, iframe, noembed, and noframes are dropped.
- Block-level boundaries (p, div, br, li, headings, tr, table, ...) become a single newline; td/th boundaries become a single space; inline tags (span, b, a, ...) add nothing.
- Entities decode to their characters: "&" → "&", "<" → "<".
- Text outside tags is preserved verbatim, including whitespace.
NOT idempotent: decoded entities can form new tag-like text ("<b>" → "<b>", which a second application would strip). Apply once. Input containing neither '<' nor '&' passes through allocation-free; input the tokenizer leaves unchanged (e.g. "a < b") returns the original string. Invalid UTF-8 is handled deterministically by the tokenizer.
func StripTagsStep ¶
StripTagsStep is StripTags as a Pipeline step, named "markup/striptags".
Types ¶
This section is empty.