/** * @fileoverview Markdown escaping for upstream text interpolated into `content[]`. GDELT titles, * labels, snippets, and station metadata are third-party text; rendered raw they parse as * markup — a nested `[x](y)` breaks a link, `*…*` turns into emphasis, `` renders as HTML, a * newline opens a new list item. Escaping applies to `content[]` only; `structuredContent` keeps * the raw value, and nothing is decoded or stripped. * @module mcp-server/tools/markdown-escape */ /** * Where a value sits in its rendered line, which decides the block-level markup it can open. * Inline markup is escaped in every slot. */ export type MarkdownSlot = /** Anywhere inside a line: after a label, inside a bold span, as a link label, mid-heading. */ 'inline' /** The end of an ATX heading, where a trailing `#` run reads as the closing sequence. */ | 'heading-end' /** The first text of a list item, where a leading marker opens a nested block. */ | 'line-start'; /** * Escape `value` so CommonMark/GFM renders it as literal text in `slot`. * * One linear pass, escaping only where markup would parse: `\`, `` ` ``, `*`, `[`, `]`, `~` * always; `_` only at a word boundary (an intraword run cannot open emphasis); `<` only before * a character that can open a tag or autolink; `&` only before a complete entity reference. * Line breaks become a space, so a value can never open a new block. `.`, `-`, `(`, `)`, and * mid-text `#` pass through, so a value with no markup characters renders byte-identical. * Every lookahead is bounded, so the cost stays linear in the value's length. */ export declare function escapeMarkdown(value: string, slot?: MarkdownSlot): string; /** * A URL rendered as its own text, never backslash-escaped. A plain URL passes through * byte-identical. One carrying a character CommonMark would read as markup — a boundary `_`, * `*`, `~`, a bracket, a backtick, a backslash, an entity — renders as an autolink * (``), whose content no renderer parses as emphasis, with or without GFM's own * linking of bare URLs. A space, `<`, `>`, and ASCII controls (line breaks included) cannot * sit in an autolink and no valid URL carries them raw, so they are percent-encoded first. * A value with no scheme cannot be an autolink; it is escaped as text instead. */ export declare function markdownUrl(url: string): string; /** * A URL as a `[label](destination)` destination that parses as exactly one destination and * resolves to exactly this URL: the angle-bracket form when it carries a space or a parenthesis, * the bare form otherwise, so a plain URL renders byte-identical. CommonMark decodes backslash * escapes and entity references inside a destination, so a `\` and an entity-forming `&` are * backslash-escaped there — the one place that yields the literal character. Percent-encoding * them would change the URL itself (`%26` is not a query separator; browsers read `\` as `/`). */ export declare function markdownLinkDestination(url: string): string; //# sourceMappingURL=markdown-escape.d.ts.map