@openexam/render-html
v0.1.0
Published
OEAST to HTML renderer for the preview path (spec 0.1).
Readme
@openexam/render-html
OEAST → HTML renderer for the preview path. Produces semantic HTML
for the 0.1 node set; dispatches Directive nodes to per-addon
HTML adapters supplied by the caller.
Public API
import { renderHtmlBody, renderHtmlDocument } from '@openexam/render-html';
import { mcHtmlAdapter } from '@openexam/mc';
const registry = {
'response:mc': mcHtmlAdapter({ moduleUrl: '/addons/mc/oe-mc.js' }),
};
const body = renderHtmlBody(doc, { widgetRegistry: registry });
const fullHtml = renderHtmlDocument(doc, { widgetRegistry: registry });renderHtmlBody returns just the rendered content as an HTML
fragment; useful for embedding into a host page or for
deterministic snapshot tests.
renderHtmlDocument wraps the body in a complete HTML5 document
with the deduplicated module + stylesheet imports the used widgets
declared.
Widget HTML adapters
Each addon ships an HTML adapter as part of its package. An adapter
is { render(directive): string, modules: string[], stylesheets?: string[] }.
The renderer dedups module/stylesheet URLs across all used widgets
in the document.
License
Apache-2.0. See LICENSE and the repository root
../../LICENSE.
