-
strip_html — Strip all HTML tags, returning plain text with paragraph breaks preserved.
comicbox.formats.base.online.sanitize¶
source module comicbox.formats.base.online.sanitize
HTML sanitization for description / long-text fields from online sources.
ComicVine’s description is HTML; mokkari’s desc may also contain HTML in some records. We strip all tags and return plain text. The result is what comicbox stores in summary and similar fields.
We use nh3 (the Python binding to the Rust ammonia library — same maintainers as bleach, much faster). Plain-text output is the v1 choice; downstream tools can render however they like.
Functions
source strip_html(text: str | None) → str | None
Strip all HTML tags, returning plain text with paragraph breaks preserved.
Block-level tags collapse to single newlines so the result reads like text rather than running together. Inline tags drop entirely. Runs of three+ newlines collapse to two (paragraph spacing).
Returns None for None input, “” for empty input.