Skip to main content

Crate rustyfi_html

Crate rustyfi_html 

Source
Expand description

HTML output backend (--format html): one continuous, self-contained, semantic web document.

The whole backend lives in the [reflow] submodule — see its doc comment for what the box stream becomes and why. This root module holds only what that submodule and its helpers share: the crate’s error type, HTML escaping, and the base64/fonts/image/svg helper modules.

The document is built from the flat block stream as it stood BEFORE page breaking (DocumentValue::reflow_source in rustyfi-lang), so there are no pages in it and nothing is cut at a page boundary; the browser does the line breaking. Nothing is fetched and nothing is executed — graphics and math are inline <svg> (svg.rs), images are data URIs (image.rs), and fonts are NAMED rather than embedded (fonts.rs’s reflow_font_stack).

Location. This is its own rustyfi-html crate, a peer of rustyfi-pdf. It depends on rustyfi-backend for every box/geometry type it walks, plus rustyfi-pdf for rustyfi_pdf::TtfFontStore (the one type this crate reuses rather than re-implements — only its pub file_index/file_family_name accessors are used, so this is a plain one-way dependency, not a cycle: rustyfi-pdf does not depend on rustyfi-html). Nothing here touches pdf_writer or any other PDF-specific type, only rustyfi_backend/rustyfi_pdf::TtfFontStore types and String building.

Enums§

HtmlError
Rendering is in practice infallible — every text run is valid UTF-8/HTML-escapable, and image/font handling reads from tables the compile step already validated. The Result return shape is kept anyway so the entry points are argument-for-argument (module signature, not module fallibility) with rustyfi_pdf::render_pdf_with, and so a future embedding step can surface a real error without a breaking signature change.

Functions§

render_html_reflow
Serialize the pre-page-break Vec<VertBox> (sourceDocumentValue::reflow_source, None when unavailable, e.g. a hand-built DocumentValue in a test) to a single, self-contained, REFLOWABLE HTML document, leaving every run’s face to the stylesheet’s own generic stack — the base-14 twin of render_html_reflow_ttf_with, exactly mirroring rustyfi_pdf::render_pdf_with’s relationship to rustyfi_pdf::render_pdf_ttf_with.
render_html_reflow_ttf_with
Same as render_html_reflow, but rendering under a real TtfFontStore — the document’s faces are then NAMED (crate::fonts::reflow_font_stack) rather than left to the stylesheet’s generic stack: the dominant face goes on the body rule (css.rs), and only a run that departs from it names a family of its own (inline.rs’s emit_run) — so the bulk of the prose stays bare text with no <span> at all. Nothing is embedded; see crate::fonts for why a reflowed document does not pay for that.
render_html_reflow_ttf_with_decos
render_html_reflow_ttf_with plus the frame decorations — the full-fidelity entry point the CLI uses.
render_html_reflow_with_decos
render_html_reflow plus the frame decorations (DocumentValue::reflow_frame_decos), so framed blocks draw their own decoration instead of nothing.