Magpie HTML - v0.1.3
    Preparing search index...

    Interface HtmlToTextOptions

    Options for HTML to plain text conversion.

    interface HtmlToTextOptions {
        mode?: "fragment" | "document";
        links?: "text" | "inline" | "remove";
        images?: "remove" | "alt";
        collapseWhitespace?: boolean;
        maxNewlines?: number;
        wrap?: number | null;
        tableCellSeparator?: "tab" | "space";
        excludeTags?: string[];
        decodeEntities?: boolean;
        preserveTags?: string[];
        trim?: boolean;
    }
    Index

    Properties

    mode?: "fragment" | "document"

    How to treat the input HTML.

    • "fragment": Treat as HTML fragment (default)
    • "document": Treat as full document (ignores <head> content)

    "fragment"

    links?: "text" | "inline" | "remove"

    How to render anchor (<a>) tags.

    • "text": Show only the link text (default)
    • "inline": Show text followed by URL in parentheses, e.g., "Click here (https://example.com)"
    • "remove": Remove links entirely

    "text"

    images?: "remove" | "alt"

    How to render image (<img>) tags.

    • "alt": Show the alt text (default)
    • "remove": Remove images entirely

    "alt"

    collapseWhitespace?: boolean

    Collapse consecutive whitespace outside preserved tags.

    When true, multiple spaces, tabs, and line breaks are collapsed into single spaces. Whitespace inside preserved tags (e.g., <pre>, <code>) is always kept intact.

    true

    maxNewlines?: number

    Maximum consecutive newlines allowed after compaction.

    Limits runs of newlines to this value. Set to 1 for single spacing, 2 for double spacing (default), or higher values as needed.

    2

    wrap?: number | null

    Optional hard-wrap column width.

    When set to a positive number, lines will be wrapped at this column width. Does not wrap inside preserved tags like <pre> or <code>. Set to null to disable wrapping (default).

    null

    tableCellSeparator?: "tab" | "space"

    Separator between table cells.

    • "tab": Use tab character (default)
    • "space": Use space character

    "tab"

    excludeTags?: string[]

    HTML tags to exclude entirely along with their contents.

    By default excludes: script, style, noscript, template, svg, canvas

    ["script", "style", "noscript", "template", "svg", "canvas"]

    decodeEntities?: boolean

    Decode HTML entities.

    When true, decodes entities like &amp;, &lt;, &#8212;, etc.

    true

    preserveTags?: string[]

    Tags whose internal whitespace is preserved.

    These tags will not have their whitespace collapsed, allowing proper formatting of code blocks and preformatted text.

    ["pre", "code", "textarea"]

    trim?: boolean

    Trim leading and trailing whitespace from the result.

    true