/** * Pure parsing and structural helpers for the bilingual-document pairing * gate. Kept separate from the CLI so corpus discovery and signature behavior * can be regression-tested without reading or mutating the repository tree. * Also the one home of the generated-region grammar and the pair-record * primitives, shared by the pairing gate and the region-injecting generators. */ import { createHash } from 'node:crypto' import { basename } from 'node:path' import { fromMarkdown } from 'mdast-util-from-markdown' import { gfmFromMarkdown } from 'mdast-util-gfm' import { gfm } from 'micromark-extension-gfm' import type { Nodes } from 'mdast' /** Complete opening marker line: `` (slug captured). */ const GENERATED_REGION_BEGIN_LINE = /^$/ /** Complete closing marker line: `` (slug captured). */ const GENERATED_REGION_END_LINE = /^$/ /** Loose marker detector: any line that LOOKS like a region marker must parse as one. */ const GENERATED_REGION_MARKER_HINT = /^