/**
* @file AST → HTML string, directly.
*
* The package's second emitter, and deliberately not a wrapper around
* the first (ARCHITECTURE.md "Two emitters"). `mdToVnode` builds a
* PATCHABLE TREE — keyed, memoized, reference-stable — whose safety is
* structural: a vnode has no slot for unescaped author markup, which is
* why a lone `` cannot survive it. `toHtml` builds BYTES, and a
* string can hold half an element, so the raw-HTML corner of CommonMark
* is reachable here and only here.
*
* What the two share is factored, not copied: the escapers are
* `@jarenjs/view`'s (the same ones its SSR renderer uses, which is what
* makes the two outputs byte-identical for markup a vnode can express),
* the URL policy is `@jarenjs/view/helpers`, heading slugs come from
* `@jarenjs/core/string` through `utils.js`, and plugin dispatch is the
* parser's own table.
*
* Escaping is the default and `html: 'raw'` is per-call: the default
* cannot emit unescaped author content, and no jaren surface passes
* `'raw'`.
*/
export type MdNode = import('./ast.js').MdNode;
export type MdHtmlOptions = {
/**
* raw-HTML policy (default
* `'escape'`): show the markup as literal text, drop it (the vnode
* path's default), or pass it through verbatim. **`'raw'` emits author
* content as live markup and is for trusted input only** — a document
* from a user, a fetch or a model must never be rendered with it.
*/
html?: 'escape' | 'skip' | 'raw';
/**
* link/image URL
* filter, replacing the default deny-list; return the URL to emit or
* `null` to drop the attribute. It applies in EVERY `html` mode,
* `'raw'` included: `'raw'` is a statement about HTML blocks, not a
* blanket trust, so a markdown `[x](javascript:…)` is still filtered.
*/
sanitizeUrl?: (url: string) => (string | null);
/**
* plugin set (must match the parse set for
* claimed nodes); a plugin contributes `toHtml(node, ctx)` here the
* way it contributes `render` to the vnode path.
*/
plugins?: any[];
/**
* GitHub-compatible `id` per heading
* (default `false`; see MD-FORMAT.md §4.5 for why it is opt-in).
*/
headingIds?: boolean;
/**
* prepended to every heading id and
* anchor href (default `''`); set it for markdown you did not author.
*/
slugPrefix?: string;
/**
* append a `#` permalink to each
* heading (default `false`). Requires `headingIds`.
*/
headingAnchors?: boolean;
/**
* the accessible name of the
* appended footnotes section (default `'Footnotes'`); a localized page
* sets it, since it is the one string the emitter writes that a reader
* can hear.
*/
footnotesLabel?: string;
/**
* wrapping element, written as it appears in
* the start tag (`'article class="md"'`). Default `null`: bare
* fragment HTML, which is what a consumer concatenating into a
* template wants.
*/
wrap?: string;
};
export type HtmlCtx = {
tables: any;
html: 'escape' | 'skip' | 'raw';
sanitizeUrl: (url: string) => (string | null);
headingIds: boolean;
slugPrefix: string;
headingAnchors: boolean;
slugs: Map;
options: MdHtmlOptions;
footnotes: import('./footnotes.js').Footnotes | null;
footnotePrefix: string;
footnotesLabel: string;
};
/**
* Render an MdDocument (or a CompiledMd, an AST array, a single node)
* to an HTML string.
*
* @example
* toHtml(parseMarkdown('# Hi')); // 'Hi
'
* toHtml(parseMarkdown('x')); // '<b>x</b>'
* toHtml(doc, { html: 'raw' }); // trusted input only
* toHtml(doc, { wrap: 'article class="md"' }); // wrapped
*
* @param {any} docOrAst MdDocument, CompiledMd, MdNode[] or MdNode
* @param {MdHtmlOptions} [options]
* @returns {string}
*/
export declare function toHtml(docOrAst: any, options?: MdHtmlOptions): string;