UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

25 lines (24 loc) • 1.05 kB
import { n as postprocess, r as parse, t as preprocess } from "./preprocess-CrIuhpzj.mjs"; import { t as gfmTable } from "./syntax-QOMXoaW7.mjs"; //#region packages/markdown-core/src/markdown-code-regions.ts /** Read exact original UTF-16 code ranges without building a Markdown tree. */ function findMarkdownCodeRegions(e) { if (!/[`~\t]| {4}/u.test(e)) return []; const t = postprocess(parse({ extensions: [{ disable: { null: ["htmlFlow", "htmlText"] } }, gfmTable()] }).document().write(preprocess()(e, void 0, true))); const n = []; let r = 0; for (const [e, i] of t) { if (i.type === "image") r += e === "enter" ? 1 : -1; if (e === "enter" && r === 0 && (i.type === "codeText" || i.type === "codeFenced" || i.type === "codeIndented")) n.push({ start: i.start.offset, end: i.end.offset, block: i.type !== "codeText" }); } return n; } function findMarkdownCodeSpans(e) { return findMarkdownCodeRegions(e).map(({ start: e, end: t }) => [e, t]); } //#endregion export { findMarkdownCodeSpans as n, findMarkdownCodeRegions as t };