Rich text / foldkit-richtext

HTML export

toHtml(blocks) and documentToHtml(document) serialize to HTML for other applications; toText / documentToText give the plain-text projection.

ts
RichText.documentToHtml(document)
// → '<p>plain <strong>bold</strong></p><h2><code><em>Title</em></code></h2>'

Known marks become strong/em/code in a deterministic nesting order (not the order they were added), unknown marks survive as data-marks on a span, unknown blocks as a <div data-unknown="Type"> placeholder, and text and attribute values are escaped, so content cannot become markup. Importing HTML is a whitelist walk over a DOMParser tree, and the read-only Foldkit view is built with inertHtml; the importer, the view, and the editable DOM interpreter all live in foldkit-richtext-dom, because this package stays DOM-free and framework-free. Nothing parses HTML back into authority without that walk.