On this page
parse-html5
Prev: parse-md | Up: projects | Next: parse-mw
Rel: wispsy, Foundation, astree
Ref: wispsy on GitHub
Tags: #public #wispsy #project #foundation #tier/standard
Role
Source-preserving HTML5 parsing (parse, parse_fragment) and safe typed HTML rendering (render) for Python 3.14+ (0.1.0, zero runtime deps)—using immutable dataclass AST nodes with exact source slices, entity decoding, and safe default escaping.
Install
python -m pip install parse-html5
Quickstart
from parse_html5 import parse, parse_fragment, render
doc = parse("<main><h1>Hello & welcome</h1><br></main>")
assert doc.children[0].name == "main"
fragment = parse_fragment("<p>one</p><p>two</p>")
assert render(fragment) == "<p>one</p><p>two</p>"
When to Reach for It
- Parsing HTML5 documents or fragments into immutable source-span ASTs and rendering safe, escaped HTML (omitting event-handler attributes and unsafe URL schemes).
- Reach for astree when you want CSS selector queries and declarative
Fieldextraction.
Gotchas & Pitfalls
- Safe rendering strips unsafe constructs:
render()escapes text and omitson*event-handler attributes and unsafe URL schemes (javascript:) by default—do not expect raw script/handler passthrough. - Bounded input limits: Oversized documents or pathological nesting depth trigger explicit parse bounds rather than exhausting memory.
- Querying boundary:
parse-html5produces immutable source-span AST nodes; pair with astree if you need CSS selector queries or declarativeFieldextraction.
Pairs With
- parse-md — Sibling bounded parser for Markdown.
- parse-mw — Sibling bounded parser for MediaWiki markup.
Metadata
type: project-card
slug: parse-html5
org: wispsy
repo: wispsy/parse-html5
package: parse-html5
version: 0.1.0
requires_python: ">=3.14"
layer: foundation
topic: wispsy-foundation
status: active
language: python
source_docs: README.md, docs/
Linked from
Related notes
- wiki/projects/astree Linked here; links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/projects/parse-md Linked here; links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/projects/parse-mw Linked here; links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/stack/foundation Linked here; links to this page; shared tags: #foundation, #tier, #wispsy
- wiki/projects Linked here; links to this page; shared tags: #wispsy
- wiki/projects/parse-xml1 links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/choosing links to this page; shared tags: #tier, #wispsy
- wiki/compatibility links to this page; shared tags: #tier, #wispsy
- wiki/orgs/wispsy Linked here; shared tags: #tier, #wispsy
- tuts/third_party/python3/wispsy links to this page; shared tags: #tier