damascene_html/lib.rs
1//! HTML → Damascene `El` transformer.
2//!
3//! ```ignore
4//! use damascene_core::prelude::*;
5//! use damascene_html::html;
6//!
7//! let tree: El = html("<h1>Hi</h1><p>Hello <strong>world</strong>.</p>");
8//! ```
9//!
10//! `damascene-html` is a focused HTML-to-`El` transformer, not a browser
11//! engine. The thesis: Damascene's widget kit already echoes most of HTML's
12//! semantic vocabulary (`text_runs` ≈ `<p>`, `hard_break` ≈ `<br>`,
13//! span modifiers ≈ inline tags, `bullet_list` ≈ `<ul>`,
14//! `code_block` ≈ `<pre><code>`, `table` ≈ `<table>`, …), so a parse
15//! through `html5ever` plus a tag-by-tag mapping onto the existing
16//! widget vocabulary produces a faithful render for the subset of HTML
17//! that actually fits.
18//!
19//! Supported coverage (per `docs/HTML_VISION.md`):
20//!
21//! - **Tier 1 — direct widget mapping.** Headings `<h1>`…`<h3>`
22//! (h4–h6 clamp to h3), paragraphs with the inline tag set
23//! (`<strong>`/`<b>`, `<em>`/`<i>`, `<u>`, `<s>`/`<strike>`/`<del>`,
24//! `<code>`, `<a href>`, `<br>`, `<kbd>`, `<mark>`), `<ul>` / `<ol>`
25//! / `<li>` with nesting + GFM task-list shape, `<blockquote>`,
26//! `<pre><code class="language-X">`, `<hr>`, full table tag family,
27//! `<img>` placeholders.
28//! - **Tier 2A — inline `style="..."`.** Color, background, padding,
29//! border, radius, opacity, width/height + min/max, text-align,
30//! font-size/weight/style, text-decoration.
31//! - **Tier 2B — `<style>` blocks + selectors.** Tag / class / id /
32//! compound / comma-grouped selectors with full specificity sort.
33//! At-rules and unsupported selector shapes drop with lint findings.
34//! - **Tier 2C — generic containers.** `<div>`, `<section>`, `<details>`,
35//! `<figure>`, `<button>`, `<input type="checkbox">` (all cosmetic).
36//! - **Tier 2D — layout reshape + lint surface.** `display: flex` +
37//! `flex-direction`, `align-items`, `justify-content`, `overflow`
38//! (hidden → clip, auto/scroll → wrap in `scroll`), `box-shadow`
39//! (blur extracted), `font-family` monospace detection, and
40//! `margin*` reconciled into parent `gap`. Properties without an
41//! Damascene equivalent (`position`, `float`, `vh`/`vw`/`fr`,
42//! `display: grid`, …) drop with [`Finding`]s exposed through the
43//! `_with_lints` entry points.
44//!
45//! Tier 3 (security-dropped: `<script>`, `<iframe>`, `<object>`,
46//! `<embed>`, `<noscript>`, every `on*` attribute, every
47//! `javascript:` / `vbscript:` / `data:text/html` URL) is enforced
48//! always. Embedders handling untrusted HTML should still layer a
49//! dedicated sanitizer (e.g. `ammonia`) in front.
50
51mod css;
52mod lints;
53mod options;
54mod parser;
55mod sanitize;
56mod selectors;
57mod transform;
58
59pub use lints::{Finding, FindingKind};
60pub use options::HtmlOptions;
61pub use transform::{
62 html, html_blocks, html_blocks_with_lints, html_fragment_inline,
63 html_fragment_inline_with_lints, html_with_lints, html_with_options,
64};