Hwaro::Utils::HtmlMinifier
Constants
HTML block-level elements. Whitespace adjacent to a block-level neighbour has no visual effect:
- between two block siblings the user agent renders them on separate lines anyway,
- leading whitespace inside a block parent is collapsed by the browser before the first inline child,
- trailing whitespace before a block close is collapsed after the last inline child. Anything not listed here is treated as inline, where whitespace between siblings collapses to a single rendered space and must therefore be kept as one literal space.
Classification of protected tags by default HTML display so the inter-token whitespace pass can treat sealed blocks as if they were their original tag.
Tags whose content must be preserved verbatim. Extracted into
placeholders before any whitespace pass and restored afterward.
code is included because inline-code snippets often carry
whitespace that authors expect to ship unchanged.
Order matters: a <style> body may legitimately contain the
literal string <script> (e.g. content: "<script>"), so
style is extracted first to remove that text from view
before the script pass runs.
Instance methods
Minify the given HTML.
Example: minify("
Hello
\n=> "Hello
"
Hello
minify("x\ny")