docx
    Preparing search index...

    Type Alias HtmlOptions

    Options for turning HTML into a document's content.

    type HtmlOptions = {
        baseUrl?: string;
        images?:
            | Readonly<Record<string, HtmlImage>>
            | ((source: string) => HtmlImage | undefined);
        maxImageWidth?: number;
        notes?: "footnotes" | "endnotes";
        onWarning?: (warning: HtmlWarning) => void;
        styleMap?: Readonly<Record<string, string>>;
        stylesheet?: string;
        trackChanges?: { author: string; date?: string };
    }
    Index
    baseUrl?: string

    The address that relative links and image addresses are relative to, such as https://example.com/blog/

    images?:
        | Readonly<Record<string, HtmlImage>>
        | ((source: string) => HtmlImage | undefined)

    The images that <img src> refers to by addresses other than data URLs, as docx/html doesn't download anything: an object of each address and its image, or a function that gives the image for an address, or undefined when it has none. An address is looked for as it is written, and then resolved against baseUrl.

    maxImageWidth?: number

    The widest an image can be, in pixels, so it fits on the page: 601 by default, the width of the text on the page of a document with docx's default page size and margins. Wider images are scaled down.

    notes?: "footnotes" | "endnotes"

    What the HTML's notes are in Word, such as the footnotes of Markdown, Pandoc and Google Docs: "footnotes", at the foot of the page each is referred to on, by default, or "endnotes", at the end of the document, as a web page has them. Word's own HTML says which of its notes are footnotes and which are endnotes, which they stay.

    onWarning?: (warning: HtmlWarning) => void

    Called with each thing in the HTML that the document leaves out or has differently

    styleMap?: Readonly<Record<string, string>>

    The Word styles to give the elements that CSS selectors match, by the styles' ids, such as { "p.lead": "Lead", "blockquote": "Quote", "code": "InlineCode", "table": "GridTable4" }. A block is given a paragraph style, an inline element a character style, and a table a table style. When selectors that match an element give it different styles, the most specific selector's is used, as in CSS. The styles must be in the document, such as in its styles option or the template it patches.

    stylesheet?: string

    CSS for the HTML, as if it were in a <style> element after the HTML's own, such as the style sheet of the editor it comes from. Rules in @media print blocks are used, and those in other @media blocks aren't.

    trackChanges?: { author: string; date?: string }

    Turns <ins> and <del>, such as an HTML diff's, into Word's tracked changes, by this author, and at the time of their datetime attribute, or this time, or now: an ISO 8601 date and time such as 2026-10-13T09:30:00Z. Without it, they are underlined and struck through, as a browser shows them.