diff --git a/src/cli/completions/declare-parser.ts b/src/cli/completions/declare-parser.ts index 711dea2..45e92b0 100644 --- a/src/cli/completions/declare-parser.ts +++ b/src/cli/completions/declare-parser.ts @@ -15,25 +15,7 @@ */ import { parse } from "csv-parse/browser/esm/sync"; - -// --------------------------------------------------------------------------- -// Shared block scanning — used by both CLI (block-processor) and client -// (completions.ts) so there's a single source of truth for declare parsing. -// --------------------------------------------------------------------------- - -/** Matches fenced code blocks with an info string. */ -const FENCED_BLOCK_RE = /^```(\w*)\s+(\S.*?)\s*\n([\s\S]*?)```\s*$/gm; - -/** Parse key="value" and key=value pairs from an attribute string. */ -function parseBlockAttrs(info: string): Record { - const attrs: Record = {}; - const re = /(\w+)\s*=\s*("[^"]*"|\S+)/g; - let m: RegExpExecArray | null; - while ((m = re.exec(info)) !== null) { - attrs[m[1]] = m[2].replace(/^"|"$/g, ""); - } - return attrs; -} +import { FENCED_BLOCK_RE, parseBlockAttrs } from "./block-scanner.js"; /** * Scan markdown content for ```csv role=declare blocks and return