sempdf v1.9.1Functions
Function: htmlToBlocks()
sempdf / htmlToBlocks
function htmlToBlocks(html, options?): TemplateBlock[];Defined in: src/internal/html-blocks.ts:599
Converts an HTML fragment or document into template blocks.
Supported block elements: h1–h6, p, div, ul/ol/li (nested, and
mixed ordered/unordered), dl/dt/dd, pre (a code block), blockquote,
table (with th/colspan/rowspan), hr, img, figure/figcaption,
and the sectioning elements, which are unwrapped. Supported inline elements:
strong/b, em/i, u, s/del/strike, mark, code/kbd/samp,
sup, sub, small, span, a, and br.
Unknown elements are unwrapped so their text still renders; <script>,
<style>, form controls, and embedded objects are dropped with their
content.
Parameters
| Parameter | Type | Description |
|---|---|---|
html | string | The HTML to convert. Tag soup is tolerated. |
options | HtmlToBlocksOptions | Mapping and styling options. |
Returns
Blocks ready for renderTemplate, flow.render, or renderDocumentJson.