Skip to content
QuireKit
Core docs
Alpha · evolving API
Extension developmentView Markdown ↗

HTML and Markdown conversion

Choose browser or server conversion APIs and understand Schema, format rules and data loss.

HTML and Markdown are input/output representations. Conversion does not install extensions or produce Classic's paginated interface. Choose your product's Schema, then supply rules for the content you need to exchange.

Browser: read the current editor

An Editor exposes getJSON(), getHTML() and getMarkdown(). HTML uses node/mark renderHTML() rules; JSON represents canonical content; Markdown uses installed extension rules. See reading and replacing content for strict JSON restoration.

For HTML conversion without an Editor, use generateJSON(html, extensions) and generateHTML(json, extensions) from @quirekit/html. The browser entry requires a DOM; do not execute it directly in a Node server.

Server: select the separate entry

Install HTML utilitiessh

Node uses @quirekit/html/server. Utilities receive resolved extensions: expand composites such as StarterKit through resolveExtensions() first. This function mounts no View, needs no client Editor and shares no DOM document between requests:

core/formats/server.tsts

Client and server need compatible extensions and configuration. A server that understands only paragraphs cannot restore client business cards. generateJSON() normalizes HTML against the Schema and may discard unknown tags, attributes or styles. A successful result does not establish lossless HTML preservation.

Parsing and security filtering are separate. The converter is not a general sanitizer. Apply your content policy to untrusted HTML and explicitly decide which links, images and external resources to permit.

Markdown: declare the input type

Strings default to HTML. For Markdown, creation options or setContent() options must include contentType: 'markdown'.

core/formats/markdown.tsts

The recipe handles content supported by StarterKit and emits normalized Markdown. Original whitespace, delimiter spelling and unsupported syntax are not guaranteed to survive. Restore JSON with the same model for continued editing; reparsing Markdown is not lossless JSON storage.

A custom Node/Mark's HTML rules do not become Markdown rules. Custom syntax needs Markdown token parsing and rendering contracts too. Until implemented, explicitly reject, downgrade or preserve the original separately. A typing rule for ==text== does not teach that syntax to the Markdown parser.

Choose a storage format

GoalApproach
Restore product content preciselyVersioned canonical JSON plus media assets
Publish or exchange semantic HTMLHTML rules, tested with links, images and custom nodes
Interoperate with Markdown toolsDefined supported syntax and loss policy, tested both ways
Preserve Word pages, styles and relationshipsWord model and DOCX service with conversion diagnostics

Round-trip headings, mixed marks, lists, links and a business node. Compare canonical structure and meaningful attributes; textContent alone misses structure and formatting loss.

QuireKitQuireKit · Core, plugins and Classic docs