{"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-LLPHSREU.cjs","../src/modes/markdown.ts","../src/engine/markdown-pipeline.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACpBA,sCAA+C;AAC/C,gFAA4B;AAC5B,gEAAoB;AACpB,oEAAsB;AAiBtB,IAAM,oBAAA,kBAA2C,IAAI,GAAA,CAAI;AAAA;AAAA,EAEvD,YAAA;AAAA,EACA,cAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA;AAAA,EAGA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA;AAAA,EAEA,iBAAA;AAAA,EACA,4BAAA;AAAA;AAAA;AAAA;AAAA,EAIA,mBAAA;AAAA,EACA,mBAAA;AAAA,EACA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAM,oBAAA,kBAA2C,IAAI,GAAA,CAAI;AAAA,EACvD,UAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,UAAA,EAAY,EAAA;AAClB,IAAM,aAAA,EAAe,EAAA;AACrB,IAAM,MAAA,EAAQ,EAAA;AACd,IAAM,YAAA,EAAc,EAAA;AACpB,IAAM,SAAA,EAAW,EAAA;AAEjB,SAAS,aAAA,CAAc,IAAA,EAAuB;AAC5C,EAAA,OAAQ,KAAA,GAAQ,GAAA,GAAQ,KAAA,GAAQ,IAAA,GAAU,KAAA,GAAQ,GAAA,GAAQ,KAAA,GAAQ,EAAA;AACpE;AAEA,SAAS,aAAA,CAAc,IAAA,EAAu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Aa,EAAO,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,UAAA,EAAY,YAAY,CAAA;AAC7E;AAYA,SAAS,OAAA,CACP,KAAA,EACA,OAAA,EACA,eAAA,EACU;AACV,EAAA,MAAM,KAAA,EAAO,aAAA,CAAc,KAAA,EAAO,OAAO,CAAA;AACzC,EAAA,GAAA,CAAI,gBAAA,IAAoB,KAAA,CAAA,EAAW,OAAO,CAAC,IAAI,CAAA;AAC/C,EAAA,OAAO,CAAC,gBAAA,CAAiB,KAAA,EAAO,eAAe,CAAA,EAAG,IAAI,CAAA;AACxD;AAKO,SAAS,uBAAA,CAAwB,KAAA,EAAe,OAAA,EAAqC;AAC1F,EAAA,MAAM,aAAA,EAAe,mDAAA,OAAoB,CAAQ,UAAU,CAAA;AAC3D,EAAA,MAAM,QAAA,EAAU,yCAAA,OAAU,CAAQ,KAAK,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,6CAAA,OAAc,CAAQ,MAAM,CAAA;AAC3C,EAAA,MAAM,QAAA,EAAU,cAAA,CAAe,OAAA,CAAQ,OAAO,CAAA;AAC9C,EAAA,MAAM,gBAAA,EAAkB,sDAAA,OAAuB,CAAQ,eAAe,CAAA;AACtE,EAAA,+CAAA,OAAgB,CAAQ,OAAA,EAAS,UAAU,CAAA;AAC3C,EAAA,OAAO,gDAAA;AAAA,IACL,KAAA;AAAA,IACA,OAAA,CAAQ,KAAA,EAAO,OAAA,EAAS,eAAe,CAAA;AAAA,IACvC,OAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;AFiUA;AACA;AACE;AACA;AACF,6GAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-LLPHSREU.cjs","sourcesContent":[null,"import { parse, postprocess, preprocess } from \"micromark\";\nimport { frontmatter } from \"micromark-extension-frontmatter\";\nimport { gfm } from \"micromark-extension-gfm\";\nimport { mdxjs } from \"micromark-extension-mdxjs\";\nimport type { Event, Extension } from \"micromark-util-types\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Dialect } from \"../types.js\";\nimport { htmlFragmentSpans, isSkippedElement } from \"./html.js\";\nimport { yamlSpans } from \"./yaml.js\";\nimport { wrapParserErrors } from \"./parse-error.js\";\nimport { normalizeSpans, type Span } from \"./spans.js\";\n\n/**\n * spec/rules/modes.md 3.7. Each entry is skipped **whole**, including anything that looks\n * processable inside it. The complement is not enumerated: a span is emitted only for a\n * micromark `data` token, which is the tokenizer's own name for \"literal content\", so list\n * markers, emphasis delimiters, heading sequences, table padding, line endings, hard-break\n * spaces, character escapes and character references are outside every span by construction\n * rather than by a second list that could drift from the first.\n */\nconst SKIPPED_TOKEN_TYPES: ReadonlySet<string> = new Set([\n  // fenced code blocks (including the info string and the fences) and indented code blocks\n  \"codeFenced\",\n  \"codeIndented\",\n  // inline code spans, including the backticks\n  \"codeText\",\n  // autolinks `<https://…>`, and GFM's bare-URL form\n  \"autolink\",\n  // link and image destinations and titles; the definition line of a reference link. The link\n  // *text* is a `labelText`, which is not skipped.\n  \"resource\",\n  \"reference\",\n  \"definition\",\n  // GFM footnotes: the call's label and the definition's label are matched against each other\n  \"gfmFootnoteCall\",\n  \"gfmFootnoteDefinitionLabel\",\n  // MDX: expression containers in full, and every JSX attribute — the whole tag is skipped, so\n  // attributes never surface. JSX element *children* sit outside the tag tokens and are\n  // processable.\n  \"mdxFlowExpression\",\n  \"mdxTextExpression\",\n  \"mdxjsEsm\",\n  // modes.md 3.7.3, and it matters: without it the second `---` of a YAML block reads as a setext\n  // underline, `title: Une note` becomes a paragraph, and `fr` puts a narrow no-break space in\n  // front of the colon of a machine-read metadata field. Covered by conformance fixtures\n  // en-us-markdown-{commonmark,mdx}-frontmatter, fr-markdown-{commonmark,mdx}-frontmatter-nbsp,\n  // en-us-markdown-commonmark-frontmatter-toml and -frontmatter-unterminated.\n  //\n  // These are `micromark-extension-frontmatter`'s own token types, one per matter. An earlier\n  // revision listed `\"frontmatter\"`, which the extension never emits: the block was skipped only\n  // because its content arrives as `yamlValue`/`tomlValue` rather than `data`, so the entry that\n  // was supposed to do the work did none.\n  //\n  // Since spec 1.8.0 the skip is 3.7.3a's mask, not this: a located block reaches the parser as\n  // blanks, so the extension cannot see one. The extension stays because it is measured inert —\n  // `tests/modes/frontmatter-keys.test.ts` asserts over every edge document that it never finds\n  // a block the scan denies — and because removing a working locator that costs nothing would be\n  // a change with no problem behind it. What the test would catch is the case that would matter:\n  // the two disagreeing about whether a document has a block at all.\n  \"yaml\",\n  \"toml\",\n]);\n\n/** Token types whose enter/exit also maintains the skipped-element stack. */\nconst RAW_TAG_TOKEN_TYPES: ReadonlySet<string> = new Set([\n  \"htmlText\",\n  \"mdxJsxTextTag\",\n  \"mdxJsxFlowTag\",\n]);\n\nconst LESS_THAN = 0x3c;\nconst GREATER_THAN = 0x3e;\nconst SLASH = 0x2f;\nconst EXCLAMATION = 0x21;\nconst QUESTION = 0x3f;\n\nfunction isAsciiLetter(unit: number): boolean {\n  return (unit >= 0x61 && unit <= 0x7a) || (unit >= 0x41 && unit <= 0x5a);\n}\n\nfunction isTagNameUnit(unit: number): boolean {\n  // Deliberately permissive: anything that is not a delimiter belongs to the name. Custom\n  // elements (`my-callout`) and member expressions (`Foo.Bar`) must come out whole so that they\n  // fail the skip-list membership test rather than being truncated into something that passes.\n  return (\n    unit !== GREATER_THAN &&\n    unit !== SLASH &&\n    unit !== 0x20 &&\n    unit !== 0x09 &&\n    unit !== 0x0a &&\n    unit !== 0x0d\n  );\n}\n\n/** ASCII-only, because HTML tag names are ASCII case-insensitive and `toLowerCase()` is not. */\nfunction asciiLower(value: string): string {\n  let out = \"\";\n  for (let i = 0; i < value.length; i += 1) {\n    const unit = value.charCodeAt(i);\n    out += unit >= 0x41 && unit <= 0x5a ? String.fromCharCode(unit + 0x20) : value[i];\n  }\n  return out;\n}\n\ninterface RawTag {\n  readonly name: string;\n  readonly closing: boolean;\n  readonly selfClosing: boolean;\n}\n\nfunction readTag(tag: string): RawTag | null {\n  if (tag.charCodeAt(0) !== LESS_THAN) return null;\n  let i = 1;\n  const closing = tag.charCodeAt(i) === SLASH;\n  if (closing) i += 1;\n  // Comments, declarations and processing instructions carry no element name.\n  if (tag.charCodeAt(i) === EXCLAMATION || tag.charCodeAt(i) === QUESTION) return null;\n  if (!isAsciiLetter(tag.charCodeAt(i))) return null;\n  const nameAt = i;\n  while (i < tag.length && isTagNameUnit(tag.charCodeAt(i))) i += 1;\n  const selfClosing = tag.charCodeAt(tag.length - 2) === SLASH;\n  return { name: tag.slice(nameAt, i), closing, selfClosing };\n}\n\n/**\n * modes.md 3.7: raw HTML is \"handed to the html skip list of 3.6\". Inline raw HTML reaches the\n * tokenizer as isolated tags with ordinary markdown content between them, so honouring the\n * subtree rule means tracking which skipped element is currently open. JSX names are compared\n * case-sensitively (`<Code>` is a component, `<code>` is an element); HTML names are not.\n */\nfunction updateElementStack(stack: string[], tag: string, caseSensitive: boolean): void {\n  const parsed = readTag(tag);\n  if (parsed === null) return;\n  const name = caseSensitive ? parsed.name : asciiLower(parsed.name);\n  if (parsed.closing) {\n    if (stack[stack.length - 1] === name) stack.pop();\n    return;\n  }\n  if (!parsed.selfClosing && isSkippedElement(name)) stack.push(name);\n}\n\nfunction tokenize(source: string, extensions: readonly Extension[]): Event[] {\n  return postprocess(\n    parse({ extensions: [...extensions] })\n      .document()\n      .write(preprocess()(source, null, true)),\n  );\n}\n\n/**\n * modes.md 3.7.1. The dialect is the caller's, never detected: `\"commonmark\"` is CommonMark 0.31\n * plus GFM, `\"mdx\"` is the same minus indented code blocks and `<…>` autolinks, plus JSX and\n * `{…}` expression containers. Both enable frontmatter and GFM, which 3.7.2 makes normative —\n * §4's promise that table alignment rows survive is empty unless tables are recognised at all.\n */\nexport function resolveDialect(dialect: Dialect | undefined): Dialect {\n  if (dialect === \"commonmark\" || dialect === \"mdx\") return dialect;\n  if (dialect === undefined) {\n    throw new PolytypoError(\n      \"POLYTYPO_INVALID_DIALECT\",\n      'Mode \"markdown\" requires a dialect. Expected \"commonmark\" or \"mdx\"; there is no default.',\n    );\n  }\n  throw new PolytypoError(\n    \"POLYTYPO_INVALID_DIALECT\",\n    `Unknown dialect \"${String(dialect)}\". Expected \"commonmark\" or \"mdx\".`,\n  );\n}\n\n// modes.md 3.7.3 names both frontmatter delimiters, `---` (YAML) and `+++` (TOML), and skips\n// either whole. micromark's default matter is YAML alone, so both must be asked for by name: with\n// the default, a `+++` block parses as prose and the machine-read fields inside it get typeset.\nconst FRONTMATTER_MATTERS = [\"yaml\", \"toml\"] as const;\n\nexport function extensionsFor(dialect: Dialect): Extension[] {\n  const fm = frontmatter([...FRONTMATTER_MATTERS]);\n  return dialect === \"mdx\" ? [fm, gfm(), mdxjs()] : [fm, gfm()];\n}\n\n// modes.md 3.7.3a, spec 1.8.0: where the frontmatter block begins and ends, decided by the scan\n// below and by nothing else. Four runtimes reached the construct through four parsers and got four\n// answers — two of them typeset `date: \"2026-09-26\"` over one trailing space on a fence — so the\n// section makes this scan normative and a parser's opinion a thing measured against it. Locating\n// the block here is also what lets `frontmatterSpans` stop parsing the document a second time\n// (polytypo/polytypo#59).\nconst YAML_DELIMITER = \"---\";\nconst TOML_DELIMITER = \"+++\";\n\nconst TAB = 0x09;\nconst LF = 0x0a;\nconst CR = 0x0d;\nconst SPACE = 0x20;\nconst BOM = 0xfeff;\n\ninterface SourceLine {\n  /** Index just past the line's content: the terminator, or the end of the source. */\n  readonly end: number;\n  /** Index the next line starts at, or the end of the source when this line is the last. */\n  readonly next: number;\n}\n\n/**\n * 3.7.3a step 5: **CommonMark's** line, not 3.8.4's. A line ends at U+000A, at a U+000D that is\n * not followed by U+000A, or at the end of input, and the terminator is never part of the line.\n * The block is a Markdown construct and ends its lines the way the language around it does; the\n * YAML inside it keeps 3.8.4's LF-only model (`./yaml.js`), and the two are different on purpose —\n * harmonising them silently changes one of them.\n */\nfunction markdownLineFrom(source: string, start: number): SourceLine {\n  for (let i = start; i < source.length; i += 1) {\n    const unit = source.charCodeAt(i);\n    if (unit === LF) return { end: i, next: i + 1 };\n    if (unit === CR) return { end: i, next: source.charCodeAt(i + 1) === LF ? i + 2 : i + 1 };\n  }\n  return { end: source.length, next: source.length };\n}\n\n/** 3.7.3a steps 2 and 3: what a delimiter line may carry after the delimiter, and nothing else. */\nfunction isBlankRun(source: string, from: number, to: number): boolean {\n  for (let i = from; i < to; i += 1) {\n    const unit = source.charCodeAt(i);\n    if (unit !== SPACE && unit !== TAB) return false;\n  }\n  return true;\n}\n\n/**\n * A delimiter line: the delimiter at the line's first code point — indentation disqualifies it —\n * then U+0020 and U+0009 to the end of the line. A fourth delimiter character is not whitespace,\n * so `----` is neither an opener nor a closer.\n */\nfunction isDelimiterLine(\n  source: string,\n  start: number,\n  line: SourceLine,\n  delimiter: string,\n): boolean {\n  return (\n    source.startsWith(delimiter, start) && isBlankRun(source, start + delimiter.length, line.end)\n  );\n}\n\n/** modes.md 3.7.3a. The frontmatter block's extent, in source offsets. */\nexport interface FrontmatterBlock {\n  /** Which matter the delimiter names. TOML yields no spans either way (3.7.4). */\n  readonly matter: \"yaml\" | \"toml\";\n  /** First code point of the opening delimiter: 0, or 1 past a single leading U+FEFF (step 1). */\n  readonly start: number;\n  /**\n   * End of the closing delimiter line's content — its trailing whitespace included, its terminator\n   * excluded.\n   */\n  readonly end: number;\n  /** 3.7.4: the code point after the opening delimiter line's terminator. */\n  readonly contentStart: number;\n  /** 3.7.4: the code point that begins the closing delimiter line. */\n  readonly contentEnd: number;\n}\n\n/**\n * modes.md 3.7.3a, the whole of it. Offsets are UTF-16 indices, like every other mode in this\n * runtime; every code point the scan tests is ASCII or U+FEFF, so indexing by code unit and\n * indexing by code point agree on all of them.\n */\nexport function locateFrontmatter(source: string): FrontmatterBlock | null {\n  // Step 1: the document must begin with the delimiter, with a single leading U+FEFF stepped over\n  // first — it is a byte-order mark, not content, and reading it as content would deny the block\n  // to every file some Windows editors produce.\n  const start = source.charCodeAt(0) === BOM ? 1 : 0;\n  const matter = source.startsWith(YAML_DELIMITER, start)\n    ? \"yaml\"\n    : source.startsWith(TOML_DELIMITER, start)\n      ? \"toml\"\n      : null;\n  if (matter === null) return null;\n  const delimiter = matter === \"yaml\" ? YAML_DELIMITER : TOML_DELIMITER;\n\n  // Step 2: the rest of the opening line may be U+0020 and U+0009 and nothing else.\n  const opener = markdownLineFrom(source, start);\n  if (!isBlankRun(source, start + delimiter.length, opener.end)) return null;\n\n  // Step 3: the closing line is the first LATER line of the same delimiter. Step 4: with none,\n  // there is no block, and the opening delimiter is whatever the dialect makes of it.\n  const contentStart = opener.next;\n  for (let at = contentStart; at < source.length;) {\n    const line = markdownLineFrom(source, at);\n    if (isDelimiterLine(source, at, line, delimiter)) {\n      return { matter, start, end: line.end, contentStart, contentEnd: at };\n    }\n    at = line.next;\n  }\n  return null;\n}\n\n/**\n * modes.md 3.7.3a: **the parser is handed the block masked out** — the located block, both\n * delimiter lines included and step 1's leading U+FEFF with them, replaced by U+0020, with line\n * terminators kept as they are. The mark is in that list because without it the first line is not\n * blank: no parser is required to strip it, and a runtime masking the block alone emits a span\n * for it.\n *\n * The invariant is that the masked source stay **positionally aligned with the original in the unit\n * this runtime maps parser offsets back through**, which here is UTF-16 code units: micromark's\n * offsets are handed straight to `Span`, so one U+0020 per code unit is what JS owes. An astral\n * character therefore masks to two spaces, not one. It is deliberately not stated as a count of\n * code points — a runtime that converts offsets against the masked source first owes code-point\n * alignment instead, and both are conformant.\n *\n * Suppressing spans inside the block's range instead is not equivalent, and the runtime that did\n * that is measured in 3.7.3a: a fence inside a metadata value pairs with the body's own, and the\n * body's code block and its prose swap roles — or, with nothing to pair with, swallows the rest of\n * the document. The damage is in what the parser concluded, so no span-level check can see it.\n *\n * Masking is also what keeps 3.7.4's two text units disjoint now that the extent is the scan's and\n * not the parser's: the body cannot emit a span inside a block the parser was never shown.\n */\nfunction maskFrontmatter(source: string, block: FrontmatterBlock | null): string {\n  if (block === null) return source;\n  let masked = \"\";\n  for (let i = 0; i < block.end; i += 1) {\n    const unit = source.charCodeAt(i);\n    masked += unit === LF || unit === CR ? source[i] : \" \";\n  }\n  return masked + source.slice(block.end);\n}\n\n/** modes.md 3.7.3 (spec 1.17.2): the text of a shortcut or collapsed reference is its label. */\nfunction labelRanges(events: readonly Event[], shift: number): Span[] {\n  const ranges: Span[] = [];\n  const open: { hasDest: boolean; labels: Span[] }[] = [];\n  for (const [kind, token] of events) {\n    const type: string = token.type;\n    if (type === \"link\" || type === \"image\") {\n      if (kind === \"enter\") open.push({ hasDest: false, labels: [] });\n      else {\n        const done = open.pop();\n        if (done !== undefined && !done.hasDest) ranges.push(...done.labels);\n      }\n      continue;\n    }\n    const top = open[open.length - 1];\n    if (top === undefined || kind !== \"enter\") continue;\n    if (type === \"resource\" || type === \"referenceString\") top.hasDest = true;\n    if (type === \"labelText\") {\n      top.labels.push({ start: token.start.offset + shift, end: token.end.offset + shift });\n    }\n  }\n  return ranges;\n}\n\nfunction startsUrl(source: string, i: number, end: number): boolean {\n  const lower = (k: number) => {\n    const c = source.charCodeAt(k);\n    return c >= 0x41 && c <= 0x5a ? c + 0x20 : c;\n  };\n  const at = (word: string) => {\n    if (i + word.length > end) return false;\n    for (let k = 0; k < word.length; k += 1) if (lower(i + k) !== word.charCodeAt(k)) return false;\n    return true;\n  };\n  return at(\"www.\") || at(\"http://\") || at(\"https://\");\n}\n\n/**\n * modes.md 3.7.3 (spec 1.17.2): the tail of a bare URL, found by scanning the source rather than\n * asking a parser, because parsers disagree about where a URL may start and where it ends.\n */\nfunction trimUrlTails(\n  source: string,\n  spans: readonly Span[],\n  urlEnds: ReadonlySet<number>,\n): Span[] {\n  const out: Span[] = [];\n  for (const span of spans) {\n    let from = span.start;\n    let i = span.start;\n    let guard =\n      span.urlTail === true ||\n      (urlEnds.has(span.start) &&\n        (source.charCodeAt(span.start) === 0x20 || source.charCodeAt(span.start) === 0x09));\n    while (i < span.end) {\n      if (!(i === span.start && urlEnds.has(i)) && !startsUrl(source, i, span.end)) {\n        i += 1;\n        continue;\n      }\n      let e = i;\n      while (e < span.end) {\n        const c = source.charCodeAt(e);\n        if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d || c === 0x3c) break;\n        e += 1;\n      }\n      if (e === i) {\n        i += 1;\n        continue;\n      }\n      if (i > from)\n        out.push(guard ? { start: from, end: i, urlTail: true } : { start: from, end: i });\n      guard = e < span.end && (source.charCodeAt(e) === 0x20 || source.charCodeAt(e) === 0x09);\n      from = e;\n      i = e;\n    }\n    if (from < span.end)\n      out.push(\n        guard ? { start: from, end: span.end, urlTail: true } : { start: from, end: span.end },\n      );\n  }\n  return out;\n}\n\nfunction removeRanges(spans: readonly Span[], ranges: readonly Span[]): Span[] {\n  if (ranges.length === 0) return [...spans];\n  const out: Span[] = [];\n  for (const span of spans) {\n    let pieces: Span[] = [span];\n    for (const r of ranges) {\n      pieces = pieces.flatMap((q) => {\n        if (r.end <= q.start || r.start >= q.end) return [q];\n        const res: Span[] = [];\n        if (q.start < r.start) res.push({ start: q.start, end: r.start });\n        if (r.end < q.end) res.push({ start: r.end, end: q.end });\n        return res;\n      });\n    }\n    out.push(...pieces);\n  }\n  return out;\n}\n\n/**\n * modes.md 3.7. The body's spans. The document reaches the parser with its frontmatter block\n * masked out (3.7.3a), so the block is skipped because the scan located it, not because an\n * extension recognised it — and `text` below is what the token offsets refer to.\n *\n * Two corrections sit between `text` and the spans this returns:\n *\n * - **`shift`**: micromark's `preprocess` drops a leading U+FEFF and then reports offsets against\n *   the shortened string, so every span in a document carrying one lands a code unit to the left —\n *   which ate the last code point of every span and left\n *   `en-us-markdown-commonmark-byte-order-mark-no-block` unconverted in full. The mark is removed\n *   here instead, and the difference added back. A document whose block was located needs no such\n *   correction, because 3.7.3a masks the mark along with the block;\n * - **the no-span rule** (3.7.3a): no span may lie inside the block whatever the parser made of the\n *   masked text. A span straddling the block's end is **clipped** to the part outside it, and\n *   dropped only when nothing is left, so body prose past the block cannot be lost to a parser's\n *   mistake\n *   about where the block ended. Masking is what makes this inert for micromark — measured over\n *   nineteen block shapes in both dialects, it emits nothing inside a masked block — and the spec\n *   states the rule separately because it is not true of every parser.\n */\nexport function markdownSpans(source: string, dialect: Dialect): Span[] {\n  const block = locateFrontmatter(source);\n  const masked = maskFrontmatter(source, block);\n  const shift = masked.charCodeAt(0) === BOM ? 1 : 0;\n  const text = shift === 0 ? masked : masked.slice(shift);\n  const events = wrapParserErrors(dialect, () => tokenize(text, extensionsFor(dialect)));\n  const spans: Span[] = [];\n  const elementStack: string[] = [];\n  let skipDepth = 0;\n\n  for (const [kind, token] of events) {\n    const type = token.type;\n\n    if (SKIPPED_TOKEN_TYPES.has(type)) {\n      skipDepth += kind === \"enter\" ? 1 : -1;\n      continue;\n    }\n\n    if (RAW_TAG_TOKEN_TYPES.has(type)) {\n      if (kind === \"enter\") {\n        updateElementStack(\n          elementStack,\n          text.slice(token.start.offset, token.end.offset),\n          type !== \"htmlText\",\n        );\n      }\n      skipDepth += kind === \"enter\" ? 1 : -1;\n      continue;\n    }\n\n    // An HTML block is handed to the `html` extractor rather than skipped whole, so that the\n    // prose inside `<div>…</div>` is typeset while the markup is not.\n    if (type === \"htmlFlow\") {\n      if (kind === \"enter\" && skipDepth === 0 && elementStack.length === 0) {\n        for (const span of htmlFragmentSpans(\n          text.slice(token.start.offset, token.end.offset),\n          token.start.offset + shift,\n        )) {\n          spans.push(span);\n        }\n      }\n      skipDepth += kind === \"enter\" ? 1 : -1;\n      continue;\n    }\n\n    if (kind === \"enter\" && type === \"data\" && skipDepth === 0 && elementStack.length === 0) {\n      spans.push({ start: token.start.offset + shift, end: token.end.offset + shift });\n    }\n  }\n\n  const urlEnds = new Set<number>();\n  for (const [kind, token] of events) {\n    if (\n      kind === \"exit\" &&\n      (token.type as string) === \"literalAutolink\" &&\n      startsUrl(source, token.start.offset + shift, token.end.offset + shift)\n    ) {\n      urlEnds.add(token.end.offset + shift);\n    }\n  }\n  const trimmed = trimUrlTails(\n    source,\n    normalizeSpans(removeRanges(spans, labelRanges(events, shift))),\n    urlEnds,\n  );\n  if (block === null) return trimmed;\n  return trimmed.flatMap((span) => {\n    if (span.start >= block.end) return [span];\n    if (span.end <= block.end) return [];\n    return [{ start: block.end, end: span.end }];\n  });\n}\n\n/**\n * modes.md 3.7.4: **a content line containing a U+000D not followed by U+000A yields no spans**,\n * \"exactly as 3.8.4 step 1 already declines a line containing U+0009\". The two line models meet in\n * the block content and do not compose — 3.7.3a step 5 finds a block in a lone-U+000D document, and\n * 3.8.4's LF-only scan then reads the whole of it as one line. Measured, letting it through is not\n * merely inert: marks pair across what were two mapping lines, an unlisted line inside the listed\n * key's scalar takes `fr`'s spacing, and the U+000D itself lands inside a span — which 3.8.4\n * forbids.\n *\n * The decline **drops the spans the content scan produced for that line and does not alter the\n * content the scan is given**. Substituting each lone U+000D for a character 3.8.4 already\n * declines is the shortcut three ports reached for, this one included, and it is measured not\n * equivalent: the substitution moves the character onto a line of its own and can end a value run.\n * Both shapes are pinned as fixtures, and both are decided by what `yaml` mode does with the same\n * characters, since 3.7.4 claims 3.8's scan applies verbatim:\n *\n * - `title: a \"b\"\\nslug: c \"d\"\\n\\r` — the content-final U+000D is a blank line joining `slug`'s\n *   value run, so 3.8.6's continuation bail declines `slug`. As a U+0009 it is a line with a tab\n *   in it, not a blank one, the run ends and `slug` converts. `yaml` mode converts `title` only,\n *   in both shipped runtimes measured;\n * - `summary: a\\rb\\n  title: c -- d\\n` — the indented line is inside `summary`'s value run, so\n *   `title` is not a key at all. Substitution ends the run and invents one.\n *\n * **The window runs to the start of the next line, not to the end of this one**, because 3.8.4's\n * own splitter treats a trailing U+000D as a terminator without a U+000A after it — so a block\n * whose single line ends in one looks clean if the terminator is excluded.\n */\nfunction declinedContentRanges(content: string): readonly Span[] {\n  const declined: Span[] = [];\n  let start = 0;\n  while (start < content.length) {\n    const lf = content.indexOf(\"\\n\", start);\n    const next = lf === -1 ? content.length : lf + 1;\n    for (let i = start; i < next; i += 1) {\n      if (content.charCodeAt(i) === CR && content.charCodeAt(i + 1) !== LF) {\n        declined.push({ start, end: next });\n        break;\n      }\n    }\n    start = next;\n  }\n  return declined;\n}\n\n/**\n * modes.md 3.7.4, spec 1.7.0. The frontmatter block's own spans, which form a **second text\n * unit**: the pipeline runs over them separately from the body's, so an unbalanced mark in a\n * metadata field can never pair with one in the first paragraph and this option cannot change a\n * byte outside the block.\n *\n * The block is located by `locateFrontmatter` (3.7.3a, spec 1.8.0) rather than by a second parse\n * of the document, which is both what polytypo/polytypo#59 reported and, since 1.8.0, the wrong\n * authority: the scan owns the extent and a parser is measured against it.\n *\n * Spans inside it are taken by the scan of modes.md 3.8 — frontmatter *is* YAML, and specifying it\n * twice is how two implementations of one grammar drift — with `frontmatterKeys` as step 8's key\n * predicate.\n *\n * A TOML block yields nothing, with the option or without it: TOML's quoting is a second grammar\n * this scan does not claim (modes.md §7.13). So does any content line carrying a lone U+000D — see\n * `declinedContentRanges`, which filters what the scan produced rather than changing what it reads.\n */\nexport function frontmatterSpans(source: string, frontmatterKeys: readonly string[]): Span[] {\n  if (frontmatterKeys.length === 0) return [];\n  const block = locateFrontmatter(source);\n  if (block === null || block.matter === \"toml\") return [];\n\n  const { contentStart, contentEnd } = block;\n  const content = source.slice(contentStart, contentEnd);\n  const declined = declinedContentRanges(content);\n\n  return (\n    yamlSpans(content, frontmatterKeys)\n      // 3.7.4: a span reaching a declined position is dropped whole rather than trimmed.\n      .filter((span) => !declined.some((range) => span.start < range.end && range.start < span.end))\n      .map((span) => ({ start: span.start + contentStart, end: span.end + contentStart }))\n  );\n}\n","import { frontmatterSpans, markdownSpans, resolveDialect } from \"../modes/markdown.js\";\nimport type { Dialect, Options } from \"../types.js\";\nimport { getLocaleData } from \"./locale.js\";\nimport { resolveNarrowTarget } from \"./narrow-target.js\";\nimport { assertNoProtect } from \"./protect.js\";\nimport { planRules } from \"./rule-runner.js\";\nimport { resolveFrontmatterKeys } from \"./yaml-keys.js\";\nimport { analyzeOverUnits, runOverUnits } from \"./span-runner.js\";\nimport type { Change } from \"./origin.js\";\nimport type { Span } from \"../modes/spans.js\";\n\n/**\n * `markdown` mode only. Imports the Micromark/MDX stack and `parse5` (via `../modes/markdown.js`\n * importing `../modes/html.js` for normative embedded-HTML handling, modes.md 3.7) — both are\n * legitimately reachable from `polytypo/markdown` (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1).\n *\n * Validation order — `planRules`, then `getLocaleData`, then `resolveDialect`/parsing — mirrors\n * the pre-Stage-5 aggregate `runPipeline` exactly: an unknown-rule error wins over an\n * unknown-locale error, which wins over a missing/invalid dialect, which wins over a parse\n * failure. All four are public, tested behaviour this refactor was not authorised to change.\n */\nexport function runMarkdownPipeline(input: string, options: Partial<Options>): string {\n  const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n  const planned = planRules(options.rules);\n  const locale = getLocaleData(options.locale);\n  const dialect = resolveDialect(options.dialect);\n  const frontmatterKeys = resolveFrontmatterKeys(options.frontmatterKeys);\n  assertNoProtect(options.protect, \"markdown\");\n  const units = unitsOf(input, dialect, frontmatterKeys);\n  return runOverUnits(input, units, planned, locale, \"markdown\", narrowTarget);\n}\n\n/**\n * modes.md 3.7.4: the body, and — only when the caller named frontmatter keys — the frontmatter\n * block as a second text unit. Without the option this is exactly the single unit every document\n * had before spec 1.7.0, which is why no released output can move.\n *\n * The two units must be **disjoint** — 3.7.4: \"no source position can belong to both units\". Since\n * spec 1.8.0 that is 3.7.3a's masking rule doing the work rather than a shared parser: the body is\n * read from a document whose block is blanked out, so it cannot emit a span the frontmatter unit\n * also claims, whatever the parser would have made of the block's characters.\n */\nfunction unitsOf(\n  input: string,\n  dialect: Dialect,\n  frontmatterKeys: readonly string[] | undefined,\n): Span[][] {\n  const body = markdownSpans(input, dialect);\n  if (frontmatterKeys === undefined) return [body];\n  return [frontmatterSpans(input, frontmatterKeys), body];\n}\n\n/** analyze.md §1, `markdown` mode. Dialect validation happens here exactly as it does for\n * `runMarkdownPipeline`, so an absent dialect throws POLYTYPO_INVALID_DIALECT from `analyze`\n * too (analyze.md §4 A1). */\nexport function analyzeMarkdownPipeline(input: string, options: Partial<Options>): Change[] {\n  const narrowTarget = resolveNarrowTarget(options.narrowNbsp);\n  const planned = planRules(options.rules);\n  const locale = getLocaleData(options.locale);\n  const dialect = resolveDialect(options.dialect);\n  const frontmatterKeys = resolveFrontmatterKeys(options.frontmatterKeys);\n  assertNoProtect(options.protect, \"markdown\");\n  return analyzeOverUnits(\n    input,\n    unitsOf(input, dialect, frontmatterKeys),\n    planned,\n    locale,\n    \"markdown\",\n    narrowTarget,\n  );\n}\n"]}