Expand description
HTML → Damascene El transformer.
use damascene_core::prelude::*;
use damascene_html::html;
let tree: El = html("<h1>Hi</h1><p>Hello <strong>world</strong>.</p>");damascene-html is a focused HTML-to-El transformer, not a browser
engine. The thesis: Damascene’s widget kit already echoes most of HTML’s
semantic vocabulary (text_runs ≈ <p>, hard_break ≈ <br>,
span modifiers ≈ inline tags, bullet_list ≈ <ul>,
code_block ≈ <pre><code>, table ≈ <table>, …), so a parse
through html5ever plus a tag-by-tag mapping onto the existing
widget vocabulary produces a faithful render for the subset of HTML
that actually fits.
Supported coverage (per docs/HTML_VISION.md):
- Tier 1 — direct widget mapping. Headings
<h1>…<h3>(h4–h6 clamp to h3), paragraphs with the inline tag set (<strong>/<b>,<em>/<i>,<u>,<s>/<strike>/<del>,<code>,<a href>,<br>,<kbd>,<mark>),<ul>/<ol>/<li>with nesting + GFM task-list shape,<blockquote>,<pre><code class="language-X">,<hr>, full table tag family,<img>placeholders. - Tier 2A — inline
style="...". Color, background, padding, border, radius, opacity, width/height + min/max, text-align, font-size/weight/style, text-decoration. - Tier 2B —
<style>blocks + selectors. Tag / class / id / compound / comma-grouped selectors with full specificity sort. At-rules and unsupported selector shapes drop with lint findings. - Tier 2C — generic containers.
<div>,<section>,<details>,<figure>,<button>,<input type="checkbox">(all cosmetic). - Tier 2D — layout reshape + lint surface.
display: flex+flex-direction,align-items,justify-content,overflow(hidden → clip, auto/scroll → wrap inscroll),box-shadow(blur extracted),font-familymonospace detection, andmargin*reconciled into parentgap. Properties without an Damascene equivalent (position,float,vh/vw/fr,display: grid, …) drop withFindings exposed through the_with_lintsentry points.
Tier 3 (security-dropped: <script>, <iframe>, <object>,
<embed>, <noscript>, every on* attribute, every
javascript: / vbscript: / data:text/html URL) is enforced
always. Embedders handling untrusted HTML should still layer a
dedicated sanitizer (e.g. ammonia) in front.
Structs§
- Finding
- One lint occurrence.
detailis a human-readable hint: the dropped property name + value, the collided margin pair, the unsupported selector text, and so on. - Html
Options - Optional knobs for
crate::html_with_options.
Enums§
- Finding
Kind - What was dropped or coerced, in a single dimension. The transformer emits at most one finding per (node, kind) tuple, so a single element with three unsupported properties produces three findings.
Functions§
- html
- Render an HTML document as an Damascene
El. Returns acolumn([...])of block-level Damascene widgets — the same shape an author would have hand-written, and the same shapedamascene_markdown::mdreturns. - html_
blocks - Like
html_with_optionsbut returns the block-level Els directly instead of wrapping them in acolumn. Intended for callers (e.g.damascene-markdown’s block-HTML event handler) that already have a containing block frame and just want the produced children appended. - html_
blocks_ with_ lints - Lints-returning sibling of
html_blocks. The reconciledgapis not surfaced — the calling block frame already owns its rhythm — but margin-asymmetry findings still land in the result. - html_
fragment_ inline - Inline-only entry point: parse
inputas an HTML fragment and return the inline runs it produces. The intended caller isdamascene-markdown’sEvent::InlineHtmlhandler, which buffers consecutive inline-HTML events into one string, hands the buffer here, and appends the produced runs to the open paragraph / heading / link / table cell. - html_
fragment_ inline_ with_ lints - Lints-returning sibling of
html_fragment_inline. - html_
with_ lints - Like
html_with_optionsbut also returns the lint findings gathered during the walk. Use this when you need to surface dropped declarations, unsupported selectors, or margin-asymmetry reconciliations to the author or downstream tools. - html_
with_ options - Render an HTML document with explicit options.