open-agreements
Version:
Open-source legal template filling CLI and library
37 lines • 1.97 kB
TypeScript
import type { DocumentViewNode } from './document_view.js';
import type { Footnote } from './footnotes.js';
/**
* Tracks which footnote numbers were actually rendered as markers in the body, and how many
* times each appeared. Used to (a) give repeated markers unique element ids and (b) emit a
* back-link from a definition only when its marker was really rendered (no dangling `#fnref-n`).
*/
type FootnoteRefs = Map<number, number>;
export declare function isSafeHref(href: string): boolean;
/**
* Convert one TOON inline-tag string (a `DocumentViewNode.tagged_text` value) to inline HTML.
* This is the HTML parallel of `inlineTagsToMarkdown` and the reusable core of the serializer.
*
* Tag mapping:
* - `<b>`/`<i>`/`<u>`/`<a href="...">` → passed through verbatim (already valid, attribute-escaped HTML)
* - `<highlight>` → `<mark>`
* - `<font color=… size=… face=…>` → `<span style="…">` (values sanitized)
*
* Literal text spans are HTML-escaped; injected `[^n]` footnote markers become `<sup>` anchors.
*/
export declare function inlineTagsToHtml(text: string, refs?: FootnoteRefs): string;
export interface SerializeHtmlOptions {
/** Emit only the body-level elements (no `<!DOCTYPE>`/`<head>`/`<body>` wrapper). */
readonly fragment?: boolean;
/** Override the `<title>` (full-document mode only). Defaults to the first heading's text. */
readonly title?: string;
}
/**
* Serialize a structured document view to semantic HTML.
*
* @param nodes Block nodes from `buildDocumentView({ showFormatting: true }).nodes`.
* @param footnotes Footnotes from `DocxDocument.getFootnotes()` (already sorted by
* `displayNumber`); rendered as a footnotes `<section>` with back-links.
*/
export declare function serializeToHtml(nodes: DocumentViewNode[], footnotes?: Footnote[], opts?: SerializeHtmlOptions): string;
export {};
//# sourceMappingURL=serialize_html.d.ts.map