UNPKG

html-textify

Version:
34 lines (32 loc) 1.32 kB
interface TextifyOptions { html: string; preserveFormatting?: boolean; ignoreTags?: string[]; wrapLength?: number; wrapWords?: number; } /** * Converts HTML to plain text with optional formatting and wrapping. * * @param {Object} options - Configuration options. * @param {string} options.html - The input HTML string to convert. * @param {boolean} [options.preserveFormatting=true] - Whether to preserve readable formatting. * @param {string[]} [options.ignoreTags=[]] - List of HTML tags to keep intact. * @param {number} [options.wrapLength] - Maximum characters per line (ignored if wrapWords is set). * @param {number} [options.wrapWords] - Maximum words per line. Takes priority over wrapLength. * @returns {string} The plain text result with optional wrapping. * * @example * textify({ html: "<p>Hello <b>world</b></p>", preserveFormatting: false }); * // => "Hello world" * * @example * textify({ html: "<p>one two three four five</p>", wrapWords: 2 }); * // => "one two\nthree four\nfive" * * @example * textify({ html: "<p>one two three four five</p>", wrapLength: 10 }); * // => "one two\nthree four\nfive" */ declare function textify({ html, preserveFormatting, ignoreTags, wrapLength, wrapWords, }: TextifyOptions): string; export { type TextifyOptions, textify };