/** * @fileoverview `mdText` — the escape a deposited string passes through on its way into the * Markdown that every tool's `format()` builds, so that a character the deposit carried * reaches a `content[]` reader as itself rather than as markup. * * `structuredContent` and `content[]` are two surfaces over the same values, and a reader of * the second must not lose what a reader of the first keeps. Normalization already decides * which brackets are markup and which are content; the ones it keeps are kept because deleting * them would cost the reader an address, a Miller index, a DOI fragment, or a phrase somebody * typed. Interpolated raw into a Markdown line, several of those are read a second time — this * time by the client's renderer, which consumes an unknown element as its children alone and * resolves a character reference the single-pass decode deliberately left as text. What the * strip protected, the render then deletes. * * The escape belongs here rather than in normalization because normalization decides what the * value *is* and `format()` decides how it is *shown*. A backslash written into the value * itself would reach `structuredContent`, whose contract is the deposited text; written here it * reaches only the surface that needs it, and the two surfaces then agree on every character. * * Two entry points, because one class of construct depends on where the value is placed rather * than on what it contains: `mdText` for a value rendered inside a line, `mdTextAtLineStart` for * one rendered at column zero, where a leading `#`, `>`, `-`, or `19.` opens a block and the * renderer eats the marker. * @module mcp-server/tools/markdown-text */ /** * Escape a deposited string for the Markdown surface `format()` writes. * * Applies to the values the normalization passes produced — the human-readable free text. * Identifiers and machine-format values (DOIs, URLs, ISSNs, prefixes, ORCIDs, reference keys) * are projected byte-exact and are interpolated the same way, because they are what a reader * copies: a backslash inside a URL breaks the copy and the autolink both, which is a worse * outcome than the stray emphasis it would prevent. That is the same line normalization already * draws between the two kinds of value. * * Block constructs are not escaped here, and what decides that is the call site rather than the * value. `#`, `>`, `-`, `+`, and a number followed by a dot open a block only at column zero, and * almost every value this server renders sits behind a `## `, a `- `, or a `**Label:** `, where * the same characters are inert. Escaping them unconditionally would put a backslash in front of * the leading hyphen of every title that starts with one and protect nothing: 1,201 of 328,920 * sampled values open on one of these characters and nearly all of them are rendered mid-line. * A value that is the first thing on its line goes through `mdTextAtLineStart` instead. */ export declare function mdText(value: string): string; /** * Escape a deposited string for a Markdown line it *begins*, rather than one it sits inside. * * A marker at column zero is not merely presented differently — the renderer consumes it, so an * abstract deposited as `19. yüzyılın ikinci yarısından` reaches the reader as a list item * numbered 19 with the century it names gone, and one opening `- ` loses the hyphen and space * the publisher wrote. Whether that can happen is a property of the line, not of the value, * which is why this is a second entry point rather than a widening of `mdText`. * * The escape lands on the last character of the marker: the marker itself where it is one * character, the `.` or `)` of an ordered-list marker otherwise. Escaping the digits instead * would show a backslash, since `\1` is not an escape a reader resolves. The inline pass runs * first — reversed, it would escape the backslash this one just wrote. */ export declare function mdTextAtLineStart(value: string): string; //# sourceMappingURL=markdown-text.d.ts.map