/** * Discord Markdown elements {@link strip} and {@link toHTML} can act on. * All are removed/rendered by default; shared across the package so element * names stay consistent between the plain-text stripper and the HTML * renderer. */ type MarkdownElement = "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "code" | "codeBlock" | "blockQuote" | "header" | "subtext" | "list" | "link" | "embedLink" | "silent"; /** * Options for {@link strip}. */ interface StripOptions { /** * Elements to leave untouched instead of removing. Default: `[]` (every * element is removed). */ disable?: MarkdownElement[]; } /** * Strip Discord Markdown formatting from text, leaving plain text behind. * * Built on {@link parse}: covers the syntax described in Discord's Markdown * 101 article (bold, italic, underline, strikethrough, spoilers, code/code * blocks, block quotes, headers, subtext, lists, masked links) plus * suppressed embed links (``) and a leading `@silent` * marker. * * Mentions (`<@id>`, `<@!id>`, `<@&id>`, `<@$id>`, `<#id>`, ``), * custom emoji (`<:name:id>`, ``) and timestamps * (``) are left untouched, since their raw IDs carry no * displayable information on their own. * * Every element in {@link MarkdownElement} is removed by default; pass its * name in `options.disable` to leave it untouched instead. */ declare function strip(text: string, options?: StripOptions): string; /** * Options for {@link toHTML}. */ interface ToHTMLOptions { /** * Elements to leave as literal (HTML-escaped) text instead of rendering. * Default: `[]` (every element is rendered). */ disable?: MarkdownElement[]; } /** * Render Discord Markdown to an HTML string. * * Built on {@link parse}: all text is HTML-escaped per-segment (via * `escape-html`), so the result is safe to insert into a page as-is; only * the tags this function generates itself are ever emitted as raw markup. * Masked links and suppressed embed links are only turned into `` tags * when their URL is `http(s)`; anything else is left as literal escaped * text. * * Covers the same syntax as {@link strip} (bold, italic, underline, * strikethrough, spoilers, code/code blocks, block quotes, headers, * subtext, lists, masked links, suppressed embed links, `@silent`), mapped * to ``, ``, ``, ``, ``, ``, * `
`, `
`, `

`-`

`, ``, * `