/** * CommonMark-compliant code-block detection for markdown. * * Returns a Set of 0-indexed line numbers that are inside any code block — * fenced (` ``` ... ``` ` / `~~~ ... ~~~`) or indented (4-space prefix). The * fence boundary lines themselves are also included. * * Per the CommonMark spec, a fenced code block: * - Opens with at least 3 backticks or tildes, optionally followed by an * "info string" (e.g. ` ```js `). * - Closes only with the SAME fence character, AT LEAST as many of them * as the opener, and an EMPTY info string (just the run of backticks * or tildes plus optional trailing whitespace). * - Anything else inside the block — including ` ```js ` lines — is * content, not a fence boundary. * * The naive tracker that toggles on every `^`{3,}|~{3,}` confuses * `` ```js `` with a close and corrupts state for the rest of the file. * Use this helper instead. * * Indented code blocks: a line is treated as inside an indented code block * when it has 4+ leading spaces and the previous non-blank line is also * indented (or blank with another indented line above it). Lines inside a * fenced block don't double-count as indented. */ export declare function getCodeBlockLines(lines: string[]): Set; /** * Like `getCodeBlockLines` but returns whether a single line index is * inside ANY kind of code block — handy for one-shot checks where you * don't already have the set computed. */ export declare function isInsideCodeBlock(lines: string[], targetIdx: number): boolean; /** * Apply `transform` to the parts of `line` that are OUTSIDE inline code * spans, leaving code-span text (and its backticks) verbatim. Lets * emphasis/style fixers rewrite prose without corrupting literal markers * such as `reverse_proxy` inside `` `caddy reverse_proxy` ``. */ export declare function replaceOutsideInlineCode(line: string, transform: (segment: string) => string): string; /** * Blank out inline code spans (replacing every character — backticks and * content — with spaces) while preserving length and column positions. Used * by detectors that want to scan prose for markers without matching anything * inside a code span. */ export declare function maskInlineCode(line: string): string; /** * Mask inline code across a whole document, including spans that wrap a line. * * `maskInlineCode` works one line at a time, which is right for a fixer that * rewrites a line in place and wrong for a detector. A code span may legally * span a line break inside a paragraph: * * ```md * `REVIEWOS_GPG_TESTS=1 bun * test tests/e2e/git-signature.test.ts` is 8 passing * ``` * * Per line, neither half has a balanced pair of backticks, so nothing is masked * and the underscores in `REVIEWOS_GPG_TESTS` read as emphasis - which is * exactly the false positive this exists to stop. Prose wrapped at eighty * columns produces this constantly, and it is invisible to anybody reading the * source because it renders correctly. * * A span is only carried across the break while a paragraph continues: a blank * line ends it, because an unterminated backtick is far more common than a * multi-line span, and carrying it to the end of the file would mask the whole * document on one stray tick. */ export declare function maskInlineCodeAcrossLines(lines: string[]): string[];