NativeElixirPdfUtilities.HtmlToPdf.HtmlParser (native_elixir_pdf_utilities v0.11.0)
View SourceStrict HTML parser for the native HTML-to-PDF renderer.
Supports a strict subset of document-oriented HTML: structural
html/head/body/style tags, paragraphs, headings, inline emphasis/color
containers, div containers for flex/grid layouts, lists, links, tables,
images, static form controls, and CSS-targeting attributes, including
data-* and aria-* metadata used by attribute selectors and generated
content. Unsupported or malformed markup returns an error instead of
guessing at browser behavior.
Summary
Functions
Parses an HTML binary into a renderer DOM tree.
Parses an HTML binary and returns source-location details when parsing fails.
Types
@type dom_tree() :: %{type: :document, children: [element_node()]}
@type element_node() :: %{ type: :element, tag: String.t(), attributes: map(), children: [text_node() | element_node()] }
@type text_node() :: %{type: :text, text: String.t()}
Functions
@spec parse(term()) :: {:ok, dom_tree()} | {:error, :invalid_encoding | :invalid_html | :unsupported_html}
Parses an HTML binary into a renderer DOM tree.
@spec parse_detailed(term()) :: {:ok, dom_tree()} | {:error, {:invalid_encoding | :invalid_html | :unsupported_html, map()}}
Parses an HTML binary and returns source-location details when parsing fails.