@hawkeyexl/manni 4.4.1 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/batch-OZOACN4G.js +41 -0
- package/dist/build-Z5VOVADH.js +32 -0
- package/dist/calibrate-TZYT42DR.js +36 -0
- package/dist/capture-SL4MNDDP.js +34 -0
- package/dist/check-5OMA42Y6.js +26 -0
- package/dist/{check-HYNGXYJV.js → check-OAJWC3WD.js} +7 -5
- package/dist/{check-ASPIHA6B.js → check-PKY7KTQE.js} +13 -14
- package/dist/check-WB2QDHJQ.js +880 -0
- package/dist/check-WB2QDHJQ.js.map +1 -0
- package/dist/{chunk-MWJLZMBL.js → chunk-2JFPBZJK.js} +11 -11
- package/dist/{chunk-QQUKGCAJ.js → chunk-2KRB3EG7.js} +2 -2
- package/dist/{chunk-DXNZS72W.js → chunk-2M6DVNI5.js} +10 -6
- package/dist/{chunk-DXNZS72W.js.map → chunk-2M6DVNI5.js.map} +1 -1
- package/dist/{chunk-QZ6LRSNV.js → chunk-3NWX34ZI.js} +19 -19
- package/dist/{chunk-IDV6HJCB.js → chunk-5G53XATW.js} +4 -4
- package/dist/{chunk-M2JCK5F6.js → chunk-6KKZXB2O.js} +19 -6
- package/dist/chunk-6KKZXB2O.js.map +1 -0
- package/dist/{chunk-PNPQTHBT.js → chunk-733Y2STG.js} +2 -2
- package/dist/{chunk-WB3QM6PP.js → chunk-73TC4DYH.js} +332 -2522
- package/dist/chunk-73TC4DYH.js.map +1 -0
- package/dist/{chunk-EPH54CAY.js → chunk-7WRP5FFP.js} +4 -4
- package/dist/{chunk-NXV7WE2D.js → chunk-APKH2T6E.js} +29 -591
- package/dist/chunk-APKH2T6E.js.map +1 -0
- package/dist/{chunk-I2AH3CJJ.js → chunk-B3TS4WRM.js} +17 -15
- package/dist/{chunk-I2AH3CJJ.js.map → chunk-B3TS4WRM.js.map} +1 -1
- package/dist/chunk-BWCWTHYS.js +146 -0
- package/dist/chunk-BWCWTHYS.js.map +1 -0
- package/dist/{chunk-MMTSSTG7.js → chunk-C3B2VJNC.js} +2 -2
- package/dist/{chunk-PU6DFJMY.js → chunk-C73RSUIC.js} +4 -4
- package/dist/chunk-CU57HT2E.js +116 -0
- package/dist/chunk-CU57HT2E.js.map +1 -0
- package/dist/chunk-CWXZ2MRT.js +222 -0
- package/dist/chunk-CWXZ2MRT.js.map +1 -0
- package/dist/{chunk-GCQRPUSB.js → chunk-DC5DDJVE.js} +6 -6
- package/dist/{chunk-6OYEI2VV.js → chunk-ECVQNGTH.js} +3 -3
- package/dist/chunk-FLAO4ZS3.js +502 -0
- package/dist/chunk-FLAO4ZS3.js.map +1 -0
- package/dist/chunk-FQGLRJGX.js +174 -0
- package/dist/chunk-FQGLRJGX.js.map +1 -0
- package/dist/{chunk-7UKO3ASZ.js → chunk-GAJIJKET.js} +3 -3
- package/dist/{chunk-6JSSEWBG.js → chunk-GREQKO6M.js} +202 -54
- package/dist/chunk-GREQKO6M.js.map +1 -0
- package/dist/chunk-HX44GB4Z.js +30 -0
- package/dist/chunk-HX44GB4Z.js.map +1 -0
- package/dist/{chunk-4IUC2MNL.js → chunk-IY7NYNPZ.js} +9 -11
- package/dist/{chunk-4IUC2MNL.js.map → chunk-IY7NYNPZ.js.map} +1 -1
- package/dist/{chunk-57NEQRVO.js → chunk-KCOFEWV5.js} +8 -6
- package/dist/{chunk-57NEQRVO.js.map → chunk-KCOFEWV5.js.map} +1 -1
- package/dist/chunk-M2RLHZ4J.js +849 -0
- package/dist/chunk-M2RLHZ4J.js.map +1 -0
- package/dist/{chunk-NLXTXE5Y.js → chunk-M6GSS72T.js} +185 -33
- package/dist/chunk-M6GSS72T.js.map +1 -0
- package/dist/{chunk-YTURO7SI.js → chunk-MHM4QEBV.js} +4 -4
- package/dist/{chunk-RL5XWQOL.js → chunk-MOWMCEOJ.js} +143 -54
- package/dist/chunk-MOWMCEOJ.js.map +1 -0
- package/dist/{chunk-C4SQM22E.js → chunk-MWBJ3KTF.js} +13 -11
- package/dist/chunk-MWBJ3KTF.js.map +1 -0
- package/dist/chunk-N7JSEDSC.js +233 -0
- package/dist/chunk-N7JSEDSC.js.map +1 -0
- package/dist/{chunk-JCDXE76J.js → chunk-NBMPHD4I.js} +2 -2
- package/dist/{chunk-37LP5HMZ.js → chunk-NHHOPZRA.js} +12 -10
- package/dist/{chunk-37LP5HMZ.js.map → chunk-NHHOPZRA.js.map} +1 -1
- package/dist/{chunk-YB4IBW3M.js → chunk-NTWW7J76.js} +2 -2
- package/dist/{chunk-UJCVAWP7.js → chunk-PCFG7E6B.js} +3 -3
- package/dist/{chunk-UJCVAWP7.js.map → chunk-PCFG7E6B.js.map} +1 -1
- package/dist/{chunk-FBEQCK47.js → chunk-PL4UAF4S.js} +73 -1304
- package/dist/chunk-PL4UAF4S.js.map +1 -0
- package/dist/chunk-QCHVR4ZM.js +286 -0
- package/dist/chunk-QCHVR4ZM.js.map +1 -0
- package/dist/{chunk-PIKOVN6W.js → chunk-QW77LCOU.js} +10 -10
- package/dist/{chunk-2B7ZNTPV.js → chunk-SM6NOMJS.js} +2 -2
- package/dist/chunk-SWSTHZBI.js +2464 -0
- package/dist/chunk-SWSTHZBI.js.map +1 -0
- package/dist/{chunk-JXLTXMJ7.js → chunk-T6SYGLWR.js} +3 -3
- package/dist/{chunk-CK7SKVHR.js → chunk-TBAMBLF3.js} +3 -12
- package/dist/chunk-TBAMBLF3.js.map +1 -0
- package/dist/chunk-TH4JVQPF.js +133 -0
- package/dist/chunk-TH4JVQPF.js.map +1 -0
- package/dist/{chunk-QRWGPQKO.js → chunk-TLXE7LYK.js} +4 -4
- package/dist/{chunk-M3W7J6MU.js → chunk-TUAAR3MM.js} +3280 -283
- package/dist/chunk-TUAAR3MM.js.map +1 -0
- package/dist/{chunk-SKSDRUUK.js → chunk-UAKNZVCD.js} +4 -4
- package/dist/{chunk-YJOGUXGP.js → chunk-UJSGS2Y5.js} +8 -6
- package/dist/{chunk-YJOGUXGP.js.map → chunk-UJSGS2Y5.js.map} +1 -1
- package/dist/{chunk-UQISLDAV.js → chunk-UWQ2UVHE.js} +8 -6
- package/dist/{chunk-UQISLDAV.js.map → chunk-UWQ2UVHE.js.map} +1 -1
- package/dist/chunk-WQWKYAAK.js +86 -0
- package/dist/chunk-WQWKYAAK.js.map +1 -0
- package/dist/{chunk-LJ2RDH3F.js → chunk-XG6PVB5S.js} +1 -23
- package/dist/chunk-XG6PVB5S.js.map +1 -0
- package/dist/{chunk-Q35YIDBV.js → chunk-XKBEHKWO.js} +29 -264
- package/dist/chunk-XKBEHKWO.js.map +1 -0
- package/dist/chunk-XPEWUK7J.js +532 -0
- package/dist/chunk-XPEWUK7J.js.map +1 -0
- package/dist/{chunk-MYMBCTDE.js → chunk-XXDXIIQ4.js} +2 -2
- package/dist/chunk-YGFIQ6Y5.js +17 -0
- package/dist/chunk-YGFIQ6Y5.js.map +1 -0
- package/dist/chunk-YLK2J5YK.js +610 -0
- package/dist/chunk-YLK2J5YK.js.map +1 -0
- package/dist/{chunk-3VK37OR2.js → chunk-Z4IZGEM3.js} +16 -12
- package/dist/{chunk-3VK37OR2.js.map → chunk-Z4IZGEM3.js.map} +1 -1
- package/dist/{cli-6HIDIFVT.js → cli-6EWVMEN6.js} +5 -3
- package/dist/{cli-6HIDIFVT.js.map → cli-6EWVMEN6.js.map} +1 -1
- package/dist/{cli-VI7VHWNZ.js → cli-6H7HVDMQ.js} +113 -20
- package/dist/{cli-VI7VHWNZ.js.map → cli-6H7HVDMQ.js.map} +1 -1
- package/dist/{cli-RPM5PELX.js → cli-EPVZHAZS.js} +24 -20
- package/dist/cli-EPVZHAZS.js.map +1 -0
- package/dist/{cli-MN7PYMBI.js → cli-LUCSGTVI.js} +17 -19
- package/dist/{cli-MN7PYMBI.js.map → cli-LUCSGTVI.js.map} +1 -1
- package/dist/{cli-LFP5ZGYS.js → cli-NIG4N3XM.js} +16 -15
- package/dist/{cli-LFP5ZGYS.js.map → cli-NIG4N3XM.js.map} +1 -1
- package/dist/{cli-PYPX6O6E.js → cli-PSKNB66T.js} +225 -58
- package/dist/cli-PSKNB66T.js.map +1 -0
- package/dist/{cli-3BIBYHFK.js → cli-UO4NHIB3.js} +17 -17
- package/dist/{cli-6UB5N6CU.js → cli-UQ7A3YA2.js} +17 -18
- package/dist/{cli-6UB5N6CU.js.map → cli-UQ7A3YA2.js.map} +1 -1
- package/dist/{cli-673OTRGE.js → cli-YHYDLQAF.js} +10 -10
- package/dist/cli.js +11 -11
- package/dist/config-P4HDNTYD.js +26 -0
- package/dist/conformance-ZFCMKM6M.js +18 -0
- package/dist/docmeta.js +9 -9
- package/dist/github-7ZCH5PSO.js +26 -0
- package/dist/github-POT6724K.js +31 -0
- package/dist/host-6GURH5HE.js +23 -0
- package/dist/index.d.ts +102 -12
- package/dist/index.js +185 -171
- package/dist/index.js.map +1 -1
- package/dist/{json-SY7KLNC7.js → json-KT2K62L5.js} +12 -13
- package/dist/lint-5AQ5C2BV.js +29 -0
- package/dist/list-5JZKX2NK.js +28 -0
- package/dist/list-SWPFXQMU.js +30 -0
- package/dist/{page-KSGV5RD4.js → page-UPSXRP75.js} +11 -12
- package/dist/prepare-6GNEWCNH.js +155 -0
- package/dist/prepare-6GNEWCNH.js.map +1 -0
- package/dist/{pretty-CXSDXNAS.js → pretty-Q6FQAOK4.js} +13 -14
- package/dist/{pretty-A5EGTN35.js → pretty-SQRPFPSQ.js} +12 -13
- package/dist/provider-AMGRDY6V.js +34 -0
- package/dist/release-IECYCLTD.js +36 -0
- package/dist/release-IECYCLTD.js.map +1 -0
- package/dist/{reporters-HUY7UXFS.js → reporters-45MMC2ID.js} +13 -13
- package/dist/{reporters-K2VUKSAK.js → reporters-XUV4MM64.js} +7 -5
- package/dist/reporters-XUV4MM64.js.map +1 -0
- package/dist/run-KMWY2IAN.js +32 -0
- package/dist/run-KMWY2IAN.js.map +1 -0
- package/dist/{term-BIQUPMOR.js → term-PCJUCWNF.js} +16 -17
- package/dist/{term-BIQUPMOR.js.map → term-PCJUCWNF.js.map} +1 -1
- package/dist/validate-IMNCZNWG.js +17 -0
- package/dist/validate-IMNCZNWG.js.map +1 -0
- package/package.json +2 -2
- package/plugin/manni/.claude-plugin/plugin.json +1 -1
- package/plugin/manni/hooks/hooks.json +47 -0
- package/dist/batch-GFNLTGOH.js +0 -36
- package/dist/build-COYIQ25L.js +0 -31
- package/dist/calibrate-MDBLJKEE.js +0 -31
- package/dist/capture-LRML2PKV.js +0 -32
- package/dist/check-EDLBYL5N.js +0 -27
- package/dist/chunk-6JSSEWBG.js.map +0 -1
- package/dist/chunk-A5ULMVHQ.js +0 -164
- package/dist/chunk-A5ULMVHQ.js.map +0 -1
- package/dist/chunk-C4SQM22E.js.map +0 -1
- package/dist/chunk-CK7SKVHR.js.map +0 -1
- package/dist/chunk-FBEQCK47.js.map +0 -1
- package/dist/chunk-LJ2RDH3F.js.map +0 -1
- package/dist/chunk-M2JCK5F6.js.map +0 -1
- package/dist/chunk-M3W7J6MU.js.map +0 -1
- package/dist/chunk-NLXTXE5Y.js.map +0 -1
- package/dist/chunk-NXV7WE2D.js.map +0 -1
- package/dist/chunk-Q35YIDBV.js.map +0 -1
- package/dist/chunk-RL5XWQOL.js.map +0 -1
- package/dist/chunk-TK3FC4RF.js +0 -3090
- package/dist/chunk-TK3FC4RF.js.map +0 -1
- package/dist/chunk-TU2WUBVZ.js +0 -2
- package/dist/chunk-WB3QM6PP.js.map +0 -1
- package/dist/cli-PYPX6O6E.js.map +0 -1
- package/dist/cli-RPM5PELX.js.map +0 -1
- package/dist/github-6QMYOHC3.js +0 -27
- package/dist/github-SXPGP5DB.js +0 -32
- package/dist/lint-ASMJLLPA.js +0 -28
- package/dist/list-KZNVTNVC.js +0 -31
- package/dist/list-Q57YTFUQ.js +0 -29
- package/dist/run-3DYJNRIG.js +0 -33
- package/dist/validate-53RKM2XG.js +0 -16
- /package/dist/{batch-GFNLTGOH.js.map → batch-OZOACN4G.js.map} +0 -0
- /package/dist/{build-COYIQ25L.js.map → build-Z5VOVADH.js.map} +0 -0
- /package/dist/{calibrate-MDBLJKEE.js.map → calibrate-TZYT42DR.js.map} +0 -0
- /package/dist/{capture-LRML2PKV.js.map → capture-SL4MNDDP.js.map} +0 -0
- /package/dist/{check-ASPIHA6B.js.map → check-5OMA42Y6.js.map} +0 -0
- /package/dist/{check-EDLBYL5N.js.map → check-OAJWC3WD.js.map} +0 -0
- /package/dist/{check-HYNGXYJV.js.map → check-PKY7KTQE.js.map} +0 -0
- /package/dist/{chunk-MWJLZMBL.js.map → chunk-2JFPBZJK.js.map} +0 -0
- /package/dist/{chunk-QQUKGCAJ.js.map → chunk-2KRB3EG7.js.map} +0 -0
- /package/dist/{chunk-QZ6LRSNV.js.map → chunk-3NWX34ZI.js.map} +0 -0
- /package/dist/{chunk-IDV6HJCB.js.map → chunk-5G53XATW.js.map} +0 -0
- /package/dist/{chunk-PNPQTHBT.js.map → chunk-733Y2STG.js.map} +0 -0
- /package/dist/{chunk-EPH54CAY.js.map → chunk-7WRP5FFP.js.map} +0 -0
- /package/dist/{chunk-MMTSSTG7.js.map → chunk-C3B2VJNC.js.map} +0 -0
- /package/dist/{chunk-PU6DFJMY.js.map → chunk-C73RSUIC.js.map} +0 -0
- /package/dist/{chunk-GCQRPUSB.js.map → chunk-DC5DDJVE.js.map} +0 -0
- /package/dist/{chunk-6OYEI2VV.js.map → chunk-ECVQNGTH.js.map} +0 -0
- /package/dist/{chunk-7UKO3ASZ.js.map → chunk-GAJIJKET.js.map} +0 -0
- /package/dist/{chunk-YTURO7SI.js.map → chunk-MHM4QEBV.js.map} +0 -0
- /package/dist/{chunk-JCDXE76J.js.map → chunk-NBMPHD4I.js.map} +0 -0
- /package/dist/{chunk-YB4IBW3M.js.map → chunk-NTWW7J76.js.map} +0 -0
- /package/dist/{chunk-PIKOVN6W.js.map → chunk-QW77LCOU.js.map} +0 -0
- /package/dist/{chunk-2B7ZNTPV.js.map → chunk-SM6NOMJS.js.map} +0 -0
- /package/dist/{chunk-JXLTXMJ7.js.map → chunk-T6SYGLWR.js.map} +0 -0
- /package/dist/{chunk-QRWGPQKO.js.map → chunk-TLXE7LYK.js.map} +0 -0
- /package/dist/{chunk-SKSDRUUK.js.map → chunk-UAKNZVCD.js.map} +0 -0
- /package/dist/{chunk-MYMBCTDE.js.map → chunk-XXDXIIQ4.js.map} +0 -0
- /package/dist/{cli-3BIBYHFK.js.map → cli-UO4NHIB3.js.map} +0 -0
- /package/dist/{chunk-TU2WUBVZ.js.map → cli-YHYDLQAF.js.map} +0 -0
- /package/dist/{cli-673OTRGE.js.map → config-P4HDNTYD.js.map} +0 -0
- /package/dist/{github-6QMYOHC3.js.map → conformance-ZFCMKM6M.js.map} +0 -0
- /package/dist/{github-SXPGP5DB.js.map → github-7ZCH5PSO.js.map} +0 -0
- /package/dist/{json-SY7KLNC7.js.map → github-POT6724K.js.map} +0 -0
- /package/dist/{lint-ASMJLLPA.js.map → host-6GURH5HE.js.map} +0 -0
- /package/dist/{list-KZNVTNVC.js.map → json-KT2K62L5.js.map} +0 -0
- /package/dist/{list-Q57YTFUQ.js.map → lint-5AQ5C2BV.js.map} +0 -0
- /package/dist/{page-KSGV5RD4.js.map → list-5JZKX2NK.js.map} +0 -0
- /package/dist/{pretty-A5EGTN35.js.map → list-SWPFXQMU.js.map} +0 -0
- /package/dist/{pretty-CXSDXNAS.js.map → page-UPSXRP75.js.map} +0 -0
- /package/dist/{reporters-HUY7UXFS.js.map → pretty-Q6FQAOK4.js.map} +0 -0
- /package/dist/{reporters-K2VUKSAK.js.map → pretty-SQRPFPSQ.js.map} +0 -0
- /package/dist/{run-3DYJNRIG.js.map → provider-AMGRDY6V.js.map} +0 -0
- /package/dist/{validate-53RKM2XG.js.map → reporters-45MMC2ID.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lint/parsers/markdown.ts","../src/lint/parsers/mdast.ts","../src/lint/parsers/sectionize.ts","../src/lint/parsers/metadata.ts","../src/lint/parsers/html.ts","../src/lint/parsers/rst.ts","../src/lint/parsers/xml.ts","../src/lint/parsers/asciidoc.ts","../src/lint/parsers/index.ts"],"sourcesContent":["/**\n * Markdown and MDX parsers.\n *\n * They share everything but the unified processor. MDX needs its own, selected\n * by extension rather than by a flag: `remark-mdx` reads `{` as an expression\n * delimiter, so ordinary Markdown prose containing a brace is a syntax error\n * under it. Running one processor for both formats would break either MDX\n * (without the plugin) or plain Markdown (with it).\n */\nimport { unified } from \"unified\";\nimport remarkParse from \"remark-parse\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkFrontmatter from \"remark-frontmatter\";\nimport remarkMdx from \"remark-mdx\";\nimport { extractFrontmatter } from \"../../meta/index.js\";\nimport type { ContentKind, DocumentParser, DocumentTree } from \"../types.js\";\nimport { LintError } from \"../types.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport { documentEnd, toFragments } from \"./mdast.js\";\nimport { sectionize } from \"./sectionize.js\";\nimport { fencedPosition as frontmatterPosition, withMetadataTitle as withFrontmatterTitle } from \"./metadata.js\";\n\nconst markdownProcessor = unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkFrontmatter, [\"yaml\", \"toml\"]);\n\nconst mdxProcessor = unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkFrontmatter, [\"yaml\", \"toml\"])\n .use(remarkMdx);\n\n/**\n * Only `parse` is used, and unified's `Processor` generics differ between the\n * plain and MDX pipelines (their tree types are not the same), so the narrow\n * structural type is both sufficient and the one that lets both pass.\n */\ninterface Parseable {\n parse(content: string): unknown;\n}\n\nfunction parseWith(\n processor: Parseable,\n format: string,\n content: string,\n filePath: string,\n): DocumentTree {\n let root: unknown;\n try {\n root = processor.parse(content);\n } catch (err) {\n // MDX raises on malformed expressions; a parse failure is the file's\n // problem, not a crash, so it surfaces as an operational error naming it.\n throw new LintError(\n `${filePath}: could not parse as ${format}: ${errorMessage(err)}`,\n );\n }\n\n const meta = extractFrontmatter(content, format);\n const tree = root as Parameters<typeof toFragments>[0];\n\n const frontmatter = meta.present ? meta.data : null;\n const metaPosition = frontmatterPosition(content);\n\n return {\n format,\n filePath,\n frontmatter,\n frontmatterPosition: metaPosition,\n sections: sectionize(\n withFrontmatterTitle(toFragments(tree), frontmatter, metaPosition),\n documentEnd(tree),\n ),\n // Markdown's links are read from mdast by `manni graph` itself.\n links: [],\n };\n}\n\n/**\n * What both formats emit. `element` is MDX's alone: plain Markdown has no JSX,\n * so `<Steps>` is raw HTML to it and no tree it produces carries an element.\n * Declaring one here would report a rule about elements as checked on every\n * `.md` file it silently could not see.\n */\nconst SHARED_KINDS: ContentKind[] = [\n \"paragraph\",\n \"codeBlock\",\n \"list\",\n \"listItem\",\n \"table\",\n \"tableRow\",\n \"tableCell\",\n \"admonition\",\n \"image\",\n \"blockquote\",\n];\n\nexport const markdownParser: DocumentParser = {\n name: \"markdown\",\n label: \"Markdown\",\n kinds: SHARED_KINDS,\n extensions: [\".md\", \".markdown\"],\n parse: (content, filePath) =>\n parseWith(markdownProcessor, \"markdown\", content, filePath),\n};\n\nexport const mdxParser: DocumentParser = {\n name: \"mdx\",\n label: \"MDX\",\n kinds: [...SHARED_KINDS, \"element\"],\n extensions: [\".mdx\"],\n parse: (content, filePath) => parseWith(mdxProcessor, \"mdx\", content, filePath),\n};\n","/**\n * mdast -> generic fragments. Shared by the Markdown and MDX parsers, which\n * differ only in which unified processor produced the tree.\n *\n * The mapping is onto the family content model (proposal 0065), never onto a\n * nearest neighbour: a blockquote is a `blockquote` and a table is a `table`,\n * because counting either as a paragraph would make `paragraphs: {max: 3}`\n * fail documents a reader would say satisfy it. A node type the model has no\n * kind for is still skipped with its subtree rather than approximated.\n *\n * MDX-only node types (`mdxJsxFlowElement`, and the expressions and comments\n * this file deliberately drops) appear only in trees the MDX processor\n * produced. The plain Markdown processor has no `remark-mdx`, so its trees\n * cannot carry them and `markdownParser` neither emits `element` nor declares\n * it. That is why one mapping serves both formats without a mode flag.\n */\nimport { toString as mdastToString } from \"mdast-util-to-string\";\nimport type { Position } from \"../types.js\";\nimport type {\n AdmonitionNode,\n ContentNode,\n ElementNode,\n ImageNode,\n ListItemNode,\n TableCellNode,\n TableRowNode,\n} from \"../types.js\";\nimport type { Fragment } from \"./sectionize.js\";\n\n/** An MDX JSX attribute, as `mdast-util-mdx-jsx` shapes it. */\ninterface MdAttribute {\n type: string;\n name?: string | null;\n /** A string for `a=\"b\"`, null for a bare `a`, an expression node for `a={b}`. */\n value?: string | { type?: string; value?: string } | null;\n}\n\n/** Minimal structural view of an mdast node; avoids depending on @types/mdast shapes. */\ninterface MdNode {\n type: string;\n position?: {\n start: { line: number; column: number; offset?: number };\n end: { line: number; column: number; offset?: number };\n };\n children?: MdNode[];\n depth?: number;\n lang?: string | null;\n ordered?: boolean | null;\n value?: string;\n url?: string;\n alt?: string | null;\n title?: string | null;\n /** MDX JSX only; null on a fragment (`<>`). */\n name?: string | null;\n attributes?: MdAttribute[];\n}\n\nconst ZERO: Position = {\n start: { line: 1, column: 1, offset: 0 },\n end: { line: 1, column: 1, offset: 0 },\n};\n\n/**\n * unist positions carry `offset` as optional. It is always present on a tree\n * remark parsed from a string, but the type does not say so, and a missing\n * offset would otherwise become `NaN` in a reporter.\n */\nexport function positionOf(node: MdNode): Position {\n const p = node.position;\n if (!p) return { start: { ...ZERO.start }, end: { ...ZERO.end } };\n return {\n start: { line: p.start.line, column: p.start.column, offset: p.start.offset ?? 0 },\n end: { line: p.end.line, column: p.end.column, offset: p.end.offset ?? 0 },\n };\n}\n\nfunction isContentNode(node: ContentNode | null): node is ContentNode {\n return node !== null;\n}\n\nfunction childContent(node: MdNode): ContentNode[] {\n return (node.children ?? []).map(toContentNode).filter(isContentNode);\n}\n\n/**\n * `AdmonitionNode.variant` is optional, for the formats that name a flavor\n * this vocabulary does not carry. A GitHub alert always names one of five, so\n * every admonition this file produces has one, and saying so here is what\n * keeps a missing lookup from being mistaken for a format that named nothing.\n */\ntype AlertVariant = NonNullable<AdmonitionNode[\"variant\"]>;\n\n/**\n * The five alert types GitHub defines. `danger` is in the model's `variant`\n * set but is not one of them, so `> [!DANGER]` renders as an ordinary\n * blockquote and is read as one here: a word outside the source's own set is\n * not an equivalence to invent.\n */\nconst ALERT_VARIANTS = new Map<string, AlertVariant>([\n [\"note\", \"note\"],\n [\"tip\", \"tip\"],\n [\"important\", \"important\"],\n [\"warning\", \"warning\"],\n [\"caution\", \"caution\"],\n]);\n\n/** The marker line, which must be the whole first line of the first paragraph. */\nconst ALERT_MARKER = /^\\[!([A-Za-z]+)\\][^\\S\\n]*$/;\n\n/**\n * The same marker where it sits at the head of a flattened string, with the\n * newline that followed it. `mdast-util-to-string` concatenates block children\n * without a separator, so the marker's paragraph may run straight into the\n * next one and there is no newline to consume.\n */\nconst ALERT_PREFIX = /^\\[!\\w+\\][^\\S\\n]*\\n?/;\n\n/**\n * A GitHub alert, which is a blockquote whose first paragraph opens with a\n * marker line. It is a check on that paragraph's text rather than a plugin,\n * because the marker is ordinary text to every Markdown parser.\n */\nfunction alertVariant(node: MdNode): AlertVariant | null {\n const first = node.children?.[0];\n if (!first || first.type !== \"paragraph\") return null;\n const text = mdastToString(first);\n const newline = text.indexOf(\"\\n\");\n const firstLine = newline === -1 ? text : text.slice(0, newline);\n const match = ALERT_MARKER.exec(firstLine);\n const word = match?.[1];\n // Case-insensitively, as GitHub matches it.\n return word ? (ALERT_VARIANTS.get(word.toLowerCase()) ?? null) : null;\n}\n\nfunction toAdmonition(node: MdNode, variant: AlertVariant): AdmonitionNode {\n const children = childContent(node);\n const first = children[0];\n // The marker is markup, not content, so it is stripped from the admonition's\n // own text and from the paragraph that carried it. A paragraph left holding\n // nothing but the marker is dropped rather than kept as an empty one.\n if (first && first.kind === \"paragraph\") {\n const stripped = first.text.replace(ALERT_PREFIX, \"\");\n if (stripped.length === 0) children.shift();\n else children[0] = { ...first, text: stripped };\n }\n return {\n kind: \"admonition\",\n position: positionOf(node),\n text: mdastToString(node).replace(ALERT_PREFIX, \"\"),\n variant,\n children,\n };\n}\n\n/**\n * The image a paragraph holds, when that is all it holds. An image inside\n * richer prose is part of what the paragraph says: promoting it would take the\n * sentence around it out of the paragraph count.\n */\nfunction soleImage(node: MdNode): MdNode | null {\n const meaningful = (node.children ?? []).filter(\n (child) => !(child.type === \"text\" && (child.value ?? \"\").trim().length === 0),\n );\n const only = meaningful.length === 1 ? meaningful[0] : undefined;\n return only && only.type === \"image\" ? only : null;\n}\n\nfunction toImage(node: MdNode): ImageNode {\n const alt = node.alt ?? \"\";\n return {\n kind: \"image\",\n position: positionOf(node),\n text: alt,\n url: node.url ?? \"\",\n alt,\n ...(node.title ? { title: node.title } : {}),\n };\n}\n\n/**\n * An MDX element's attributes, by their literal values: the string for\n * `a=\"b\"`, `true` for a bare `a`, and the braced source for `a={b}`, so a rule\n * can say \"its value is an expression\" rather than silently not matching a\n * value it cannot know. A spread (`{...rest}`) names no attribute and is\n * dropped, having no key to record it under.\n */\nfunction attributesOf(node: MdNode): Record<string, string | true> | undefined {\n const attributes: Record<string, string | true> = {};\n let any = false;\n for (const attribute of node.attributes ?? []) {\n if (attribute.type !== \"mdxJsxAttribute\") continue;\n const name = attribute.name;\n if (typeof name !== \"string\" || name.length === 0) continue;\n const value = attribute.value;\n if (value === null || value === undefined) attributes[name] = true;\n else if (typeof value === \"string\") attributes[name] = value;\n else attributes[name] = `{${value.value ?? \"\"}}`;\n any = true;\n }\n return any ? attributes : undefined;\n}\n\nfunction toElement(node: MdNode): ElementNode {\n const attributes = attributesOf(node);\n return {\n kind: \"element\",\n position: positionOf(node),\n text: mdastToString(node),\n // A fragment (`<>`) has no tag to name.\n name: node.name ?? \"\",\n ...(attributes ? { attributes } : {}),\n // The element's own children, never the enclosing section's: a section\n // holding one `<Steps>` holds one block, not the four paragraphs inside\n // it (proposal 0065, stress test 4). A heading inside one is dropped with\n // everything else the model has no kind for, which stress test 5 records.\n children: childContent(node),\n };\n}\n\nfunction toTableRow(row: MdNode, header: boolean): TableRowNode {\n return {\n kind: \"tableRow\",\n position: positionOf(row),\n text: mdastToString(row),\n header,\n children: (row.children ?? [])\n .filter((cell) => cell.type === \"tableCell\")\n .map(\n (cell): TableCellNode => ({\n kind: \"tableCell\",\n position: positionOf(cell),\n text: mdastToString(cell),\n // A GFM cell holds inline content only, so this is empty today. It\n // is mapped rather than assumed empty because the model's cell is\n // the one reStructuredText and DITA fill with blocks.\n children: childContent(cell),\n }),\n ),\n };\n}\n\nfunction toContentNode(node: MdNode): ContentNode | null {\n switch (node.type) {\n case \"paragraph\": {\n const image = soleImage(node);\n if (image) return toImage(image);\n return {\n kind: \"paragraph\",\n position: positionOf(node),\n text: mdastToString(node),\n };\n }\n case \"code\":\n return {\n kind: \"codeBlock\",\n position: positionOf(node),\n text: node.value ?? \"\",\n ...(node.lang ? { language: node.lang } : {}),\n };\n case \"list\":\n return {\n kind: \"list\",\n position: positionOf(node),\n text: mdastToString(node),\n ordered: Boolean(node.ordered),\n items: (node.children ?? [])\n .filter((child) => child.type === \"listItem\")\n .map(\n (item): ListItemNode => ({\n kind: \"listItem\",\n position: positionOf(item),\n text: mdastToString(item),\n children: childContent(item),\n }),\n ),\n };\n case \"table\":\n return {\n kind: \"table\",\n position: positionOf(node),\n text: mdastToString(node),\n // GFM guarantees the first row is the header, which is the one format\n // of six where reading it positionally is safe. Everywhere else the\n // format carries a real `thead` and this flag comes from it.\n children: (node.children ?? [])\n .filter((row) => row.type === \"tableRow\")\n .map((row, index) => toTableRow(row, index === 0)),\n };\n case \"blockquote\": {\n const variant = alertVariant(node);\n if (variant) return toAdmonition(node, variant);\n return {\n kind: \"blockquote\",\n position: positionOf(node),\n text: mdastToString(node),\n children: childContent(node),\n };\n }\n case \"mdxJsxFlowElement\":\n return toElement(node);\n default:\n return null;\n }\n}\n\n/**\n * The `{#anchor}` suffix Hugo and Docusaurus write on a heading. It names the\n * rendered id, and a reader never sees it, so a template matches the heading\n * without it.\n */\nconst HEADING_ANCHOR = /\\s*\\{#[^}\\s]*\\}\\s*$/;\n\nfunction headingTitle(node: MdNode): string {\n return mdastToString(node).replace(HEADING_ANCHOR, \"\").trim();\n}\n\n/** Flatten an mdast root's direct children into ordered fragments. */\nexport function toFragments(root: MdNode): Fragment[] {\n const fragments: Fragment[] = [];\n for (const node of root.children ?? []) {\n // Frontmatter is metadata, not body content; the caller reads it separately.\n if (node.type === \"yaml\" || node.type === \"toml\") continue;\n\n if (node.type === \"heading\") {\n fragments.push({\n type: \"heading\",\n level: node.depth ?? 1,\n title: headingTitle(node),\n position: positionOf(node),\n });\n continue;\n }\n\n const content = toContentNode(node);\n if (content) fragments.push({ type: \"content\", node: content });\n }\n return fragments;\n}\n\n/** End of the document, for closing the final sections. */\nexport function documentEnd(root: MdNode): Position[\"end\"] {\n return positionOf(root).end;\n}\n","/**\n * Fold a flat list of fragments into a nested section tree.\n *\n * Every format arrives here as an ordered list of `Fragment`s - a heading, or\n * a piece of content - and leaves as `SectionNode[]`. Keeping the fold in one\n * place is what makes a new format one `toFragments` function rather than a\n * second copy of the nesting, position, and slug logic.\n *\n * Named `Fragment` rather than `Block`, deliberately: \"block\" is the\n * block-level content vocabulary (`ContentKind`'s `table`, `blockquote`, and\n * so on), and this internal pipeline type never leaves `src/lint/parsers/`.\n *\n * Two position rules are deliberate:\n *\n * - A section ends where the *next section at its level or shallower* begins,\n * not at its own last child. A finding about a section therefore spans the\n * trailing blank lines a reader would consider part of it, and adjacent\n * sections tile the document with no gaps.\n * - Content appearing before any heading becomes an implicit lead section at\n * `level: 0`, so a headless document (frontmatter, prose, then `## ...`)\n * still has somewhere to hang its content and its later headings nest under\n * it rather than being dropped.\n */\nimport GithubSlugger from \"github-slugger\";\nimport type { ContentNode, Position, SectionNode } from \"../types.js\";\n\nexport interface HeadingFragment {\n type: \"heading\";\n /** 1-6. */\n level: number;\n title: string;\n position: Position;\n /** The source's own anchor for this heading; copied to `SectionNode.id`. */\n id?: string;\n /** Made by `withMetadataTitle`, not written; copied to `SectionNode.synthetic`. */\n synthetic?: true;\n}\n\nexport interface ContentFragment {\n type: \"content\";\n node: ContentNode;\n}\n\nexport type Fragment = HeadingFragment | ContentFragment;\n\n/** Mutable while open; frozen into a `SectionNode` on close. */\ninterface OpenSection {\n node: SectionNode;\n /** End of the last block seen, the fallback when nothing follows. */\n lastEnd: Position[\"end\"];\n}\n\n/**\n * @param fragments Document fragments in source order, frontmatter excluded.\n * @param docEnd End of the document, used to close the final sections.\n */\nexport function sectionize(fragments: Fragment[], docEnd: Position[\"end\"]): SectionNode[] {\n const slugger = new GithubSlugger();\n const roots: SectionNode[] = [];\n const stack: OpenSection[] = [];\n\n /** Close every open section at `level` or deeper, ending it at `end`. */\n const closeTo = (level: number, end: Position[\"end\"]): void => {\n let top = stack.at(-1);\n while (top !== undefined && top.node.level >= level) {\n stack.pop();\n top.node.position.end = { ...end };\n top = stack.at(-1);\n }\n };\n\n /** Pushes `node` onto the stack and hands back the section it opened. */\n const push = (node: SectionNode): OpenSection => {\n const parent = stack[stack.length - 1];\n if (parent) {\n node.parentSlug = parent.node.slug;\n node.order = parent.node.sections.length + 1;\n parent.node.sections.push(node);\n } else {\n node.parentSlug = null;\n node.order = roots.length + 1;\n roots.push(node);\n }\n const open: OpenSection = { node, lastEnd: node.position.end };\n stack.push(open);\n return open;\n };\n\n /**\n * The implicit lead section. `level: 0` is below every real heading, so the\n * headings that follow nest inside it instead of closing it.\n */\n const openLead = (start: Position[\"start\"]): OpenSection =>\n push({\n slug: slugger.slug(\"(lead)\"),\n title: \"\",\n level: 0,\n order: 0,\n parentSlug: null,\n titlePosition: null,\n position: { start: { ...start }, end: { ...start } },\n children: [],\n sections: [],\n });\n\n for (const fragment of fragments) {\n if (fragment.type === \"heading\") {\n closeTo(fragment.level, fragment.position.start);\n push({\n slug: slugger.slug(fragment.title),\n title: fragment.title,\n level: fragment.level,\n order: 0,\n parentSlug: null,\n titlePosition: { ...fragment.position },\n ...(fragment.id !== undefined ? { id: fragment.id } : {}),\n ...(fragment.synthetic ? { synthetic: true as const } : {}),\n position: { start: { ...fragment.position.start }, end: { ...fragment.position.end } },\n children: [],\n sections: [],\n });\n continue;\n }\n\n const current = stack.at(-1) ?? openLead(fragment.node.position.start);\n current.node.children.push(fragment.node);\n current.lastEnd = fragment.node.position.end;\n // Every enclosing section grows with its descendants, so a parent's span\n // always covers its children even before it is closed.\n for (const open of stack) open.node.position.end = { ...fragment.node.position.end };\n }\n\n closeTo(0, docEnd);\n return roots;\n}\n","/**\n * Metadata helpers shared by every format that has both metadata and headings.\n *\n * Both functions here were independently written four times, once per parser,\n * and were character-identical each time. They are rules about a `DocumentTree`\n * rather than about any one syntax, so they belong in one place: a subtlety\n * duplicated four ways is a subtlety that will be fixed one way.\n */\nimport { locateFrontmatter } from \"../../meta/index.js\";\nimport type { Position } from \"../types.js\";\nimport type { Fragment } from \"./sectionize.js\";\n\n/**\n * Span of a leading fenced metadata block (`--- … ---`, `+++ … +++`,\n * `;;; … ;;;`), or null when the content carries none.\n *\n * docmeta's locator reports character offsets against the original content, so\n * line numbers are recovered by counting newlines rather than by a second\n * parse - exact, because those offsets are byte-for-byte.\n */\nexport function fencedPosition(content: string): Position | null {\n const loc = locateFrontmatter(content);\n if (!loc) return null;\n const before = content.slice(0, loc.openStart);\n const startLine = before.split(\"\\n\").length;\n const lines = content.slice(loc.openStart, loc.closeEnd).split(\"\\n\");\n return {\n start: { line: startLine, column: 1, offset: loc.openStart },\n end: {\n line: startLine + lines.length - 1,\n // Taken from the last line's own length rather than fixed at 1. When the\n // block ends with a newline that line is empty and the column is 1\n // anyway; when the closing fence ends at EOF without one, the half-open\n // end is just past the delimiter - which `offset` already said, so a\n // fixed column contradicted it and pointed a reader's caret at the start\n // of the fence line instead of its end.\n // `split` always yields at least one entry, so the fallback is\n // unreachable; an empty last line is column 1 either way.\n column: (lines.at(-1) ?? \"\").length + 1,\n offset: loc.closeEnd,\n },\n };\n}\n\n/**\n * Treat a metadata `title` as the document's H1 when the body has none.\n *\n * Docusaurus, Hugo, and Starlight all render the page title from frontmatter,\n * so their pages legitimately start at `##`. Read literally, such a page has no\n * top-level section, and every doctype template - which models the title as its\n * outermost rule, because that is how the published templates are written -\n * misaligns against it and reports a cascade. The page is not malformed; the\n * title simply is not written where a naive reading looks for it.\n *\n * So a synthetic heading is prepended, positioned on the metadata that actually\n * carries the title. Everything downstream then sees the document the way a\n * reader sees it rendered.\n *\n * Only when the body has no level-1 heading of its own: prepending one where a\n * real title exists would nest it inside a synthetic parent, which is a\n * different document.\n *\n * See ADR 01006. Formats where the title is always a body element - XML, whose\n * \"metadata\" is the root element's own attributes - do not call this, and\n * should not.\n */\nexport function withMetadataTitle(\n fragments: Fragment[],\n metadata: Record<string, unknown> | null,\n position: Position | null,\n): Fragment[] {\n const declared = metadata?.[\"title\"];\n const title = typeof declared === \"string\" ? declared.trim() : null;\n // Trimmed, not merely non-empty: `title: \" \"` is as absent as no title at\n // all, and admitting it would give the document a synthetic H1 with a blank\n // heading - which every template then reports as the wrong title, naming\n // nothing the author could search for.\n if (title === null || title.length === 0) return fragments;\n if (position === null) return fragments;\n if (fragments.some((b) => b.type === \"heading\" && b.level === 1)) return fragments;\n\n return [{ type: \"heading\", level: 1, title, position, synthetic: true }, ...fragments];\n}\n\n/**\n * The content with a leading fenced metadata block removed.\n *\n * docmeta's AsciiDoc and reStructuredText extractors short-circuit: when a\n * fence is present they return it and never look at the format's own metadata.\n * So a page carrying both a `---` fence and a native `:type: how-to` header\n * lost the `type` entirely and was skipped as untyped - while the same page in\n * HTML, whose extractor has no such branch, routed correctly. Running the\n * native extractor over the fence-free remainder is what lets both be read.\n *\n * Only the values are taken from that second read; positions would be shifted\n * by the removal and are not used.\n */\nexport function withoutFence(content: string): string {\n const loc = locateFrontmatter(content);\n return loc ? content.slice(loc.closeEnd) : content;\n}\n","/**\n * HTML parser: parse5's DOM -> generic blocks -> the shared `sectionize` fold.\n *\n * The job is the same one `mdast.ts` does for Markdown - flatten a format's own\n * tree into ordered `Fragment`s - and the same skipping discipline applies\n * where the content model has no kind at all. A `<div>` is not content and a\n * `<figure>` with no image inside it is dropped whole, because counting\n * either would make `paragraphs: {max: 3}` fail a page a reader would say\n * satisfies it. Proposal 0065 widened the model, so `blockquote`, `table`,\n * `figure`, and `dl` are no longer in that group: they map onto real nodes\n * now, alongside `admonition` from `<aside>`/`role=\"note\"` and `image` from\n * `<img>`.\n *\n * `parse` rather than `parseFragment`. Real documentation HTML is a document:\n * `<!DOCTYPE html><html><head>…</head><body>…`, and an HTML page's metadata\n * lives in `<head>`, which `parseFragment` (which parses in a `<body>` context)\n * drops on the floor - `<head>` is an ignored start tag in the \"in body\"\n * insertion mode. `parse` also handles a bare fragment, because HTML5 tree\n * construction synthesizes the missing `<html>`/`<head>`/`<body>` around it; the\n * only cost is that those synthesized elements carry no `sourceCodeLocation`,\n * which `positionOf` already has to tolerate.\n *\n * parse5 never throws on malformed input - HTML5 defines recovery for every\n * error - so unlike the MDX path there is no parse-failure branch here. A\n * document with unclosed tags parses into whatever a browser would build from\n * it, and lints against that.\n */\nimport { defaultTreeAdapter, parse } from \"parse5\";\nimport type { DefaultTreeAdapterTypes } from \"parse5\";\nimport { extractFrontmatter, extractorForExtension } from \"../../meta/index.js\";\nimport type {\n AdmonitionNode,\n BlockquoteNode,\n CodeNode,\n ContentNode,\n DefinitionItemNode,\n DefinitionListNode,\n DocumentParser,\n DocumentTree,\n ImageNode,\n ListItemNode,\n Position,\n TableCellNode,\n TableNode,\n TableRowNode,\n} from \"../types.js\";\nimport type { Fragment } from \"./sectionize.js\";\nimport { sectionize } from \"./sectionize.js\";\nimport { fencedPosition, withMetadataTitle } from \"./metadata.js\";\n\ntype Node = DefaultTreeAdapterTypes.Node;\ntype Element = DefaultTreeAdapterTypes.Element;\ntype ParentNode = DefaultTreeAdapterTypes.ParentNode;\n\n/**\n * What a walk does when it meets an element.\n *\n * - `heading`/`content`: the element *is* a block. It is emitted and never\n * descended into, because its whole subtree has already been folded into the\n * emitted node's text (or, for a container kind, its own `children`).\n * Descending would emit the same prose twice.\n * - `container`: the element is not content but its children may be. Descend\n * without emitting. This is the case that matters: real HTML wraps\n * everything in `<html><body><main><article><div>`, and a heading inside a\n * `<div>` is still a heading.\n * - `opaque`: neither content nor a container. Skip the subtree entirely.\n *\n * `container` is the default, so an unknown element - a web component, a\n * `<my-callout>` - still yields the headings and paragraphs inside it. `opaque`\n * is a short, explicit list, and every entry earns its place the same way: it\n * is metadata/machinery rather than prose, so the generic content model has no\n * kind for it at all.\n */\ntype Role = \"heading\" | \"content\" | \"container\" | \"opaque\";\n\nconst HEADING_LEVELS = new Map<string, number>([\n [\"h1\", 1],\n [\"h2\", 2],\n [\"h3\", 3],\n [\"h4\", 4],\n [\"h5\", 5],\n [\"h6\", 6],\n]);\n\n/**\n * Elements that are a block on their own: emitted as one content node, never\n * descended into. `table`, `blockquote`, `dl`, `img` and `figure` used to sit\n * in `OPAQUE_TAGS` and be dropped whole; proposal 0065 gave each a node shape,\n * so they move here instead. `aside` joins them because it is one of the two\n * HTML sources of `admonition` - the other, `role=\"note\"`, is not a tag and is\n * checked separately in `roleOf`.\n */\nconst CONTENT_TAGS = new Set([\"p\", \"pre\", \"ul\", \"ol\", \"table\", \"blockquote\", \"dl\", \"img\", \"figure\", \"aside\"]);\n\nconst OPAQUE_TAGS = new Set([\n // Metadata and machinery, not prose.\n \"head\",\n \"script\",\n \"style\",\n \"template\",\n \"noscript\",\n \"svg\",\n \"math\",\n]);\n\n/** Elements whose text is not document text, for the flattening helpers. */\nconst NON_TEXT_TAGS = new Set([\"script\", \"style\", \"template\"]);\n\nconst ADMONITION_VARIANTS = new Set([\n \"note\",\n \"tip\",\n \"important\",\n \"caution\",\n \"warning\",\n \"danger\",\n]);\n\nconst ZERO: Position = {\n start: { line: 1, column: 1, offset: 0 },\n end: { line: 1, column: 1, offset: 0 },\n};\n\nfunction tagOf(el: Element): string {\n return el.tagName.toLowerCase();\n}\n\n/** An element's attribute value, or `undefined` when it does not carry one. */\nfunction attrOf(el: Element, name: string): string | undefined {\n return el.attrs.find((a) => a.name === name)?.value;\n}\n\n/**\n * `admonition`'s two HTML sources: the `<aside>` tag, and `role=\"note\"` on any\n * element. Neither one is enough on its own - `aside` is a tag and `role` is\n * an attribute any element can carry - so this is checked ahead of the\n * tag-keyed `CONTENT_TAGS`/`OPAQUE_TAGS` lookup rather than folded into it.\n */\nfunction isAdmonitionSource(el: Element, tag: string): boolean {\n return tag === \"aside\" || attrOf(el, \"role\") === \"note\";\n}\n\nfunction roleOf(el: Element, tag: string): Role {\n if (HEADING_LEVELS.has(tag)) return \"heading\";\n if (isAdmonitionSource(el, tag)) return \"content\";\n if (CONTENT_TAGS.has(tag)) return \"content\";\n if (OPAQUE_TAGS.has(tag)) return \"opaque\";\n return \"container\";\n}\n\n/**\n * parse5's `sourceCodeLocation` maps onto `Position` one field at a time: its\n * lines and columns are 1-based, its offsets 0-based, and its `end*` is one\n * past the last character - the same half-open span `Position` documents. A\n * `<p>foo</p>` starting at column 1 reports `endCol` 12 for an 11-character\n * element, and `endOffset - startOffset` is its length.\n *\n * A node can carry no location at all: parse5 synthesizes `<html>`, `<head>`,\n * and `<body>` around a fragment, and those have none. Nothing synthesized is\n * ever emitted as a block, but the fallback keeps a missing location from\n * becoming `NaN` in a reporter.\n */\ninterface Located {\n sourceCodeLocation?: {\n startLine: number;\n startCol: number;\n startOffset: number;\n endLine: number;\n endCol: number;\n endOffset: number;\n } | null;\n}\n\nfunction positionOf(node: Located): Position {\n const loc = node.sourceCodeLocation;\n if (!loc) return { start: { ...ZERO.start }, end: { ...ZERO.end } };\n return {\n start: { line: loc.startLine, column: loc.startCol, offset: loc.startOffset },\n end: { line: loc.endLine, column: loc.endCol, offset: loc.endOffset },\n };\n}\n\n/**\n * Concatenated text of a subtree, markup and all, verbatim. `skipHref` drops\n * an `<a>` linking exactly there, which is how a heading leaves out its own\n * permalink glyph.\n */\nfunction rawText(node: Node, skipHref?: string): string {\n if (defaultTreeAdapter.isTextNode(node)) return node.value;\n if (!defaultTreeAdapter.isElementNode(node)) return \"\";\n const tag = tagOf(node);\n if (NON_TEXT_TAGS.has(tag)) return \"\";\n if (skipHref !== undefined && tag === \"a\" && attrOf(node, \"href\") === skipHref) return \"\";\n let out = \"\";\n for (const child of node.childNodes) out += rawText(child, skipHref);\n return out;\n}\n\n/**\n * Text as a browser renders it: nested `<code>`, `<em>`, and `<a>` contribute\n * their text, and HTML's insignificant whitespace collapses, so a heading\n * written across three indented lines still equals `\"Overview\"` - which is what\n * a template's `heading: {const: Overview}` compares against.\n *\n * This is the HTML side of the bug the Markdown parser had before the rewrite,\n * where a title was built from `children.map(c => c.value)` and every inline\n * element vanished.\n */\nfunction flatText(node: Node, skipHref?: string): string {\n return rawText(node, skipHref).replace(/\\s+/g, \" \").trim();\n}\n\n/** `language-x` from a `class`, per the HTML5 convention for code blocks. */\nfunction langOf(el: Element): string | undefined {\n const className = attrOf(el, \"class\");\n if (!className) return undefined;\n for (const token of className.split(/\\s+/)) {\n if (token.startsWith(\"language-\") && token.length > \"language-\".length) {\n return token.slice(\"language-\".length);\n }\n }\n return undefined;\n}\n\n/** `variant`, from `role=\"note\"` or a class naming one of the six - never invented. */\nfunction variantOf(el: Element): AdmonitionNode[\"variant\"] | undefined {\n const className = attrOf(el, \"class\");\n if (className) {\n for (const token of className.split(/\\s+/)) {\n if (ADMONITION_VARIANTS.has(token)) return token as AdmonitionNode[\"variant\"];\n }\n }\n if (attrOf(el, \"role\") === \"note\") return \"note\";\n return undefined;\n}\n\nfunction firstElementChild(el: Element, tag: string): Element | undefined {\n for (const child of el.childNodes) {\n if (defaultTreeAdapter.isElementNode(child) && tagOf(child) === tag) return child;\n }\n return undefined;\n}\n\n/** An element's direct element children, text and comment nodes excluded. */\nfunction elementChildren(el: Element): Element[] {\n const out: Element[] = [];\n for (const child of el.childNodes) {\n if (defaultTreeAdapter.isElementNode(child)) out.push(child);\n }\n return out;\n}\n\n/** The first `<img>` anywhere under `el`, depth-first - for a `<figure>`. */\nfunction findImage(el: Element): Element | undefined {\n for (const child of el.childNodes) {\n if (!defaultTreeAdapter.isElementNode(child)) continue;\n if (tagOf(child) === \"img\") return child;\n const nested = findImage(child);\n if (nested) return nested;\n }\n return undefined;\n}\n\n/**\n * `<pre>` (usually `<pre><code>`) as a code node.\n *\n * Whitespace is significant here, so this is the one place `rawText` is used\n * unnormalized. Two trims are deliberate: a newline directly after `<code>` is\n * an artifact of writing the block over several lines (the HTML parser already\n * drops one directly after `<pre>`, but not one after a nested `<code>`), and\n * dropping trailing whitespace matches mdast's `code.value`, which carries no\n * closing newline.\n */\nfunction codeNode(pre: Element): CodeNode {\n const inner = firstElementChild(pre, \"code\");\n const lang = langOf(pre) ?? (inner ? langOf(inner) : undefined);\n const text = rawText(pre).replace(/^\\r?\\n/, \"\").replace(/\\s+$/, \"\");\n return {\n kind: \"codeBlock\",\n position: positionOf(pre),\n text,\n ...(lang ? { language: lang } : {}),\n };\n}\n\n/**\n * `<img>` as an image node. A bare `<img>` carries no caption of its own; a\n * `<figure>` wrapping one supplies both the position (the whole figure, since\n * that construct - image and caption together - is what the one node stands\n * for) and, when present, its `<figcaption>` as `text`.\n */\nfunction imageNode(img: Element, position: Position, caption: string | null): ImageNode {\n const title = attrOf(img, \"title\");\n return {\n kind: \"image\",\n position,\n text: caption ?? \"\",\n url: attrOf(img, \"src\") ?? \"\",\n alt: attrOf(img, \"alt\") ?? \"\",\n ...(title ? { title } : {}),\n };\n}\n\n/**\n * `<figure>` as a single image node. A figure with no `<img>` anywhere inside\n * it maps to nothing - the same as before 0065, when the whole subtree was\n * opaque - because the content model has no other kind to give it.\n */\nfunction figureNode(figure: Element): ImageNode | null {\n const img = findImage(figure);\n if (!img) return null;\n const caption = firstElementChild(figure, \"figcaption\");\n return imageNode(img, positionOf(figure), caption ? flatText(caption) : null);\n}\n\n/** `<blockquote>` as a blockquote node, its own content mapped recursively. */\nfunction blockquoteNode(el: Element): BlockquoteNode {\n return {\n kind: \"blockquote\",\n position: positionOf(el),\n text: flatText(el),\n children: childContent(el),\n };\n}\n\n/**\n * `<aside>` or `role=\"note\"` as an admonition node. HTML names no admonition\n * type natively, so `variantOf` only ever returns one of the six when the\n * source itself said which - see its own comment. A bare `<aside>` that names\n * neither carries no `variant` at all, per `AdmonitionNode.variant`'s own\n * comment in `src/lint/types.ts`: defaulting it to `note` would make\n * `variant: note` pass on a page that never said note.\n */\nfunction admonitionNode(el: Element): AdmonitionNode {\n const variant = variantOf(el);\n return {\n kind: \"admonition\",\n position: positionOf(el),\n text: flatText(el),\n ...(variant ? { variant } : {}),\n children: childContent(el),\n };\n}\n\n/** One `<td>`/`<th>` as a table cell, its own content mapped recursively. */\nfunction cellNode(cell: Element): TableCellNode {\n return {\n kind: \"tableCell\",\n position: positionOf(cell),\n text: flatText(cell),\n children: childContent(cell),\n };\n}\n\n/**\n * Which grouping a row was found in. `none` is a bare `<tr>` under the table.\n *\n * A footer has to be told apart from a body, rather than both being \"not the\n * head\". `<tfoot><tr><th>Total</th></tr></tfoot>` is an ordinary way to label\n * a totals row, and the every-cell-is-a-`<th>` rule below would otherwise read\n * it as a header.\n */\ntype RowGroup = \"head\" | \"body\" | \"foot\" | \"none\";\n\n/** One `<tr>`. `header` is set from `<thead>` membership, or - failing that - from every cell being a `<th>`. Never inferred from position, and never in a footer. */\nfunction rowNode(tr: Element, group: RowGroup): TableRowNode {\n const cells: TableCellNode[] = [];\n let allHeaderCells = true;\n for (const child of elementChildren(tr)) {\n const tag = tagOf(child);\n if (tag !== \"td\" && tag !== \"th\") continue;\n if (tag !== \"th\") allHeaderCells = false;\n cells.push(cellNode(child));\n }\n return {\n kind: \"tableRow\",\n position: positionOf(tr),\n text: flatText(tr),\n header:\n group === \"head\" || (group !== \"foot\" && cells.length > 0 && allHeaderCells),\n children: cells,\n };\n}\n\n/** Rows from `<thead>`/`<tbody>`/`<tfoot>` or bare `<tr>` children, in document order. */\nfunction collectRows(parent: Element, out: TableRowNode[], group: RowGroup): void {\n for (const child of elementChildren(parent)) {\n const tag = tagOf(child);\n if (tag === \"thead\") {\n collectRows(child, out, \"head\");\n } else if (tag === \"tbody\") {\n collectRows(child, out, \"body\");\n } else if (tag === \"tfoot\") {\n collectRows(child, out, \"foot\");\n } else if (tag === \"tr\") {\n out.push(rowNode(child, group));\n }\n // `<caption>`/`<colgroup>` carry no rows and are not content of their own.\n }\n}\n\n/** `<table>` as a table node. */\nfunction tableNode(table: Element): TableNode {\n const rows: TableRowNode[] = [];\n collectRows(table, rows, \"none\");\n return {\n kind: \"table\",\n position: positionOf(table),\n text: flatText(table),\n children: rows,\n };\n}\n\n/**\n * `<dl>` as a definition list. Each `<dt>` pairs with the `<dd>` elements that\n * immediately follow it - up to the next `<dt>` or the end of the list - and\n * the `<dt>`'s own text becomes the item's `term`. An item's position spans\n * from its `<dt>` through its last `<dd>`, or the `<dt>` alone when it has\n * none.\n */\nfunction definitionListNode(dl: Element): DefinitionListNode {\n const children = elementChildren(dl);\n const items: DefinitionItemNode[] = [];\n\n for (let i = 0; i < children.length; i++) {\n const dt = children[i];\n if (!dt || tagOf(dt) !== \"dt\") continue;\n\n const dds: Element[] = [];\n let j = i + 1;\n while (j < children.length) {\n const next = children[j];\n if (!next || tagOf(next) !== \"dd\") break;\n dds.push(next);\n j++;\n }\n\n const term = flatText(dt);\n const definition = dds.flatMap((dd) => childContent(dd));\n const lastDd = dds.at(-1);\n const end = lastDd ? positionOf(lastDd).end : positionOf(dt).end;\n const text = [term, ...dds.map((dd) => flatText(dd))].filter((t) => t.length > 0).join(\" \");\n\n items.push({\n kind: \"definitionItem\",\n position: { start: positionOf(dt).start, end },\n text,\n term,\n definition,\n });\n }\n\n return {\n kind: \"definitionList\",\n position: positionOf(dl),\n text: flatText(dl),\n children: items,\n };\n}\n\n/**\n * `<li>` children of a list, with their own content mapped recursively.\n */\nfunction listItems(list: Element): ListItemNode[] {\n const items: ListItemNode[] = [];\n for (const child of list.childNodes) {\n if (!defaultTreeAdapter.isElementNode(child)) continue;\n if (tagOf(child) !== \"li\") continue;\n items.push({\n kind: \"listItem\",\n position: positionOf(child),\n text: flatText(child),\n children: childContent(child),\n });\n }\n return items;\n}\n\n/**\n * One container element's content, with its own loose prose kept as a\n * paragraph. Shared by every construct that holds generic content recursively\n * - `<li>`, `<blockquote>`, `<aside>`/`role=\"note\"`, `<td>`/`<th>`, `<dd>` -\n * so the same reconciliation applies everywhere rather than once per kind.\n *\n * An item's text is rarely wrapped in a block element, but mdast puts a list\n * item's principal text in a `paragraph` child regardless, and\n * `lists: {items: {paragraphs: {min: 1}}}` has to count the same thing in\n * every format. So the loose text is gathered into one, in the position it\n * occupies among the container's blocks.\n *\n * Gathering it rather than checking whether the container has any children is\n * what makes the two cases agree. `<li>text</li>` and `<li><p>text</p></li>`\n * were already reconciled; `<li>Parent<ul>…</ul></li>` was not, because the\n * nested list is a child, so the item looked accounted for and `Parent` became\n * a paragraph nothing counted - while its Markdown, AsciiDoc, and reST twins\n * all counted one.\n *\n * A container element that yields no blocks of its own is inline in practice -\n * `<strong>`, `<a>`, `<code>` - so its text joins the prose around it instead\n * of being dropped, which is again what mdast does with the same markup.\n */\nfunction childContent(parent: Element): ContentNode[] {\n const out: ContentNode[] = [];\n let text = \"\";\n let span: Position | null = null;\n\n const extend = (node: Located): void => {\n const at = positionOf(node);\n span = span === null ? at : { start: span.start, end: at.end };\n };\n\n const flush = (): void => {\n const value = text.trim();\n const at = span;\n text = \"\";\n span = null;\n if (value.length === 0) return;\n out.push({ kind: \"paragraph\", position: at ?? positionOf(parent), text: value });\n };\n\n for (const child of parent.childNodes) {\n if (defaultTreeAdapter.isTextNode(child)) {\n text += child.value;\n if (child.value.trim().length > 0) extend(child);\n continue;\n }\n if (!defaultTreeAdapter.isElementNode(child)) continue;\n\n const tag = tagOf(child);\n const role = roleOf(child, tag);\n if (role === \"heading\" || role === \"opaque\") continue;\n\n if (role === \"content\") {\n flush();\n const node = toContentNode(child, tag);\n if (node) out.push(node);\n continue;\n }\n\n const nested = contentIn(child);\n if (nested.length > 0) {\n flush();\n out.push(...nested);\n continue;\n }\n\n const inline = flatText(child);\n text += inline;\n if (inline.trim().length > 0) extend(child);\n }\n\n flush();\n return out;\n}\n\nfunction toContentNode(el: Element, tag: string): ContentNode | null {\n if (isAdmonitionSource(el, tag)) return admonitionNode(el);\n switch (tag) {\n case \"p\":\n return { kind: \"paragraph\", position: positionOf(el), text: flatText(el) };\n case \"pre\":\n return codeNode(el);\n case \"ul\":\n case \"ol\":\n return {\n kind: \"list\",\n position: positionOf(el),\n text: flatText(el),\n ordered: tag === \"ol\",\n items: listItems(el),\n };\n case \"table\":\n return tableNode(el);\n case \"blockquote\":\n return blockquoteNode(el);\n case \"dl\":\n return definitionListNode(el);\n case \"img\":\n return imageNode(el, positionOf(el), null);\n case \"figure\":\n return figureNode(el);\n default:\n return null;\n }\n}\n\n/**\n * Content nodes inside a container that is not itself a block - a wrapper\n * within one, reached from `childContent`. Same descend/skip rule as the\n * document walk, minus headings: a heading inside a list item does not open a\n * section, and mdast drops it the same way.\n */\nfunction contentIn(parent: ParentNode): ContentNode[] {\n const out: ContentNode[] = [];\n for (const child of parent.childNodes) {\n if (!defaultTreeAdapter.isElementNode(child)) continue;\n const tag = tagOf(child);\n const role = roleOf(child, tag);\n if (role === \"heading\" || role === \"opaque\") continue;\n if (role === \"content\") {\n const node = toContentNode(child, tag);\n if (node) out.push(node);\n continue;\n }\n out.push(...contentIn(child));\n }\n return out;\n}\n\n/**\n * Walk the document into ordered blocks.\n *\n * Structure comes from heading *levels* only. Explicit `<section>` nesting is\n * deliberately ignored, and `<section>` is just another container:\n *\n * - `sectionize` already derives nesting from heading level for every format.\n * Honoring `<section>` would mean a second nesting mechanism living in this\n * file, plus a rule for reconciling the two whenever a page's element\n * nesting and its heading levels disagree - which they routinely do, because\n * `<section>` is optional and is as often a layout wrapper\n * (`<section class=\"hero\">`) as a semantic one.\n * - The cross-format promise is that one template produces the same findings\n * on a page and its Markdown, AsciiDoc, or reST twin. Those formats have\n * nothing but heading level, so deriving HTML's structure from anything else\n * would let identical headings nest differently per format.\n * - Where `<section>` nesting agrees with the headings - which is the whole\n * point of writing it - honoring it changes nothing. It could only ever\n * matter when it disagrees, and there the headings are what the reader sees.\n */\nfunction walk(parent: ParentNode, out: Fragment[], ids: HeadingIds): void {\n for (const child of parent.childNodes) {\n if (!defaultTreeAdapter.isElementNode(child)) continue;\n const tag = tagOf(child);\n const role = roleOf(child, tag);\n\n if (role === \"heading\") {\n const id = ids.claim(child);\n out.push({\n type: \"heading\",\n level: HEADING_LEVELS.get(tag) ?? 1,\n // The self-permalink is dropped from the title as it is from the links:\n // Sphinx's `¶` is a widget, and \"Install the SDK¶\" is no reader's title.\n title: flatText(child, id !== undefined ? `#${id}` : undefined),\n position: positionOf(child),\n ...(id !== undefined ? { id } : {}),\n });\n continue;\n }\n\n if (role === \"content\") {\n const node = toContentNode(child, tag);\n if (node) out.push({ type: \"content\", node });\n continue;\n }\n\n if (role === \"opaque\") continue;\n\n if (ID_CARRIERS.has(tag)) {\n ids.enter(child);\n walk(child, out, ids);\n ids.leave();\n continue;\n }\n walk(child, out, ids);\n }\n}\n\n/** Elements whose `id` the first heading inside them inherits. */\nconst ID_CARRIERS = new Set([\"section\", \"article\"]);\n\n/**\n * Which id each heading answers to.\n *\n * A heading's own `id` first. Failing that, the `id` of the nearest enclosing\n * `<section>`/`<article>` - the shape Sphinx and a hand-written page both\n * produce, `<section id=\"install\"><h2>Install</h2>` - but only for the first\n * heading inside it, since the id names the section and a later sibling\n * heading is not that section's title. Every enclosing carrier is spent by\n * that first heading, nested or not, so an outer one cannot pass its id to a\n * heading that follows an inner one.\n */\nclass HeadingIds {\n private readonly open: { id: string | undefined; spent: boolean }[] = [];\n readonly byHeading = new Map<Element, string>();\n\n enter(el: Element): void {\n this.open.push({ id: attrOf(el, \"id\"), spent: false });\n }\n\n leave(): void {\n this.open.pop();\n }\n\n claim(heading: Element): string | undefined {\n const nearest = this.open.at(-1);\n const inherited = nearest && !nearest.spent ? nearest.id : undefined;\n for (const carrier of this.open) carrier.spent = true;\n const id = attrOf(heading, \"id\") ?? inherited;\n if (id !== undefined) this.byHeading.set(heading, id);\n return id;\n }\n}\n\n/**\n * Every `<a href>` and `<area href>`, in document order - and nothing else\n * that carries an `href`. `<link rel=\"stylesheet\">` and `<base>` name\n * resources and a URL base, not places a reader can go.\n *\n * A heading's self-permalink is left out: Sphinx, MkDocs and Docusaurus append\n * `<a href=\"#install\">¶</a>` to every heading, and a graph that kept them would\n * give each section an edge to itself. Only an exact `#<that heading's id>` is\n * dropped; a heading linking anywhere else keeps the link. Only an `<a>`\n * inside the heading is checked: a permalink placed beside the heading, as a\n * sibling, is kept as a link to its own section.\n */\nfunction collectLinks(\n parent: ParentNode,\n ids: Map<Element, string>,\n heading: string | undefined,\n out: DocumentTree[\"links\"],\n): void {\n for (const child of parent.childNodes) {\n if (!defaultTreeAdapter.isElementNode(child)) continue;\n const tag = tagOf(child);\n if (tag === \"a\" || tag === \"area\") {\n const href = attrOf(child, \"href\");\n const permalink = heading !== undefined && href === `#${heading}`;\n if (href !== undefined && !permalink) out.push({ target: href, position: positionOf(child) });\n }\n collectLinks(child, ids, HEADING_LEVELS.has(tag) ? ids.get(child) : heading, out);\n }\n}\n\n/** End of the document, for closing the final sections. */\nfunction documentEnd(content: string): Position[\"end\"] {\n const lines = content.split(\"\\n\");\n const last = lines[lines.length - 1] ?? \"\";\n return { line: lines.length, column: last.length + 1, offset: content.length };\n}\n\n/**\n * An HTML page's metadata, from both places it can be.\n *\n * `extractFrontmatter(content, \"html\")` - the call the Markdown parser makes -\n * turns out to read *only* a fenced `---`/`+++`/`;;;` block; the `format`\n * argument is a label on the result, not a dispatch key. On an ordinary HTML\n * page it returns `{present: false, data: {}}`, which would leave\n * `type: how-to` in a `<meta>` tag invisible and every `.html` file unrouted.\n *\n * The `<meta>` reading lives in docmeta's *extractor* registry instead, reached\n * by extension. So both are asked, and the results merged. That keeps docmeta\n * the single source of truth for metadata - including its `<title>` lift and\n * its YAML-scalar coercion of attribute values, so `content=\"[a, b]\"` is a list\n * here exactly as it would be in frontmatter - rather than growing a second\n * `<meta>` convention in this repository.\n *\n * A fenced block wins on a key collision: it is authored at the top of the\n * source file, and it is what every sibling format reads. The two coexist\n * rarely enough that the tie-break is a formality.\n *\n * The cost is that docmeta parses the document a second time. Re-reading\n * `<meta>` off the tree already in hand would avoid it and duplicate the\n * convention; the ADR's \"docmeta is the single source of truth for frontmatter\"\n * is worth one extra parse of a file we are already reading from disk.\n */\nfunction metadataOf(\n content: string,\n filePath: string,\n doc: DefaultTreeAdapterTypes.Document,\n): { frontmatter: Record<string, unknown> | null; position: Position | null } {\n const fenced = extractFrontmatter(content, \"html\");\n const extractor = extractorForExtension(\".html\");\n const headMeta = extractor\n ? extractor.extract(content, filePath)\n : { present: false, data: {} as Record<string, unknown> };\n\n if (!fenced.present && !headMeta.present) return { frontmatter: null, position: null };\n\n const frontmatter = { ...headMeta.data, ...fenced.data };\n\n // Anchor on whichever block the values actually came from. `<head>` is an\n // HTML document's frontmatter: it is where `<title>` and every `<meta>` sit,\n // and a finding about the page's metadata belongs there.\n if (fenced.present) return { frontmatter, position: fencedPosition(content) };\n\n // A `<head>` parse5 synthesized carries no source location. That happens\n // whenever anything precedes `<html>` - a BOM is the common case - and it\n // used to yield a null position, which silently switched off the synthetic\n // frontmatter title: `withMetadataTitle` bails when the position is null, so\n // the document lost its top-level section and every doctype template\n // misaligned against it. The metadata is real either way, so fall back to the\n // top of the file rather than disowning it.\n const head = findHead(doc);\n return {\n frontmatter,\n position: head?.sourceCodeLocation ? positionOf(head) : origin(),\n };\n}\n\n/** Zero-width span at the top of the file, for metadata with no located block. */\nfunction origin(): Position {\n return {\n start: { line: 1, column: 1, offset: 0 },\n end: { line: 1, column: 1, offset: 0 },\n };\n}\n\n/** The document's `<head>`, when the source actually wrote one. */\nfunction findHead(doc: DefaultTreeAdapterTypes.Document): Element | undefined {\n for (const child of doc.childNodes) {\n if (!defaultTreeAdapter.isElementNode(child)) continue;\n if (tagOf(child) === \"html\") return firstElementChild(child, \"head\");\n }\n return undefined;\n}\n\nfunction parseHtml(content: string, filePath: string): DocumentTree {\n const doc = parse(content, { sourceCodeLocationInfo: true });\n const fragments: Fragment[] = [];\n const ids = new HeadingIds();\n walk(doc, fragments, ids);\n const links: DocumentTree[\"links\"] = [];\n collectLinks(doc, ids.byHeading, undefined, links);\n\n const { frontmatter, position } = metadataOf(content, filePath, doc);\n\n return {\n format: \"html\",\n filePath,\n frontmatter,\n frontmatterPosition: position,\n sections: sectionize(\n withMetadataTitle(fragments, frontmatter, position),\n documentEnd(content),\n ),\n links,\n };\n}\n\nexport const htmlParser: DocumentParser = {\n name: \"html\",\n label: \"HTML\",\n kinds: [\n \"paragraph\",\n \"codeBlock\",\n \"list\",\n \"listItem\",\n \"table\",\n \"tableRow\",\n \"tableCell\",\n \"admonition\",\n \"image\",\n \"blockquote\",\n \"definitionList\",\n \"definitionItem\",\n ],\n extensions: [\".html\", \".htm\"],\n parse: parseHtml,\n};\n","/**\n * reStructuredText -> generic blocks.\n *\n * Unlike its siblings this parser has no AST library under it. There is no\n * usable reStructuredText parser for JavaScript, so this reads the source\n * directly: a line scanner that answers one question - what sections does this\n * document have, and what content is in each - and then hands `sectionize` the\n * same `Fragment[]` every other format produces.\n *\n * ## Section levels\n *\n * RST has no fixed heading hierarchy. A title is a line underlined, and\n * optionally also overlined, by a run of punctuation at least as long as the\n * title. Which *level* an adornment style means is discovered, not fixed:\n *\n * \"Rather than imposing a fixed number and order of section title adornment\n * styles, the order enforced will be the order as encountered.\"\n * - the reStructuredText spec, \"Sections\"\n *\n * So the first style seen is level 1, the next new style level 2, and so on -\n * `===` then `+++` then `---` is a perfectly ordinary document, and a\n * hardcoded character-to-level table would get it wrong. The spec also makes\n * over-and-underlined styles distinct from underline-only ones using the same\n * character, so the style key carries both facts (`over:=` vs `under:=`).\n *\n * Levels are clamped to 6, because `SectionNode.level` is documented 1-6; a\n * document with seven adornment styles is beyond what the templates model.\n *\n * ## What this deliberately does not handle\n *\n * This is a structural scanner, not docutils. It does not implement, and\n * silently ignores:\n *\n * - **Substitutions** (`|name|` definitions and references) - a reference is\n * flattened to its bare name, a definition is skipped with other directives.\n * - **Includes** (`.. include::`) - the referenced file is never read, so\n * sections it would contribute are invisible.\n * - **Transitions** (a lone adornment run between paragraphs) - skipped, like\n * Markdown thematic breaks.\n * - **Option lists** and **line blocks** (`|`) - skipped, not mapped onto\n * anything. **Definition lists** are mapped: a term line followed by an\n * indented definition becomes a `definitionList`/`definitionItem` pair,\n * and consecutive pairs group into one list the way blank-separated bullet\n * items do.\n * - **Doctest blocks** (`>>>`) - recognised so they are not mis-read as prose,\n * but skipped rather than emitted as `codeBlock`.\n * - **Tables** - grid (`+---+`), simple (`=== ===`), `list-table`, and\n * `csv-table` all become `table` nodes. Grid and simple tables take their\n * columns from the border itself, so a spanning cell (a row border that\n * omits one `+`, or a simple-table row that straddles a column gap) is read\n * as if it were not spanned - the rectangular case, not the general grid\n * grammar. A simple table's body is one row per physical line; only its\n * header, if it has one, merges multiple lines into one row. `list-table`\n * and `csv-table` carry a header row only when `:header-rows:` (both) or\n * `:header:` (`csv-table`) says so - without one, the table has real rows\n * and no header, which is the honest answer. A `csv-table`'s external\n * `:file:`/`:url:` source is never read, the same call `include` gets.\n * - **Block quotes** (an indented block with no `::` ahead of it) - mapped to\n * `blockquote`, its own content parsed the same way a list item's is.\n * - **Quoted literal blocks** (an unindented literal block quoted with\n * punctuation) - not recognised; read as prose.\n * - **Enumerator styles beyond `1.`/`1)`/`#.`/`#)`** - alphabetic and Roman\n * enumerators (`a.`, `iv.`) and the parenthesised `(1)` form are read as\n * prose. They are ambiguous without docutils' second-item confirmation:\n * `A. Smith wrote this` is a sentence, not a list.\n * - **Roles and inline markup** beyond a regex flattening - `flattenInline`\n * strips the common constructs; it does not implement inline parsing, does\n * not process `\\` escapes, and leaves trailing reference underscores alone\n * (stripping them would eat `snake_case`).\n * - **Tab expansion** in indentation - a tab counts as one column, where\n * docutils expands to the next multiple of eight.\n * - **East Asian width** - adornment length is compared against the title's\n * code-point count, where the spec compares display columns.\n * - **Document title promotion** - docutils promotes a lone top-level section\n * to the document title. Here it stays a level-1 section, which is what the\n * doctype templates model (a title with its subsections hanging under it).\n * - **Directive options and content semantics beyond what is listed above** -\n * `code-block`/`code`/`sourcecode` become `codeBlock`; `note`, `tip`,\n * `important`, `caution`, `warning`, and `danger` become `admonition` with\n * that word as `variant`; `image` and `figure` become `image`; `list-table`\n * and `csv-table` become `table`. `attention`, `hint`, `error`, and the\n * generic `admonition` directive also become `admonition`, but with no\n * `variant` at all - `AdmonitionNode.variant` has no six-value member for\n * them, and inventing an equivalence (`hint` as `tip`, `error` as `danger`)\n * is exactly what this parser does not do. A plain count rule still counts\n * them; a `variant:` rule reports them as a mismatch instead of a false\n * match. Every other directive is skipped whole.\n * - **Anything an unterminated fenced block would need** - a *complete* fenced\n * front matter block is cut from the body before scanning, because `---`\n * reads as a transition and the YAML under it as prose. An unterminated one\n * is not front matter, and is scanned as the RST it literally is.\n *\n * One judgement call is worth stating plainly. The spec requires an adornment\n * run to extend \"at least as far as the right edge of the title text\", and\n * that is what is enforced here: a shorter run is not a section title, and the\n * line becomes a paragraph. docutils the implementation is more forgiving - it\n * reports \"Title underline too short\" and recovers - but taking the strict\n * reading is what keeps this parser agreeing with `docmeta`'s RST extractor,\n * which applies the same rule to the document title.\n */\nimport { extractFrontmatter, extractorForExtension, locateFrontmatter } from \"../../meta/index.js\";\nimport type {\n AdmonitionNode,\n ContentNode,\n DefinitionItemNode,\n DocumentParser,\n DocumentTree,\n ListItemNode,\n ListNode,\n Point,\n Position,\n TableCellNode,\n TableNode,\n TableRowNode,\n} from \"../types.js\";\nimport type { Fragment } from \"./sectionize.js\";\nimport { sectionize } from \"./sectionize.js\";\nimport {\n fencedPosition,\n withMetadataTitle as withFrontmatterTitle,\n withoutFence,\n} from \"./metadata.js\";\n\n/** Every character the spec allows as title adornment. */\nconst ADORNMENT_CHARS = new Set(\n \"!\\\"#$%&'()*+,-./:;<=>?@[\\\\]^_`{|}~\".split(\"\"),\n);\n\n/** Explicit markup: a directive, comment, target, or substitution definition. */\nconst EXPLICIT = /^[ \\t]*\\.\\.(?:[ \\t]|$)/;\n/** A directive with a parseable name, e.g. `.. code-block:: python`. */\nconst DIRECTIVE = /^([ \\t]*)\\.\\.[ \\t]+([\\w.+:-]+)::[ \\t]*(.*)$/;\n/** Directives that carry a literal block, with the language as the argument. */\nconst CODE_DIRECTIVES = new Set([\"code\", \"code-block\", \"sourcecode\"]);\n/** Admonition directives that name one of the six variants directly. */\nconst ADMONITION_VARIANTS = new Map<string, AdmonitionNode[\"variant\"]>([\n [\"note\", \"note\"],\n [\"tip\", \"tip\"],\n [\"important\", \"important\"],\n [\"caution\", \"caution\"],\n [\"warning\", \"warning\"],\n [\"danger\", \"danger\"],\n]);\n/**\n * Every admonition directive this parser reads, variant-naming or not.\n * `attention`, `hint`, `error`, and the generic `admonition` directive still\n * become an `admonition` node - just with no `variant`, since none of the six\n * is honestly theirs. See the file header.\n */\nconst ADMONITION_DIRECTIVES = new Set([\n ...ADMONITION_VARIANTS.keys(),\n \"attention\",\n \"hint\",\n \"error\",\n \"admonition\",\n]);\n/** A field-list entry: `:name:` or `:name: value`. */\nconst FIELD = /^[ \\t]*:[^:\\s][^:]*:(?:[ \\t]|$)/;\n/** A directive option inside a directive body, e.g. `:linenos:`. */\nconst OPTION = /^[ \\t]*:[\\w-]+:(?:[ \\t].*)?$/;\n/** A directive option, capturing its key and value: `:header-rows: 1`. */\nconst OPTION_KV = /^[ \\t]*:([\\w-]+):(?:[ \\t]+(.*))?$/;\n/** A bullet-list item. The marker must be followed by whitespace or nothing. */\nconst BULLET = /^([ \\t]*)([*+-])(?:([ \\t]+)(.*))?$/;\n/** An enumerated-list item, arabic or auto (`#`), with a `.` or `)` suffix. */\nconst ENUM = /^([ \\t]*)(\\d+|#)([.)])(?:([ \\t]+)(.*))?$/;\n/** A doctest block. */\nconst DOCTEST = /^[ \\t]*>>>[ \\t]/;\n/** A grid-table border. */\nconst GRID_TABLE = /^[ \\t]*\\+[-=+]+\\+[ \\t]*$/;\n/** A simple-table border: runs of `=` (or `-`, for column spans) with gaps. */\nconst SIMPLE_TABLE = /^[ \\t]*[-=]+(?:[ \\t]+[-=]+)+[ \\t]*$/;\n\n/**\n * The source, indexed by line.\n *\n * `text` is the array the scanner reads, and it is mutable on purpose: list\n * item markers are blanked out of it *in place, space for space*, so an item's\n * body can be scanned by the same code that scans the document body without\n * re-slicing anything. Every column and offset in `starts` stays exact by\n * construction rather than by bookkeeping.\n *\n * Line terminators are stripped, and CRLF is handled here so nothing below has\n * to know about it.\n */\ninterface Source {\n text: string[];\n /** Offset of the first character of each line. */\n starts: number[];\n /** End of the document, for closing the final sections. */\n end: Point;\n}\n\nfunction indexLines(content: string): Source {\n const text: string[] = [];\n const starts: number[] = [];\n let cursor = 0;\n for (;;) {\n starts.push(cursor);\n const nl = content.indexOf(\"\\n\", cursor);\n if (nl === -1) {\n text.push(content.slice(cursor));\n break;\n }\n const hadCr = nl > cursor && content.charCodeAt(nl - 1) === 13;\n text.push(content.slice(cursor, hadCr ? nl - 1 : nl));\n cursor = nl + 1;\n }\n return {\n text,\n starts,\n end: {\n line: text.length,\n column: (text[text.length - 1] ?? \"\").length + 1,\n offset: content.length,\n },\n };\n}\n\n/** Leading whitespace width. Tabs count as one column; see the header. */\nfunction indentOf(line: string): number {\n let i = 0;\n while (i < line.length && (line[i] === \" \" || line[i] === \"\\t\")) i++;\n return i;\n}\n\nfunction isBlank(line: string | undefined): boolean {\n return (line ?? \"\").trim() === \"\";\n}\n\n/**\n * A run of one repeated adornment character starting at column 1, or null.\n *\n * One character counts. docutils only rejects a run for being short when it is\n * also shorter than the title, so `A` over `=` is a section - and a lone\n * punctuation line that underlines nothing is a too-short transition marker,\n * which docutils drops. Skipping it, which is what the caller does with any\n * adornment that started no title, is the same outcome.\n */\nfunction adornmentOf(line: string | undefined): { char: string; length: number } | null {\n const trimmed = (line ?? \"\").replace(/[ \\t]+$/, \"\");\n const char = trimmed[0];\n if (char === undefined || !ADORNMENT_CHARS.has(char)) return null;\n for (let i = 1; i < trimmed.length; i++) {\n if (trimmed[i] !== char) return null;\n }\n return { char, length: trimmed.length };\n}\n\n/**\n * Strip the inline markup a heading or paragraph is likely to carry, so a title\n * matches a template's `heading.const` and a slug reads like the rendered page.\n * A regex pass, not an inline parser - see the header for what it misses.\n */\nfunction flattenInline(text: string): string {\n return text\n .replace(/``([^`]*)``/g, \"$1\")\n .replace(/:[\\w.+:-]+:`([^`]*)`/g, \"$1\")\n .replace(/`([^`]*?)[ \\t]*<[^<>]*>`__?/g, \"$1\")\n .replace(/`([^`]*)`__?/g, \"$1\")\n .replace(/`([^`]*)`/g, \"$1\")\n .replace(/\\*\\*([^*]+)\\*\\*/g, \"$1\")\n .replace(/\\*([^*]+)\\*/g, \"$1\")\n .replace(/\\|([^|\\s][^|]*)\\|/g, \"$1\")\n .trim();\n}\n\n/** Point at the start of `line`'s column `column` (1-based). */\nfunction pointAt(src: Source, line: number, column: number): Point {\n return {\n line: line + 1,\n column,\n offset: (src.starts[line] ?? 0) + column - 1,\n };\n}\n\n/**\n * Span of the source lines `first..last` inclusive, ending just past the last\n * non-whitespace character - the convention mdast uses, so a block's end never\n * runs into the heading that follows it.\n */\nfunction spanOf(src: Source, first: number, last: number, startColumn?: number): Position {\n const firstLine = src.text[first] ?? \"\";\n const lastLine = (src.text[last] ?? \"\").replace(/[ \\t]+$/, \"\");\n return {\n start: pointAt(src, first, startColumn ?? indentOf(firstLine) + 1),\n end: pointAt(src, last, lastLine.length + 1),\n };\n}\n\n/** A section title found at a line, with the adornment style that marked it. */\ninterface TitleHit {\n title: string;\n /** Style key; over-and-underlined is distinct from underline-only. */\n style: string;\n /** First line of the construct (the overline, or the title text). */\n first: number;\n /** Last line of the construct (always the underline). */\n last: number;\n}\n\n/**\n * A section title starting at `line`, or null.\n *\n * Both forms are checked: overline / text / matching underline, and text /\n * underline. The adornment must be at least as long as the title text, and an\n * overline must match its underline in both character and length - what the\n * spec requires, and what `docmeta`'s RST extractor enforces for the doctitle.\n */\nfunction titleAt(src: Source, line: number, limit: number): TitleHit | null {\n const over = adornmentOf(src.text[line]);\n if (over) {\n if (line + 2 >= limit) return null;\n const text = src.text[line + 1] ?? \"\";\n const under = adornmentOf(src.text[line + 2]);\n const title = flattenInline(text);\n if (\n title !== \"\" &&\n adornmentOf(text) === null &&\n under !== null &&\n under.char === over.char &&\n under.length === over.length &&\n over.length >= text.trim().length\n ) {\n return { title, style: `over:${over.char}`, first: line, last: line + 2 };\n }\n // A lone run is a transition, and a mismatched pair is not a title.\n return null;\n }\n\n if (line + 1 >= limit) return null;\n const text = src.text[line] ?? \"\";\n if (text.trim() === \"\" || indentOf(text) > 0) return null;\n const under = adornmentOf(src.text[line + 1]);\n if (under === null || under.length < text.trim().length) return null;\n const title = flattenInline(text);\n if (title === \"\") return null;\n return { title, style: `under:${under.char}`, first: line, last: line + 1 };\n}\n\n/**\n * End of an indented block opened at `from`: the first line at or after `from`\n * whose indent is at or below `base` and which is not blank. Returns the\n * exclusive end, trimmed of trailing blank lines.\n */\nfunction indentedBlockEnd(src: Source, from: number, to: number, base: number): number {\n let i = from;\n let last = from - 1;\n while (i < to) {\n const line = src.text[i] ?? \"\";\n if (isBlank(line)) {\n i++;\n continue;\n }\n if (indentOf(line) <= base) break;\n last = i;\n i++;\n }\n return last + 1;\n}\n\n/** The lines `from..to` with their common indent removed, joined by newlines. */\nfunction dedent(src: Source, from: number, to: number): string {\n let common = Infinity;\n for (let i = from; i < to; i++) {\n const line = src.text[i] ?? \"\";\n if (!isBlank(line)) common = Math.min(common, indentOf(line));\n }\n if (!Number.isFinite(common)) common = 0;\n const out: string[] = [];\n for (let i = from; i < to; i++) {\n const line = src.text[i] ?? \"\";\n out.push(isBlank(line) ? \"\" : line.slice(common).replace(/[ \\t]+$/, \"\"));\n }\n return out.join(\"\\n\").replace(/\\n+$/, \"\");\n}\n\n/** Last non-blank line in `from..to`, or `from - 1` when there is none. */\nfunction lastContentLine(src: Source, from: number, to: number): number {\n for (let i = to - 1; i >= from; i--) {\n if (!isBlank(src.text[i])) return i;\n }\n return from - 1;\n}\n\n/** Scanner state that outlives one range: the adornment styles seen so far. */\ninterface Levels {\n styles: string[];\n}\n\nfunction levelFor(levels: Levels, style: string): number {\n let index = levels.styles.indexOf(style);\n if (index === -1) {\n levels.styles.push(style);\n index = levels.styles.length - 1;\n }\n return Math.min(index + 1, 6);\n}\n\n/** A directive's `:key: value` option block, read up to the first non-option line. */\nfunction readOptions(\n src: Source,\n from: number,\n to: number,\n): { options: Record<string, string>; next: number } {\n const options: Record<string, string> = {};\n let i = from;\n while (i < to) {\n const match = OPTION_KV.exec(src.text[i] ?? \"\");\n if (!match) break;\n const key = (match[1] ?? \"\").toLowerCase();\n options[key] = (match[2] ?? \"\").trim();\n i++;\n }\n return { options, next: i };\n}\n\n/** First content line of a directive body, after its options and any blank lines. */\nfunction directiveContentStart(src: Source, from: number, to: number): number {\n const { next } = readOptions(src, from, to);\n let start = next;\n while (start < to && isBlank(src.text[start])) start++;\n return start;\n}\n\n/** Index of every `+` in a grid-table border line - the table's column edges. */\nfunction gridColumns(border: string): number[] {\n const cols: number[] = [];\n for (let i = 0; i < border.length; i++) {\n if (border[i] === \"+\") cols.push(i);\n }\n return cols;\n}\n\n/** The substrings a grid-table content line holds between `cols`' column edges. */\nfunction gridCells(line: string, cols: number[]): string[] {\n const cells: string[] = [];\n for (let k = 0; k < cols.length - 1; k++) {\n const start = (cols[k] ?? 0) + 1;\n const end = cols[k + 1] ?? line.length;\n cells.push(line.slice(start, end));\n }\n return cells;\n}\n\n/**\n * A grid table (`+---+---+` borders), read from its top border at `from`.\n *\n * Column edges come from the top border alone, so a row whose own border omits\n * a `+` (a spanning cell) is read as if it were not spanned - see the file\n * header. A row is `header: true` when the border that closes it carries `=`.\n */\nfunction parseGridTable(src: Source, from: number, to: number): { node: TableNode; next: number } {\n let end = from;\n while (end < to && !isBlank(src.text[end])) end++;\n\n const cols = gridColumns(src.text[from] ?? \"\");\n const rows: TableRowNode[] = [];\n let current: number[] = [];\n\n const flush = (header: boolean): void => {\n if (current.length === 0) return;\n const first = current[0] ?? from;\n const last = current[current.length - 1] ?? first;\n const perColumn: string[][] = cols.slice(0, -1).map(() => []);\n for (const lineIdx of current) {\n const cells = gridCells(src.text[lineIdx] ?? \"\", cols);\n cells.forEach((text, idx) => perColumn[idx]?.push(text));\n }\n const cellNodes: TableCellNode[] = perColumn.map((lines) => {\n const text = flattenInline(lines.join(\" \").trim());\n return {\n kind: \"tableCell\",\n position: spanOf(src, first, last),\n text,\n children: text === \"\" ? [] : [{ kind: \"paragraph\", position: spanOf(src, first, last), text }],\n };\n });\n rows.push({\n kind: \"tableRow\",\n header,\n position: spanOf(src, first, last),\n text: cellNodes.map((c) => c.text).join(\" | \"),\n children: cellNodes,\n });\n current = [];\n };\n\n for (let i = from + 1; i < end; i++) {\n const line = src.text[i] ?? \"\";\n if (GRID_TABLE.test(line)) {\n flush(/=/.test(line));\n continue;\n }\n current.push(i);\n }\n flush(false);\n\n const last = lastContentLine(src, from, end);\n return {\n node: {\n kind: \"table\",\n position: spanOf(src, from, Math.max(last, from)),\n text: rows.map((r) => r.text).join(\"\\n\"),\n children: rows,\n },\n next: end,\n };\n}\n\n/** Column spans (`[start, end)`) from a simple-table border's `=`/`-` runs. */\nfunction simpleColumns(border: string): [number, number][] {\n const spans: [number, number][] = [];\n const re = /[-=]+/g;\n let match: RegExpExecArray | null;\n while ((match = re.exec(border)) !== null) {\n spans.push([match.index, match.index + match[0].length]);\n }\n return spans;\n}\n\n/** One simple-table row, built from one or more physical lines over `spans`. */\nfunction simpleRow(\n src: Source,\n lines: number[],\n spans: [number, number][],\n header: boolean,\n): TableRowNode {\n const first = lines[0] ?? 0;\n const last = lines[lines.length - 1] ?? first;\n const perColumn: string[][] = spans.map(() => []);\n for (const lineIdx of lines) {\n const raw = src.text[lineIdx] ?? \"\";\n spans.forEach(([start, endCol], idx) => {\n const isLast = idx === spans.length - 1;\n perColumn[idx]?.push(raw.slice(start, isLast ? raw.length : endCol));\n });\n }\n const cells: TableCellNode[] = perColumn.map((columnLines) => {\n const text = flattenInline(columnLines.join(\" \").trim());\n return {\n kind: \"tableCell\",\n position: spanOf(src, first, last),\n text,\n children: text === \"\" ? [] : [{ kind: \"paragraph\", position: spanOf(src, first, last), text }],\n };\n });\n return {\n kind: \"tableRow\",\n header,\n position: spanOf(src, first, last),\n text: cells.map((c) => c.text).join(\" | \"),\n children: cells,\n };\n}\n\n/**\n * A simple table (`=== ===` rules), read from its top border at `from`.\n *\n * One physical line is one row, with one exception: every line between the\n * top border and the header separator, if there is one, merges into a single\n * multi-line header row. Without a header separator, the table has no header.\n */\nfunction parseSimpleTable(src: Source, from: number, to: number): { node: TableNode; next: number } {\n let end = from;\n while (end < to && !isBlank(src.text[end])) end++;\n\n const spans = simpleColumns(src.text[from] ?? \"\");\n const borders: number[] = [];\n for (let i = from; i < end; i++) {\n if (SIMPLE_TABLE.test(src.text[i] ?? \"\")) borders.push(i);\n }\n const top = borders[0] ?? from;\n const bottom = borders[borders.length - 1] ?? end - 1;\n const interior = borders.filter((idx) => idx !== top && idx !== bottom);\n const headerSep = interior[0];\n\n const headerLines: number[] = [];\n const bodyLines: number[] = [];\n for (let i = top + 1; i < bottom; i++) {\n if (interior.includes(i)) continue;\n if (headerSep !== undefined && i < headerSep) headerLines.push(i);\n else bodyLines.push(i);\n }\n\n const rows: TableRowNode[] = [];\n if (headerLines.length > 0) rows.push(simpleRow(src, headerLines, spans, true));\n for (const lineIdx of bodyLines) rows.push(simpleRow(src, [lineIdx], spans, false));\n\n const last = lastContentLine(src, from, end);\n return {\n node: {\n kind: \"table\",\n position: spanOf(src, from, Math.max(last, from)),\n text: rows.map((r) => r.text).join(\"\\n\"),\n children: rows,\n },\n next: end,\n };\n}\n\n/**\n * A `csv-table`'s own naive split: comma-delimited, `\"`-quoted fields with\n * `\"\"` as an escaped quote. Not the general CSV grammar, just enough for the\n * directive's inline rows.\n */\nfunction splitCsvLine(line: string): string[] {\n const fields: string[] = [];\n let field = \"\";\n let quoted = false;\n let i = 0;\n while (i < line.length) {\n const ch = line[i];\n // `i < line.length` already guarantees this, but `noUncheckedIndexedAccess`\n // cannot see it, and a `?? \"\"` fallback would silently swallow a real\n // bounds bug instead of ending the scan.\n if (ch === undefined) break;\n if (quoted) {\n if (ch === '\"') {\n if (line[i + 1] === '\"') {\n field += '\"';\n i += 2;\n continue;\n }\n quoted = false;\n i++;\n continue;\n }\n field += ch;\n i++;\n continue;\n }\n if (ch === '\"' && field.trim() === \"\") {\n quoted = true;\n i++;\n continue;\n }\n if (ch === \",\") {\n fields.push(field.trim());\n field = \"\";\n i++;\n continue;\n }\n field += ch;\n i++;\n }\n fields.push(field.trim());\n return fields;\n}\n\n/** One `csv-table` row, from already-split fields. */\nfunction csvRow(src: Source, lineIdx: number, fields: string[], header: boolean): TableRowNode {\n const cells: TableCellNode[] = fields.map((field) => {\n const text = flattenInline(field);\n return {\n kind: \"tableCell\",\n position: spanOf(src, lineIdx, lineIdx),\n text,\n children: text === \"\" ? [] : [{ kind: \"paragraph\", position: spanOf(src, lineIdx, lineIdx), text }],\n };\n });\n return {\n kind: \"tableRow\",\n header,\n position: spanOf(src, lineIdx, lineIdx),\n text: cells.map((c) => c.text).join(\" | \"),\n children: cells,\n };\n}\n\n/**\n * Scan `from..to` at indent `base` into ordered blocks.\n *\n * `headings` is false inside a list item: RST section titles only occur at the\n * document's own indent, and a heading emitted from inside an item would break\n * the fold.\n */\nfunction scanRange(\n src: Source,\n levels: Levels,\n from: number,\n to: number,\n base: number,\n headings: boolean,\n): Fragment[] {\n const fragments: Fragment[] = [];\n const content = (node: ContentNode): void => {\n fragments.push({ type: \"content\", node });\n };\n let i = from;\n\n while (i < to) {\n const line = src.text[i] ?? \"\";\n\n if (isBlank(line)) {\n i++;\n continue;\n }\n\n if (headings) {\n const hit = titleAt(src, i, to);\n if (hit) {\n const id = labelAbove(src, hit.first);\n fragments.push({\n type: \"heading\",\n level: levelFor(levels, hit.style),\n title: hit.title,\n position: spanOf(src, hit.first, hit.last),\n ...(id !== undefined ? { id } : {}),\n });\n i = hit.last + 1;\n continue;\n }\n }\n\n // `::` alone is the expanded form of the literal-block marker, and it also\n // reads as a two-character run of `:`. The marker wins: an adornment of\n // colons could only ever underline a title one or two characters wide.\n if (line.trim() === \"::\") {\n i = readParagraph(src, levels, fragments, i, to, base, headings);\n continue;\n }\n\n // A run of adornment that did not start a title is a transition, or the\n // stray underline of something that was not one. Either way, not content.\n if (adornmentOf(line) !== null) {\n i++;\n continue;\n }\n\n const lineIndent = indentOf(line);\n\n // Explicit markup: a directive, a comment, a target, or a substitution\n // definition. Some directives become a node of their own; every other\n // directive, comment, target, and substitution definition is skipped\n // whole - see the file header for exactly which.\n if (EXPLICIT.test(line)) {\n const bodyEnd = indentedBlockEnd(src, i + 1, to, lineIndent);\n const directive = DIRECTIVE.exec(line);\n const name = directive?.[2]?.toLowerCase();\n\n if (name && CODE_DIRECTIVES.has(name)) {\n const lang = (directive?.[3] ?? \"\").trim();\n // Drop the directive's own options (`:linenos:` and friends) before the\n // body; they are configuration, not code.\n let codeStart = i + 1;\n while (codeStart < bodyEnd && OPTION.test(src.text[codeStart] ?? \"\")) codeStart++;\n while (codeStart < bodyEnd && isBlank(src.text[codeStart])) codeStart++;\n const codeEnd = lastContentLine(src, codeStart, bodyEnd) + 1;\n content({\n kind: \"codeBlock\",\n position: spanOf(src, i, Math.max(codeEnd - 1, i)),\n text: codeStart < codeEnd ? dedent(src, codeStart, codeEnd) : \"\",\n ...(lang ? { language: lang } : {}),\n });\n } else if (name && ADMONITION_DIRECTIVES.has(name)) {\n const variant = ADMONITION_VARIANTS.get(name);\n const start = directiveContentStart(src, i + 1, bodyEnd);\n const children =\n start < bodyEnd\n ? scanRange(src, levels, start, bodyEnd, indentOf(src.text[start] ?? \"\"), false)\n .filter((f): f is Extract<Fragment, { type: \"content\" }> => f.type === \"content\")\n .map((f) => f.node)\n : [];\n const last = lastContentLine(src, i, bodyEnd);\n content({\n kind: \"admonition\",\n position: spanOf(src, i, Math.max(last, i)),\n text: children.map((c) => c.text).join(\"\\n\"),\n ...(variant ? { variant } : {}),\n children,\n });\n } else if (name === \"image\" || name === \"figure\") {\n const url = (directive?.[3] ?? \"\").trim();\n if (url) {\n const { options } = readOptions(src, i + 1, bodyEnd);\n const alt = options[\"alt\"] ?? \"\";\n const last = lastContentLine(src, i, bodyEnd);\n content({\n kind: \"image\",\n position: spanOf(src, i, Math.max(last, i)),\n text: alt,\n url,\n alt,\n });\n }\n } else if (name === \"list-table\") {\n const start = directiveContentStart(src, i + 1, bodyEnd);\n if (start < bodyEnd) {\n const { options } = readOptions(src, i + 1, bodyEnd);\n const headerRows = Number.parseInt(options[\"header-rows\"] ?? \"\", 10) || 0;\n const rowsFragment = scanRange(\n src,\n levels,\n start,\n bodyEnd,\n indentOf(src.text[start] ?? \"\"),\n false,\n ).find(\n (f): f is Extract<Fragment, { type: \"content\" }> =>\n f.type === \"content\" && f.node.kind === \"list\",\n );\n if (rowsFragment && rowsFragment.node.kind === \"list\") {\n const rows: TableRowNode[] = rowsFragment.node.items.map((item, index) => {\n const cellsList = item.children.find((c): c is ListNode => c.kind === \"list\");\n const cells: TableCellNode[] = (cellsList?.items ?? []).map((cellItem) => ({\n kind: \"tableCell\",\n position: cellItem.position,\n text: cellItem.text,\n children: cellItem.children,\n }));\n return {\n kind: \"tableRow\",\n header: index < headerRows,\n position: item.position,\n text: cells.map((c) => c.text).join(\" | \"),\n children: cells,\n };\n });\n const last = lastContentLine(src, i, bodyEnd);\n content({\n kind: \"table\",\n position: spanOf(src, i, Math.max(last, i)),\n text: rows.map((r) => r.text).join(\"\\n\"),\n children: rows,\n });\n }\n }\n } else if (name === \"csv-table\") {\n const { options } = readOptions(src, i + 1, bodyEnd);\n const bodyStart = directiveContentStart(src, i + 1, bodyEnd);\n const rowLines: number[] = [];\n for (let li = bodyStart; li < bodyEnd; li++) {\n if (!isBlank(src.text[li])) rowLines.push(li);\n }\n const headerOption = options[\"header\"];\n if (rowLines.length > 0 || headerOption !== undefined) {\n const headerRows = Number.parseInt(options[\"header-rows\"] ?? \"\", 10) || 0;\n const rows: TableRowNode[] = [];\n if (headerOption !== undefined) {\n rows.push(csvRow(src, i, splitCsvLine(headerOption), true));\n }\n rowLines.forEach((lineIdx, index) => {\n rows.push(csvRow(src, lineIdx, splitCsvLine(src.text[lineIdx] ?? \"\"), index < headerRows));\n });\n const last = lastContentLine(src, i, bodyEnd);\n content({\n kind: \"table\",\n position: spanOf(src, i, Math.max(last, i)),\n text: rows.map((r) => r.text).join(\"\\n\"),\n children: rows,\n });\n }\n }\n i = Math.max(bodyEnd, i + 1);\n continue;\n }\n\n // Field lists (docinfo, and bibliographic fields) are metadata, read\n // separately by `readMetadata`. Never body content.\n if (FIELD.test(line) && lineIndent === base) {\n i = Math.max(indentedBlockEnd(src, i + 1, to, lineIndent), i + 1);\n while (i < to && FIELD.test(src.text[i] ?? \"\") && indentOf(src.text[i] ?? \"\") === base) {\n i = Math.max(indentedBlockEnd(src, i + 1, to, lineIndent), i + 1);\n }\n continue;\n }\n\n if (DOCTEST.test(line)) {\n // Consume the run of non-blank lines the construct occupies.\n let end = i;\n while (end < to && !isBlank(src.text[end])) end++;\n i = end;\n continue;\n }\n\n if (GRID_TABLE.test(line)) {\n const table = parseGridTable(src, i, to);\n content(table.node);\n i = table.next;\n continue;\n }\n\n if (SIMPLE_TABLE.test(line)) {\n const table = parseSimpleTable(src, i, to);\n content(table.node);\n i = table.next;\n continue;\n }\n\n // An indented block with no `::` ahead of it is a block quote. Its own\n // content is parsed the same way a list item's body is.\n if (lineIndent > base) {\n const bqEnd = indentedBlockEnd(src, i, to, base);\n const children = scanRange(src, levels, i, bqEnd, lineIndent, false)\n .filter((f): f is Extract<Fragment, { type: \"content\" }> => f.type === \"content\")\n .map((f) => f.node);\n const last = lastContentLine(src, i, bqEnd);\n content({\n kind: \"blockquote\",\n position: spanOf(src, i, Math.max(last, i)),\n text: children.map((c) => c.text).join(\"\\n\"),\n children,\n });\n i = Math.max(bqEnd, i + 1);\n continue;\n }\n\n const bullet = BULLET.exec(line);\n if (bullet && indentOf(line) === base && bulletHasBody(bullet, src, i, to, base)) {\n const list = parseList(src, levels, i, to, base, false);\n content(list.node);\n i = list.next;\n continue;\n }\n\n const enumerated = ENUM.exec(line);\n if (enumerated && indentOf(line) === base && bulletHasBody(enumerated, src, i, to, base)) {\n const list = parseList(src, levels, i, to, base, true);\n content(list.node);\n i = list.next;\n continue;\n }\n\n // A term whose next line is indented is a definition list, not a paragraph\n // followed by a block quote.\n const next = src.text[i + 1];\n if (i + 1 < to && !isBlank(next) && indentOf(next ?? \"\") > base) {\n const dl = parseDefinitionList(src, levels, i, to, base);\n content(dl.node);\n i = dl.next;\n continue;\n }\n\n i = readParagraph(src, levels, fragments, i, to, base, headings);\n }\n\n return fragments;\n}\n\n/**\n * Does a matched list marker actually open an item?\n *\n * A marker with text after it always does. A bare marker opens one only when an\n * indented block follows, which is what separates an empty list item from a\n * line that merely starts with a hyphen.\n */\nfunction bulletHasBody(\n match: RegExpExecArray,\n src: Source,\n line: number,\n to: number,\n base: number,\n): boolean {\n // The content group is 4 for `BULLET` and 5 for `ENUM`, which has the extra\n // suffix group. Checking both is cheaper than threading the pattern's shape\n // through: only one of the two is ever a content group, and the other is\n // whitespace or undefined.\n if ((match[4] ?? \"\").trim() !== \"\" || (match[5] ?? \"\").trim() !== \"\") return true;\n for (let i = line + 1; i < to; i++) {\n const next = src.text[i] ?? \"\";\n if (isBlank(next)) continue;\n return indentOf(next) > base;\n }\n return false;\n}\n\n/** The marker text and the column its content starts at, for one item line. */\ninterface Marker {\n /** Width of the marker plus the whitespace after it. */\n width: number;\n /** Indent the item's body sits at. */\n contentIndent: number;\n}\n\nfunction markerOf(match: RegExpExecArray, ordered: boolean): Marker {\n const indent = (match[1] ?? \"\").length;\n const marker = ordered ? `${match[2] ?? \"\"}${match[3] ?? \"\"}` : (match[2] ?? \"\");\n const gap = (ordered ? match[4] : match[3]) ?? \" \";\n return { width: marker.length + gap.length, contentIndent: indent + marker.length + gap.length };\n}\n\n/**\n * Parse the run of list items starting at `from`.\n *\n * Each item's marker is blanked out of `src.text` - replaced by exactly as many\n * spaces - so the item body is an ordinary indented block that `scanRange` can\n * read with no special case. Offsets and columns are untouched by construction.\n */\nfunction parseList(\n src: Source,\n levels: Levels,\n from: number,\n to: number,\n base: number,\n ordered: boolean,\n): { node: ContentNode; next: number } {\n const pattern = ordered ? ENUM : BULLET;\n // `parseList` is only entered on a line that already matched, so the miss\n // falls through to the same defaults a matched line with no marker group\n // would have taken.\n const firstMatch = pattern.exec(src.text[from] ?? \"\");\n const markerChar = ordered ? (firstMatch?.[3] ?? \".\") : (firstMatch?.[2] ?? \"*\");\n const items: ListItemNode[] = [];\n // Where the list ends, excluding the blank lines between items - those belong\n // to whatever follows, so a list before a heading does not swallow the gap.\n let end = from;\n let i = from;\n\n while (i < to) {\n // Items may be separated by blank lines; the list ends at the first\n // non-blank line that is not another item at this indent.\n let start = i;\n while (start < to && isBlank(src.text[start])) start++;\n if (start >= to) break;\n\n const line = src.text[start] ?? \"\";\n if (indentOf(line) !== base) break;\n const match = pattern.exec(line);\n if (!match) break;\n // docutils ends a list when the marker style changes; so do we. The\n // defaults match `markerChar`'s above: a different fallback here would end\n // the list after its first item rather than read the style as unchanged.\n const thisChar = ordered ? (match[3] ?? \".\") : (match[2] ?? \"*\");\n if (thisChar !== markerChar) break;\n if (!bulletHasBody(match, src, start, to, base)) break;\n\n const marker = markerOf(match, ordered);\n // Blank the marker in place. Same length, so `starts` stays exact.\n src.text[start] = \" \".repeat(marker.contentIndent) + line.slice(marker.contentIndent);\n\n const bodyEnd = Math.max(indentedBlockEnd(src, start + 1, to, base), start + 1);\n const last = lastContentLine(src, start, bodyEnd);\n const children = scanRange(src, levels, start, bodyEnd, marker.contentIndent, false)\n .filter((b): b is Extract<Fragment, { type: \"content\" }> => b.type === \"content\")\n .map((b) => b.node);\n\n items.push({\n kind: \"listItem\",\n position: spanOf(src, start, Math.max(last, start), base + 1),\n text: children.map((c) => c.text).join(\"\\n\"),\n children,\n });\n i = bodyEnd;\n end = bodyEnd;\n }\n\n const last = lastContentLine(src, from, end);\n return {\n node: {\n kind: \"list\",\n position: spanOf(src, from, Math.max(last, from), base + 1),\n text: items.map((item) => item.text).join(\"\\n\"),\n ordered,\n items,\n },\n next: Math.max(i, from + 1),\n };\n}\n\n/**\n * A run of term/definition pairs starting at `from`: an unindented term line\n * immediately followed by an indented definition. Items may be separated by\n * blank lines, the same tolerance `parseList` gives bulleted items.\n */\nfunction parseDefinitionList(\n src: Source,\n levels: Levels,\n from: number,\n to: number,\n base: number,\n): { node: ContentNode; next: number } {\n const items: DefinitionItemNode[] = [];\n let i = from;\n let end = from;\n\n while (i < to) {\n let start = i;\n while (start < to && isBlank(src.text[start])) start++;\n if (start >= to) break;\n\n const line = src.text[start] ?? \"\";\n if (indentOf(line) !== base) break;\n const next = src.text[start + 1];\n if (start + 1 >= to || isBlank(next) || indentOf(next ?? \"\") <= base) break;\n\n const term = flattenInline(line.trim());\n const defStart = start + 1;\n const defIndent = indentOf(next ?? \"\");\n const defEnd = Math.max(indentedBlockEnd(src, defStart, to, base), defStart);\n const last = lastContentLine(src, start, defEnd);\n const definition = scanRange(src, levels, defStart, defEnd, defIndent, false)\n .filter((f): f is Extract<Fragment, { type: \"content\" }> => f.type === \"content\")\n .map((f) => f.node);\n\n items.push({\n kind: \"definitionItem\",\n position: spanOf(src, start, Math.max(last, start)),\n text: [term, ...definition.map((d) => d.text)].join(\"\\n\"),\n term,\n definition,\n });\n i = defEnd;\n end = defEnd;\n }\n\n const last = lastContentLine(src, from, end);\n return {\n node: {\n kind: \"definitionList\",\n position: spanOf(src, from, Math.max(last, from)),\n text: items.map((item) => item.text).join(\"\\n\"),\n children: items,\n },\n next: Math.max(i, from + 1),\n };\n}\n\n/**\n * Read one paragraph, and the literal block it may introduce.\n *\n * A paragraph ending in `::` opens a literal block: the indented block after\n * it becomes `code`, and the `::` is stripped from the paragraph's own text the\n * way docutils strips it - removed entirely when the paragraph is only `::` or\n * when whitespace precedes it, and collapsed to one colon otherwise.\n */\nfunction readParagraph(\n src: Source,\n levels: Levels,\n fragments: Fragment[],\n from: number,\n to: number,\n base: number,\n headings: boolean,\n): number {\n let end = from;\n while (end < to) {\n const line = src.text[end] ?? \"\";\n if (isBlank(line)) break;\n if (end > from) {\n // A line whose successor underlines it ends the paragraph and starts a\n // section, and a construct of any other kind ends it too.\n if (headings && titleAt(src, end, to)) break;\n if (adornmentOf(line) !== null) break;\n if (EXPLICIT.test(line)) break;\n if (indentOf(line) !== base) break;\n if (GRID_TABLE.test(line) || SIMPLE_TABLE.test(line) || DOCTEST.test(line)) break;\n }\n end++;\n }\n\n const rawText = flattenInline(\n src.text\n .slice(from, end)\n .map((l) => l.trim())\n .join(\"\\n\"),\n );\n const literal = /::$/.test(rawText);\n const text = !literal\n ? rawText\n : rawText === \"::\"\n ? \"\" // A paragraph that is only `::` is the marker, and nothing else.\n : rawText.replace(/(\\s*)::$/, (_m, space: string) => (space === \"\" ? \":\" : \"\"));\n\n if (text.trim() !== \"\") {\n fragments.push({\n type: \"content\",\n node: { kind: \"paragraph\", position: spanOf(src, from, end - 1), text },\n });\n }\n\n if (!literal) return end;\n\n // The literal block is the next indented block, after any blank lines.\n let start = end;\n while (start < to && isBlank(src.text[start])) start++;\n if (start >= to || indentOf(src.text[start] ?? \"\") <= base) return end;\n\n const blockEnd = indentedBlockEnd(src, start, to, base);\n const last = lastContentLine(src, start, blockEnd);\n fragments.push({\n type: \"content\",\n node: {\n kind: \"codeBlock\",\n position: spanOf(src, start, Math.max(last, start)),\n text: dedent(src, start, blockEnd),\n },\n });\n return Math.max(blockEnd, end);\n}\n\n// ---------------------------------------------------------------------------\n// Links and section labels\n// ---------------------------------------------------------------------------\n\n/** A hyperlink target: `.. _name: uri`, `.. _name:`, or a backquoted phrase name. */\nconst TARGET = /^[ \\t]*\\.\\.[ \\t]+_(?:`([^`]+)`|([^:`]+)):(?:[ \\t]+(.*?))?[ \\t]*$/;\n\n/**\n * The hyperlink target defined at `line`, or null. `uri` is empty for an\n * internal target - a label for whatever follows it - and otherwise joins the\n * indented lines a long URI may continue onto, whitespace removed, as docutils\n * does. An anonymous target (`.. __: uri`) names nothing and is not one.\n */\nfunction targetAt(src: Source, line: number): { name: string; uri: string } | null {\n const match = TARGET.exec(src.text[line] ?? \"\");\n const name = (match?.[1] ?? match?.[2] ?? \"\").trim();\n if (!match || name === \"\" || name === \"_\") return null;\n let uri = match[3] ?? \"\";\n const base = indentOf(src.text[line] ?? \"\");\n for (let next = line + 1; next < src.text.length; next++) {\n const text = src.text[next] ?? \"\";\n if (isBlank(text) || indentOf(text) <= base) break;\n uri += text;\n }\n return { name, uri: uri.replace(/\\s+/g, \"\") };\n}\n\n/** Reference names match case-insensitively, with whitespace collapsed. */\nconst refName = (name: string): string => name.replace(/\\s+/g, \" \").trim().toLowerCase();\n\n/**\n * The label of an internal target directly above a section title - blank lines\n * between allowed, anything else not - which is how reST gives a section the\n * anchor `:ref:` and `label_` resolve to.\n */\nfunction labelAbove(src: Source, first: number): string | undefined {\n let line = first - 1;\n while (line >= 0 && isBlank(src.text[line])) line--;\n const target = line >= 0 ? targetAt(src, line) : null;\n return target && target.uri === \"\" ? target.name : undefined;\n}\n\n/** Every source line a code block covers, 1-based, nested blocks included. */\nfunction codeLines(\n nodes: readonly (ContentNode | ListItemNode | TableRowNode | TableCellNode | DefinitionItemNode)[],\n out: Set<number>,\n): Set<number> {\n for (const node of nodes) {\n if (node.kind === \"codeBlock\") {\n for (let l = node.position.start.line; l <= node.position.end.line; l++) out.add(l);\n } else if (node.kind === \"list\") {\n codeLines(node.items, out);\n } else if (node.kind === \"definitionItem\") {\n codeLines(node.definition, out);\n } else if (\"children\" in node) {\n codeLines(node.children, out);\n }\n }\n return out;\n}\n\n/** Replace a match with spaces, so later patterns cannot see it and columns hold. */\nconst blank = (text: string, index: number, length: number): string =>\n text.slice(0, index) + \" \".repeat(length) + text.slice(index + length);\n\nconst INLINE_LITERAL = /``.+?``/g;\nconst DOC_ROLE = /:doc:`([^`]*)`/g;\nconst ROLE = /:[\\w.+:-]+:`[^`]*`/g;\nconst EMBEDDED = /`([^`<]*?)\\s*<([^<>`]+)>`(__?)/g;\nconst PHRASE_REF = /`([^`]+)`_(?!_)/g;\n/** A simple reference name: alphanumerics joined by single `-_.:+`. */\nconst SIMPLE_REF = /(?<![\\w\\\\])([A-Za-z0-9]+(?:[-_.:+][A-Za-z0-9]+)*)_(?!\\w)/g;\n\n/**\n * The document's link targets, in document order.\n *\n * Three constructs are links: an embedded URI (`` `text <uri>`_ ``, or `__`\n * for an anonymous one), a named reference (`name_`, `` `two words`_ ``)\n * resolved against this document's own `.. _name: uri` targets, and a Sphinx\n * `:doc:` role. A reference to a name the document never defines yields\n * nothing - it may be a section label, or a typo, and neither has a target to\n * report. `:ref:` yields nothing either: its label resolves across a whole\n * Sphinx project, which one file cannot see.\n *\n * A line scan of its own, over every line but a code block's, rather than\n * part of `scanRange`: a link counts wherever it is, inside a directive this\n * parser skips (`seealso`) as much as in a paragraph. Like the rest of this\n * file it is not docutils. A reference split across two lines is missed, and\n * standalone URLs are not collected.\n */\nfunction collectLinks(src: Source, from: number, code: Set<number>): DocumentTree[\"links\"] {\n const targets = new Map<string, string>();\n for (let line = from; line < src.text.length; line++) {\n const target = targetAt(src, line);\n if (target && target.uri !== \"\") targets.set(refName(target.name), target.uri);\n }\n // An embedded URI with a single `_` also defines its text as a name.\n for (let line = from; line < src.text.length; line++) {\n for (const m of (src.text[line] ?? \"\").matchAll(EMBEDDED)) {\n const name = refName(m[1] ?? \"\");\n if (m[3] === \"_\" && name !== \"\" && !targets.has(name)) {\n targets.set(name, (m[2] ?? \"\").replace(/\\s+/g, \"\"));\n }\n }\n }\n // A value ending in `_` (`<Python_>`, `.. _home: Python_`) names another\n // target rather than being a URI, so the chain is followed to a URI. One\n // that never reaches one, a cycle included, resolves to nothing.\n const resolve = (name: string): string | undefined => {\n let uri = targets.get(refName(name));\n for (let hops = 0; uri?.endsWith(\"_\") && hops < targets.size; hops++) {\n uri = targets.get(refName(uri.slice(0, -1)));\n }\n return uri?.endsWith(\"_\") ? undefined : uri;\n };\n\n const links: DocumentTree[\"links\"] = [];\n for (let line = from; line < src.text.length; line++) {\n let text = src.text[line] ?? \"\";\n if (code.has(line + 1) || TARGET.test(text)) continue;\n const hits: { column: number; length: number; target: string }[] = [];\n // Each construct is blanked once read, so a later, looser pattern cannot\n // read it again: `:ref:` text never becomes a phrase reference.\n const take = (pattern: RegExp, toTarget: (m: RegExpExecArray) => string | undefined): void => {\n for (const m of text.matchAll(pattern)) {\n const target = toTarget(m);\n if (target) hits.push({ column: m.index + 1, length: m[0].length, target });\n text = blank(text, m.index, m[0].length);\n }\n };\n take(INLINE_LITERAL, () => undefined);\n take(DOC_ROLE, (m) => {\n const inner = (m[1] ?? \"\").trim();\n return /<([^<>]+)>$/.exec(inner)?.[1]?.trim() ?? inner;\n });\n take(ROLE, () => undefined);\n take(EMBEDDED, (m) => {\n const uri = (m[2] ?? \"\").replace(/\\s+/g, \"\");\n // `<name_>` embeds a reference to another target, not a URI.\n return uri.endsWith(\"_\") ? resolve(uri.slice(0, -1)) : uri;\n });\n take(PHRASE_REF, (m) => resolve(m[1] ?? \"\"));\n take(SIMPLE_REF, (m) => resolve(m[1] ?? \"\"));\n hits.sort((a, b) => a.column - b.column);\n for (const hit of hits) {\n links.push({\n target: hit.target,\n position: {\n start: pointAt(src, line, hit.column),\n end: pointAt(src, line, hit.column + hit.length),\n },\n });\n }\n }\n return links;\n}\n\n/**\n * Span of the native docinfo block: the leading field list, or - when a page\n * carries only a title - the title line docmeta read it from.\n *\n * docmeta reports the block's start line but not its extent, and we are already\n * holding a line index, so the span is cheaper to recover here than to ask for.\n */\nfunction docinfoPosition(src: Source): Position | null {\n const limit = src.text.length;\n let i = 0;\n while (i < limit && isBlank(src.text[i])) i++;\n\n const hit = titleAt(src, i, limit);\n if (hit) i = hit.last + 1;\n while (i < limit && isBlank(src.text[i])) i++;\n\n const fieldStart = i;\n while (i < limit && FIELD.test(src.text[i] ?? \"\") && indentOf(src.text[i] ?? \"\") === 0) {\n i = Math.max(indentedBlockEnd(src, i + 1, limit, 0), i + 1);\n }\n if (i > fieldStart) return spanOf(src, fieldStart, i - 1);\n if (hit) return spanOf(src, hit.first, hit.last);\n return null;\n}\n\ninterface Metadata {\n frontmatter: Record<string, unknown> | null;\n position: Position | null;\n /**\n * First body line, 0-based. Non-zero only for a fenced block, whose lines\n * would otherwise be scanned as prose - `---` as a transition and the YAML\n * under it as a paragraph, which opens an implicit lead section and hands the\n * template's top-level slot the wrong thing. A docinfo field list needs no\n * such cut: it is inside the body, and the scanner skips field lists.\n */\n bodyStart: number;\n}\n\n/**\n * Read the page's metadata, from both places an RST page can put it.\n *\n * `extractFrontmatter(content, \"rst\")` - the call `markdown.ts` makes - reads\n * only a *fenced* block; its format argument is a label copied onto the result,\n * not a dispatch. On its own it would leave every page using the native docinfo\n * field list unrouted, and that field list is how RST authors actually declare\n * `:type: how-to`. The RST-aware reading lives in docmeta's extractor registry,\n * so both are read and merged.\n *\n * A fenced block wins a key collision: it is the author being deliberate about\n * metadata, where a docinfo `title` is often just the document's own heading\n * read a second time. `present` is the OR of the two - the same shape the HTML\n * parser landed on, so the formats stay consistent.\n *\n * That docinfo `title` is worth knowing about. In RST the page title genuinely\n * *is* the first section title, so a page with a title and no fields comes back\n * with non-null `frontmatter` holding just that. Nothing downstream is misled -\n * routing reads `type` and `$template` - and taking docmeta's answer verbatim\n * keeps one source of truth for what a format's metadata is.\n */\nfunction readMetadata(content: string, filePath: string, src: Source): Metadata {\n const fenced = extractFrontmatter(content, \"rst\");\n // Read the docinfo field list from the fence-free remainder: docmeta's reST\n // extractor returns the fence and stops when one is present, so asking it\n // about the whole file would discard `:type:` on any page that has both.\n const native = extractorForExtension(\".rst\")?.extract(\n fenced.present ? withoutFence(content) : content,\n filePath,\n );\n\n if (!fenced.present && !native?.present) {\n return { frontmatter: null, position: null, bodyStart: 0 };\n }\n\n const loc = fenced.present ? locateFrontmatter(content) : null;\n return {\n frontmatter: {\n ...(native?.present ? native.data : {}),\n ...(fenced.present ? fenced.data : {}),\n },\n position: fenced.present ? fencedPosition(content) : docinfoPosition(src),\n // `findIndex` returns -1 when no line starts at or after the closing fence,\n // i.e. the fence is the last thing in the file. `Math.max(-1, 0)` used to\n // launder that into line 0, restarting the scan inside the frontmatter and\n // reading the YAML as body prose - the exact thing `bodyStart` exists to\n // prevent. There is no body in that case, so start past the last line.\n bodyStart: loc\n ? (() => {\n const i = src.starts.findIndex((start) => start >= loc.closeEnd);\n return i === -1 ? src.starts.length : i;\n })()\n : 0,\n };\n}\n\nexport const rstParser: DocumentParser = {\n name: \"rst\",\n label: \"reStructuredText\",\n kinds: [\n \"paragraph\",\n \"codeBlock\",\n \"list\",\n \"listItem\",\n \"table\",\n \"tableRow\",\n \"tableCell\",\n \"admonition\",\n \"image\",\n \"blockquote\",\n \"definitionList\",\n \"definitionItem\",\n ],\n extensions: [\".rst\"],\n parse(content, filePath): DocumentTree {\n const src = indexLines(content);\n // Order is load-bearing: `readMetadata` must run before `scanRange`.\n // `scanRange` blanks consumed list lines in `src.text` in place so a later\n // pass cannot re-read them, and `docinfoPosition` inside `readMetadata`\n // reads those same lines to place the metadata span. Swapped, the docinfo\n // field list is already blank and every metadata position collapses.\n const { frontmatter, position, bodyStart } = readMetadata(content, filePath, src);\n const fragments = scanRange(\n src,\n { styles: [] },\n Math.max(bodyStart, 0),\n src.text.length,\n 0,\n true,\n );\n\n return {\n format: \"rst\",\n filePath,\n frontmatter,\n frontmatterPosition: position,\n sections: sectionize(\n withFrontmatterTitle(fragments, frontmatter, position),\n src.end,\n ),\n links: collectLinks(\n src,\n Math.max(bodyStart, 0),\n codeLines(\n fragments.flatMap((f) => (f.type === \"content\" ? [f.node] : [])),\n new Set(),\n ),\n ),\n };\n },\n};\n","/**\n * XML -> generic blocks, through a declarative vocabulary mapping.\n *\n * ADR 01001 puts XML last \"because structure comes from the document's own\n * element nesting and needs a small per-vocabulary mapping\". This is that\n * mapping, and the reason it exists: XML has no headings. Markdown says `##`,\n * AsciiDoc says `==`, HTML says `<h2>` - one universal rule each. XML says\n * whatever its schema says. DITA nests `<topic>`/`<section>` and titles them\n * with `<title>`; DocBook nests `<chapter>`/`<section>`/`<sect1>` and titles\n * them with `<title>` too, but calls a paragraph `<para>` where DITA calls it\n * `<p>`; a house schema calls them something else again. Hardcoding DITA would\n * make \"the XML parser\" a lie.\n *\n * ## The mapping\n *\n * An `XmlVocabulary` sorts element names into four buckets and says nothing\n * about anything else:\n *\n * - `sections` open a section, titled by the first `titles` element among\n * their children (or inside a `titleWrappers` child, which is\n * how DocBook 5 hides `<title>` in `<info>`).\n * - `transparent` are structural wrappers with no meaning of their own -\n * DITA's `<body>`, `<taskbody>`, `<context>`. The walk passes\n * straight through them at the same level.\n * - `paragraphs` / `code` / `unorderedLists` / `orderedLists` / `listItems` /\n * `tables` / `admonitions` / `images` / `blockquotes` /\n * `definitionLists` are the format-neutral content kinds of\n * `types.ts`. The last five are optional buckets: a vocabulary\n * that leaves one out never emits that kind, same as leaving\n * an entry out of `kinds`.\n * - everything else is **skipped, with its subtree**, exactly as the Markdown\n * parser skips a blockquote. A DITA `<related-links>` is not a paragraph,\n * and its contents must not be counted as one, or `paragraphs: {max: 3}`\n * fails documents a reader would say satisfy it.\n *\n * That last rule is why `transparent` has to exist as its own bucket: without\n * it, skipping the unmapped `<body>` would skip the whole topic.\n *\n * ## Titles that are not elements, and sections that carry none\n *\n * Two more fields, both earned by a DITA map:\n *\n * - `titleAttributes` names attributes that title a section, for the schemas\n * that spell a title as one (`<topicref navtitle=\"Install\"/>`). An attribute\n * has no position of its own, so the heading ends where the start tag does.\n * - `untitledSections` says a `sections` element opens a section even with no\n * title at all. Off by default, because an untitled DITA `<section>` is\n * prose belonging to the topic around it. On for a map, where an entry names\n * its target by `@keyref` or `@href` and lets the referenced topic supply\n * the title, so untitled is the normal case and dropping those entries would\n * flatten the whole table of contents.\n *\n * ## Extending it for a bespoke schema\n *\n * Add one entry to `XML_VOCABULARIES` (or pass your own array to `parseXml`):\n *\n * { name: \"acme\", label: \"Acme Docs\",\n * namespaces: [\"https://acme.example/docs\"], roots: [\"manual\"],\n * sections: [\"manual\", \"chapter\"], titles: [\"heading\"],\n * titleWrappers: [], transparent: [\"content\"],\n * paragraphs: [\"text\"], code: [\"sample\"], codeLangAttributes: [\"lang\"],\n * unorderedLists: [\"bullets\"], orderedLists: [\"steps\"],\n * listItems: [\"item\"] }\n *\n * Tables, admonitions, images, blockquotes and definition lists are five more\n * buckets, all optional - a schema that never names one simply never emits\n * that kind. See each field's own doc comment below for the shape it expects.\n *\n * Nothing else changes: the walk, the levels, the positions, and the fold are\n * vocabulary-independent. This is deliberately not wired to `manni.config.yaml`\n * yet - the shape is the commitment, the config surface is a later decision.\n *\n * ## Which vocabulary a document is in\n *\n * Scored, not guessed: a declared namespace is decisive, then elements only\n * one candidate claims, then the root element name, then the elements they\n * share. That ordering is what settles the ambiguous cases - `<section>`,\n * `<title>` and `<reference>` belong to both built-ins, so a `<section>`-rooted\n * file is decided by whether its prose is in `<p>` or `<para>`. Nothing\n * recognized at all is an error, not an empty tree: see `chooseVocabulary`.\n *\n * ## Levels\n *\n * `sectionize` folds by heading *level*, so nesting is expressed as one: the\n * level is the number of enclosing elements that actually opened a section,\n * plus one. Transparent wrappers do not count, and neither does a section\n * element with no title - an untitled DITA `<section>` is legal, and the honest\n * reading is that it adds no heading and so no level, its content belonging to\n * the section that encloses it. Levels clamp at 6, the range `SectionNode`\n * declares.\n *\n * ## Positions\n *\n * `@xmldom/xmldom` records `lineNumber` (1-based, despite its `index.d.ts`\n * saying \"zero based\") and `columnNumber` (1-based) on every node, pointing at\n * the `<` of an element's start tag and at the first character of a text node.\n * There is no end position. But *every* node carries a start, including the\n * whitespace text nodes between elements, so the exclusive end of an element is\n * the start of the next node in document order - for indented XML that is the\n * character right after `</tag>`, exactly. Only when a node is last all the way\n * up to the root does that fall back to the end of the document, per the\n * house rule for formats whose parser reports no end.\n */\nimport { DOMParser } from \"@xmldom/xmldom\";\nimport type { Element as XmlElement, Node as XmlNode } from \"@xmldom/xmldom\";\nimport { extractorForExtension } from \"../../meta/index.js\";\nimport type {\n AdmonitionNode,\n ContentNode,\n DefinitionItemNode,\n DefinitionListNode,\n DocumentParser,\n DocumentTree,\n ImageNode,\n ListItemNode,\n Point,\n Position,\n TableCellNode,\n TableNode,\n TableRowNode,\n} from \"../types.js\";\nimport { LintError } from \"../types.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport type { Fragment } from \"./sectionize.js\";\nimport { sectionize } from \"./sectionize.js\";\n\n/**\n * One schema's answer to \"what is a section, and what is content?\".\n *\n * Every list is of lowercased local names - the prefix and namespace of an\n * element are not part of the match, so a document that binds DocBook to `db:`\n * maps the same as one that uses the default namespace.\n */\nexport interface XmlVocabulary {\n /** Stable id, used in error messages. */\n name: string;\n /** Human-readable label. */\n label: string;\n /** Namespace URIs that identify this vocabulary outright. */\n namespaces: readonly string[];\n /** Root element names that identify it. */\n roots: readonly string[];\n /** Elements that open a section when they carry a title. */\n sections: readonly string[];\n /** Elements that carry a section's title. */\n titles: readonly string[];\n /**\n * Attributes that carry a section's title when no `titles` element does,\n * first one present wins. A DITA map spells one `<topicref navtitle=\"...\">`.\n */\n titleAttributes?: readonly string[];\n /**\n * Whether a `sections` element with no title of any kind still opens a\n * section. Default false: an untitled container adds no heading, and its\n * content belongs to the section that encloses it.\n */\n untitledSections?: boolean;\n /** Children to look inside for a title (DocBook's `<info>`). */\n titleWrappers: readonly string[];\n /** Structural wrappers: no section, no content, walk through. */\n transparent: readonly string[];\n /** Elements that are one paragraph. */\n paragraphs: readonly string[];\n /** Elements that are one code block. */\n code: readonly string[];\n /** Attributes carrying a code block's language, first one present wins. */\n codeLangAttributes: readonly string[];\n /** Elements that are an unordered list. */\n unorderedLists: readonly string[];\n /** Elements that are an ordered list. */\n orderedLists: readonly string[];\n /** Elements that are one item of a list. */\n listItems: readonly string[];\n\n /** Elements that are a table, CALS-shaped or simple. */\n tables?: readonly string[];\n /** Elements whose direct children are cells: a header row or a body row. */\n tableRows?: readonly string[];\n /** Elements that are one cell of a row. */\n tableCells?: readonly string[];\n /** Wrapper elements whose descendant rows are all header rows (CALS `<thead>`). */\n tableHeaderWrappers?: readonly string[];\n /** Row elements that are inherently a header row on their own (DITA `<sthead>`). */\n tableHeaderRows?: readonly string[];\n\n /** Elements that may be an admonition. */\n admonitions?: readonly string[];\n /**\n * Attribute naming the admonition's variant (DITA's `<note>` `@type`). When\n * absent, an admonition element's own lowercased name is its variant -\n * DocBook's five admonition elements are themselves named `note`, `tip`,\n * `important`, `caution` and `warning`. Either way, a name outside the six\n * `AdmonitionNode` knows produces an admonition with no `variant` set,\n * rather than an invented equivalence - DITA's `restriction` and `fastpath`\n * are real `@type` values this model does not have a word for.\n */\n admonitionVariantAttribute?: string;\n\n /** Elements that are an image, standing alone or wrapping one. */\n images?: readonly string[];\n /**\n * Element carrying the image's own url attribute - itself, for a\n * self-contained image (DITA's `<image href>`), or a descendant found by\n * name (DocBook's `<imagedata fileref>` inside a `<mediaobject>`).\n */\n imageDataElements?: readonly string[];\n /** Attribute on an `imageDataElements` match that carries the url. */\n imageUrlAttribute?: string;\n /** Direct child of an `imageDataElements` match carrying the alt text. */\n imageAltElements?: readonly string[];\n\n /** Elements that are a block quote. */\n blockquotes?: readonly string[];\n\n /** Elements that are a definition list. */\n definitionLists?: readonly string[];\n /** Elements that are one entry, pairing a term with a definition. */\n definitionItems?: readonly string[];\n /** Elements that carry an entry's term(s); more than one join with \", \". */\n definitionTerms?: readonly string[];\n /** Elements that carry an entry's definition body. */\n definitionBodies?: readonly string[];\n\n /**\n * Where a link target is written: an attribute, matched by local name (so\n * `href` also finds DocBook's `xlink:href`), on any of `elements`. `idref`\n * marks an attribute holding a bare id rather than a URL - DocBook's\n * `linkend` - which is emitted as `#<id>`. Read from the whole document,\n * skipped subtrees included, because a DITA `<related-links>` is where a\n * topic keeps most of its links. Not counted when choosing a vocabulary.\n */\n links?: readonly { elements: readonly string[]; attribute: string; idref?: boolean }[];\n /**\n * DITA addressing. A same-scheme href names an element as\n * `file.dita#topicid/elementid`, where the rest of the web would write\n * `file.dita#elementid`, so the fragment is cut to its last segment. Never\n * applied to an href with a scheme, whose fragment means what its site says.\n */\n ditaHrefs?: boolean;\n}\n\n/**\n * DITA. No default namespace to detect on (DITA is conventionally\n * namespace-free, with only `ditaarch:` bound on the root), so recognition\n * leans on the topic types and on `<p>`/`<codeblock>`/`<body>`.\n *\n * `<prereq>`, `<context>`, `<result>` and friends are transparent rather than\n * sections: they are untitled parts of a task body that render as continuous\n * prose, so their paragraphs belong to the task. `<related-links>` and\n * `<prolog>` are in no bucket at all, so they and their contents are skipped -\n * the blockquote rule.\n *\n * A CALS `<table>` and an OASIS `<simpletable>` share one row/cell reading:\n * `<row>`/`<entry>` for the former, `<strow>`/`<stentry>` for the latter. A row\n * inside `<thead>` is a header row (the CALS shape); `<sthead>` is a header row\n * on its own, holding `<stentry>` cells directly rather than wrapping a row.\n */\nconst DITA: XmlVocabulary = {\n name: \"dita\",\n label: \"DITA\",\n namespaces: [],\n roots: [\"dita\", \"topic\", \"concept\", \"task\", \"reference\", \"glossentry\"],\n sections: [\n \"topic\",\n \"concept\",\n \"task\",\n \"reference\",\n \"glossentry\",\n \"section\",\n \"example\",\n ],\n // `<glossterm>` is how a `<glossentry>` titles itself. It never carries a\n // `<title>`, so a vocabulary listing `title` alone reads every real glossary\n // topic as untitled and refuses the whole file. DITA-OT's own docset has\n // thirteen of them. `src/term/core/readers/dita.ts` has always read\n // `<glossterm>` as the term, so the two halves of this package disagreed\n // until the vendored corpus made it visible.\n titles: [\"title\", \"glossterm\"],\n titleWrappers: [],\n transparent: [\n \"dita\",\n \"body\",\n \"conbody\",\n \"taskbody\",\n \"refbody\",\n \"glossbody\",\n \"abstract\",\n \"prereq\",\n \"context\",\n \"result\",\n \"postreq\",\n \"div\",\n \"bodydiv\",\n \"sectiondiv\",\n ],\n // `<cmd>` is the imperative line of a `<step>`; treating it as a paragraph is\n // what makes a DITA `<steps>` item shaped like a Markdown list item.\n //\n // `<glossdef>` is the definition, and it holds prose either directly or in\n // `<p>`s. A paragraph rather than a wrapper, because a wrapper would drop the\n // direct-text spelling, which is the common one.\n paragraphs: [\"p\", \"shortdesc\", \"cmd\", \"info\", \"glossdef\"],\n code: [\"codeblock\", \"pre\"],\n codeLangAttributes: [\"outputclass\"],\n unorderedLists: [\"ul\", \"sl\", \"steps-unordered\"],\n orderedLists: [\"ol\", \"steps\", \"substeps\"],\n listItems: [\"li\", \"sli\", \"step\", \"substep\"],\n\n tables: [\"table\", \"simpletable\"],\n tableRows: [\"row\", \"strow\", \"sthead\"],\n tableCells: [\"entry\", \"stentry\"],\n tableHeaderWrappers: [\"thead\"],\n tableHeaderRows: [\"sthead\"],\n\n admonitions: [\"note\"],\n admonitionVariantAttribute: \"type\",\n\n images: [\"image\", \"fig\"],\n imageDataElements: [\"image\"],\n imageUrlAttribute: \"href\",\n imageAltElements: [\"alt\"],\n\n blockquotes: [\"lq\"],\n\n definitionLists: [\"dl\"],\n definitionItems: [\"dlentry\"],\n definitionTerms: [\"dt\"],\n definitionBodies: [\"dd\"],\n\n // `keyref`, `conkeyref` and `conref` are not here: a key resolves only\n // against a map at build time, and a conref pulls content in rather than\n // pointing a reader anywhere.\n links: [{ elements: [\"xref\", \"link\"], attribute: \"href\" }],\n ditaHrefs: true,\n};\n\n/**\n * DocBook 5 (and the DocBook 4 `<sectN>`/`<*info>` spellings, which cost two\n * entries and save a whole second vocabulary).\n */\nconst DOCBOOK: XmlVocabulary = {\n name: \"docbook\",\n label: \"DocBook\",\n namespaces: [\"http://docbook.org/ns/docbook\"],\n roots: [\n \"book\",\n \"article\",\n \"chapter\",\n \"section\",\n \"sect1\",\n \"part\",\n \"appendix\",\n \"preface\",\n \"reference\",\n ],\n sections: [\n \"book\",\n \"article\",\n \"part\",\n \"chapter\",\n \"appendix\",\n \"preface\",\n \"section\",\n \"simplesect\",\n \"sect1\",\n \"sect2\",\n \"sect3\",\n \"sect4\",\n \"sect5\",\n ],\n titles: [\"title\"],\n titleWrappers: [\n \"info\",\n \"bookinfo\",\n \"articleinfo\",\n \"chapterinfo\",\n \"sectioninfo\",\n ],\n transparent: [\"formalpara\"],\n paragraphs: [\"para\", \"simpara\"],\n code: [\"programlisting\", \"screen\", \"literallayout\", \"synopsis\"],\n codeLangAttributes: [\"language\"],\n unorderedLists: [\"itemizedlist\", \"simplelist\"],\n orderedLists: [\"orderedlist\", \"procedure\"],\n listItems: [\"listitem\", \"member\", \"step\"],\n\n tables: [\"table\", \"informaltable\"],\n tableRows: [\"row\"],\n tableCells: [\"entry\"],\n tableHeaderWrappers: [\"thead\"],\n tableHeaderRows: [],\n\n // No `admonitionVariantAttribute`: DocBook's five admonition elements are\n // themselves named `note`/`warning`/`caution`/`tip`/`important`.\n admonitions: [\"note\", \"warning\", \"caution\", \"tip\", \"important\"],\n\n images: [\"mediaobject\", \"figure\"],\n imageDataElements: [\"imagedata\"],\n imageUrlAttribute: \"fileref\",\n imageAltElements: [],\n\n blockquotes: [\"blockquote\"],\n\n definitionLists: [\"variablelist\"],\n definitionItems: [\"varlistentry\"],\n definitionTerms: [\"term\"],\n // DocBook reuses `<listitem>` for a variable list's own body, distinct from\n // the `listItems` bucket above which reads it inside `<itemizedlist>`.\n definitionBodies: [\"listitem\"],\n\n links: [\n { elements: [\"link\"], attribute: \"href\" },\n { elements: [\"ulink\"], attribute: \"url\" },\n { elements: [\"xref\", \"link\"], attribute: \"linkend\", idref: true },\n ],\n};\n\n/** A map's navigation entries: each is a section, and each one's `href` a link. */\nconst MAP_ENTRIES = [\n \"map\",\n \"bookmap\",\n \"topicref\",\n \"topichead\",\n \"mapref\",\n \"glossref\",\n \"anchorref\",\n \"navref\",\n \"topicset\",\n \"topicsetref\",\n \"chapter\",\n \"part\",\n \"appendix\",\n \"appendices\",\n \"preface\",\n \"notices\",\n \"dedication\",\n \"colophon\",\n \"amendments\",\n];\n\n/**\n * DITA maps, `<map>` and `<bookmap>`. No namespace to detect on, as with DITA\n * itself, so recognition leans on `<topicref>` and the rest of the navigation\n * vocabulary.\n *\n * A map is a table of contents, which is a tree of titled nodes - and a tree of\n * titled nodes is what a section tree is. `<topicref>` nesting is section\n * nesting. The one thing a map does that a topic never does is leave its nodes\n * untitled: a real entry points by `@keyref` or `@href` and lets the referenced\n * topic supply the title, so `untitledSections` is on and an untitled entry is\n * an untitled section rather than a failure. A titled entry may be titled\n * either way, as `<topicmeta><navtitle>` or as `@navtitle`, so `titles` and\n * `titleAttributes` both name it.\n *\n * `sections` is wide because navigation is. `<glossref>`, `<mapref>`,\n * `<navref>`, `<topicset>` and a bookmap's `<chapter>`/`<part>`/`<appendix>`\n * are all `<topicref>` specializations, and a map that nests its entries in one\n * of them - DITA-OT's own glossary map nests thirteen `<glossref>`s - would\n * otherwise parse to a tree with nothing in it.\n *\n * `<reltable>` and `<keydef>` are in no bucket at all, so they and their\n * contents are skipped, the blockquote rule. A relationship table states which\n * topics relate to each other, and a key definition binds a key to a resource.\n * Neither is navigation, and counting their `<topicref>`s as sections would\n * make every map's shape a lie. A `<glossref>` carrying `@keys` is the case\n * that looks like both, and it is a section: `<keydef>` defaults to\n * `processing-role=\"resource-only\"` and so never appears in a table of\n * contents, while `<glossref>` processes normally and does. That is a fact\n * about DITA, not a preference.\n *\n * `<topicmeta>` is both a title wrapper and transparent. Wrapping is how\n * `<navtitle>` is found; transparency is how the `<shortdesc>` and `<linktext>`\n * beside it are read, since a map has no other prose and they live nowhere\n * else. `<booktitle>` is a wrapper only: a bookmap titles itself\n * `<booktitle><mainbooktitle>`, and the optional `<booklibrary>` beside it\n * names the series rather than the book, so only `<mainbooktitle>` is a title.\n */\nconst DITAMAP: XmlVocabulary = {\n name: \"ditamap\",\n label: \"DITA map\",\n namespaces: [],\n roots: [\"map\", \"bookmap\"],\n sections: MAP_ENTRIES,\n // `navtitle` sits in both buckets on purpose, because DITA spells it either\n // way. The element form wins: `headingOf` asks `titleOf` first, so\n // `@navtitle` is read only when the entry has no `<topicmeta><navtitle>`.\n titles: [\"title\", \"navtitle\", \"mainbooktitle\"],\n titleAttributes: [\"navtitle\"],\n titleWrappers: [\"topicmeta\", \"booktitle\"],\n untitledSections: true,\n transparent: [\n \"topicgroup\",\n \"topicmeta\",\n \"frontmatter\",\n \"backmatter\",\n \"booklists\",\n ],\n paragraphs: [\"shortdesc\", \"linktext\"],\n code: [],\n codeLangAttributes: [],\n unorderedLists: [],\n orderedLists: [],\n listItems: [],\n\n // Every navigation entry's `href`. `<keydef>` is not an entry - it binds a\n // key to a resource and never appears in a table of contents - so its\n // `href` is not a link, for the reason it is not a section.\n links: [{ elements: MAP_ENTRIES, attribute: \"href\" }],\n ditaHrefs: true,\n};\n\n/**\n * The vocabularies tried, in declaration order (which breaks scoring ties).\n * Exported so a bespoke schema is an array entry rather than a fork.\n */\nexport const XML_VOCABULARIES: readonly XmlVocabulary[] = [\n DITA,\n DOCBOOK,\n DITAMAP,\n];\n\n/** Precomputed lookups for one vocabulary. */\ninterface Compiled {\n vocab: XmlVocabulary;\n sections: Set<string>;\n titles: Set<string>;\n titleWrappers: Set<string>;\n transparent: Set<string>;\n paragraphs: Set<string>;\n code: Set<string>;\n unordered: Set<string>;\n ordered: Set<string>;\n items: Set<string>;\n tables: Set<string>;\n tableRows: Set<string>;\n tableCells: Set<string>;\n tableHeaderWrappers: Set<string>;\n tableHeaderRows: Set<string>;\n admonitions: Set<string>;\n images: Set<string>;\n imageDataElements: Set<string>;\n imageAltElements: Set<string>;\n blockquotes: Set<string>;\n definitionLists: Set<string>;\n definitionItems: Set<string>;\n definitionTerms: Set<string>;\n definitionBodies: Set<string>;\n links: { elements: Set<string>; attribute: string; idref: boolean }[];\n /** Every name the vocabulary claims, for scoring. */\n known: Set<string>;\n}\n\nconst lower = (names: readonly string[] = []): Set<string> =>\n new Set(names.map((n) => n.toLowerCase()));\n\nfunction compile(vocab: XmlVocabulary): Compiled {\n const c: Compiled = {\n vocab,\n sections: lower(vocab.sections),\n titles: lower(vocab.titles),\n titleWrappers: lower(vocab.titleWrappers),\n transparent: lower(vocab.transparent),\n paragraphs: lower(vocab.paragraphs),\n code: lower(vocab.code),\n unordered: lower(vocab.unorderedLists),\n ordered: lower(vocab.orderedLists),\n items: lower(vocab.listItems),\n tables: lower(vocab.tables),\n tableRows: lower(vocab.tableRows),\n tableCells: lower(vocab.tableCells),\n tableHeaderWrappers: lower(vocab.tableHeaderWrappers),\n tableHeaderRows: lower(vocab.tableHeaderRows),\n admonitions: lower(vocab.admonitions),\n images: lower(vocab.images),\n imageDataElements: lower(vocab.imageDataElements),\n imageAltElements: lower(vocab.imageAltElements),\n blockquotes: lower(vocab.blockquotes),\n definitionLists: lower(vocab.definitionLists),\n definitionItems: lower(vocab.definitionItems),\n definitionTerms: lower(vocab.definitionTerms),\n definitionBodies: lower(vocab.definitionBodies),\n links: (vocab.links ?? []).map((l) => ({\n elements: lower(l.elements),\n attribute: l.attribute.toLowerCase(),\n idref: l.idref ?? false,\n })),\n known: new Set(),\n };\n for (const set of [\n c.sections,\n c.titles,\n c.titleWrappers,\n c.transparent,\n c.paragraphs,\n c.code,\n c.unordered,\n c.ordered,\n c.items,\n c.tables,\n c.tableRows,\n c.tableCells,\n c.tableHeaderWrappers,\n c.tableHeaderRows,\n c.admonitions,\n c.images,\n c.imageDataElements,\n c.imageAltElements,\n c.blockquotes,\n c.definitionLists,\n c.definitionItems,\n c.definitionTerms,\n c.definitionBodies,\n ]) {\n for (const name of set) c.known.add(name);\n }\n return c;\n}\n\nconst ELEMENT_NODE = 1;\n\n/** Lowercased local name, prefix and namespace discarded. */\nfunction localName(node: XmlNode): string {\n const el = node as XmlElement;\n const name = el.localName ?? node.nodeName.split(\":\").pop() ?? node.nodeName;\n return name.toLowerCase();\n}\n\nfunction* elementChildren(el: XmlNode): Generator<XmlElement> {\n for (let child = el.firstChild; child; child = child.nextSibling) {\n if (child.nodeType === ELEMENT_NODE) yield child as XmlElement;\n }\n}\n\n/** An attribute's value by lowercased local name, any prefix: `id` finds `xml:id`. */\nfunction attributeByLocalName(el: XmlElement, name: string): string | null {\n for (let i = 0; i < el.attributes.length; i++) {\n const attr = el.attributes.item(i);\n if (attr && localName(attr) === name) return attr.value;\n }\n return null;\n}\n\n/** `file.dita#topic/element` -> `file.dita#element`; see `XmlVocabulary.ditaHrefs`. */\nfunction ditaTarget(href: string): string {\n if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return href;\n const hash = href.indexOf(\"#\");\n const slash = href.lastIndexOf(\"/\");\n return hash === -1 || slash < hash ? href : href.slice(0, hash + 1) + href.slice(slash + 1);\n}\n\n/** First direct child matching one of `names`, or null. */\nfunction findDirectChild(el: XmlElement, names: Set<string>): XmlElement | null {\n for (const child of elementChildren(el)) {\n if (names.has(localName(child))) return child;\n }\n return null;\n}\n\n/** First descendant matching one of `names`, in document order, or null. */\nfunction findDescendant(el: XmlElement, names: Set<string>): XmlElement | null {\n for (const child of elementChildren(el)) {\n if (names.has(localName(child))) return child;\n const nested = findDescendant(child, names);\n if (nested) return nested;\n }\n return null;\n}\n\n/** Collapse XML's indentation whitespace into the single spaces a reader sees. */\nfunction flatten(text: string | null): string {\n return (text ?? \"\").replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * A code block's text, minus the layout the source added around it: the newline\n * that follows the start tag when the code is on its own line, and the\n * indentation before the end tag. Everything between is significant and is left\n * exactly as written, which is what mdast does with a fenced block's value.\n */\nfunction codeText(text: string | null): string {\n return (text ?? \"\").replace(/^[^\\S\\n]*\\n/, \"\").replace(/\\n[^\\S\\n]*$/, \"\");\n}\n\n/** The six variants `AdmonitionNode` knows. A name outside this set names no variant. */\ntype Variant = Exclude<AdmonitionNode[\"variant\"], undefined>;\nconst ADMONITION_VARIANTS = new Set<Variant>([\n \"note\",\n \"tip\",\n \"important\",\n \"caution\",\n \"warning\",\n \"danger\",\n]);\n\nfunction isAdmonitionVariant(name: string): name is Variant {\n return (ADMONITION_VARIANTS as ReadonlySet<string>).has(name);\n}\n\n/** Weights for `chooseVocabulary`, in the order they are meant to dominate. */\nconst NAMESPACE_MATCH = 1000;\nconst EXCLUSIVE_ELEMENT = 10;\nconst ROOT_NAME = 5;\nconst SHARED_ELEMENT = 1;\n\n/**\n * Score every vocabulary against the document and take the best.\n *\n * A namespace match on the root is decisive: a document that declares its\n * namespace has already said what it is. Failing that, what counts is elements\n * only one candidate claims - `<para>` and `<programlisting>` are DocBook's\n * alone, `<p>` and `<taskbody>` DITA's - because those are the ones whose\n * presence is an argument. Elements the candidates share (`<section>`,\n * `<title>`) are worth a point as a tiebreak and no more, since they are\n * evidence for everyone and therefore for no one.\n *\n * The root element name is weaker still, and deliberately weaker than a single\n * exclusive element. `<section>` is a DocBook root, so a bare `<section>` whose\n * prose is in `<p>` would otherwise be read as DocBook - and every `<p>` in it\n * would then be an unmapped element, silently skipped, leaving a titled section\n * with no content and no complaint. One `<p>` is better evidence about what a\n * file is than the name of its outermost tag.\n */\nfunction chooseVocabulary(\n root: XmlElement,\n compiled: Compiled[],\n): { best: Compiled; score: number } {\n const counts = new Map<string, number>();\n const tally = (node: XmlNode): void => {\n for (const child of elementChildren(node)) {\n const name = localName(child);\n counts.set(name, (counts.get(name) ?? 0) + 1);\n tally(child);\n }\n };\n counts.set(localName(root), 1);\n tally(root);\n\n /** How many candidates claim each name; 1 means the name is decisive. */\n const claims = new Map<string, number>();\n for (const c of compiled) {\n for (const name of c.known) claims.set(name, (claims.get(name) ?? 0) + 1);\n }\n\n const ns = (root.namespaceURI ?? \"\").toLowerCase();\n const rootName = localName(root);\n\n let best: Compiled | undefined;\n let bestScore = -1;\n for (const c of compiled) {\n let score = 0;\n if (ns && c.vocab.namespaces.some((u) => u.toLowerCase() === ns)) {\n score += NAMESPACE_MATCH;\n }\n if (lower(c.vocab.roots).has(rootName)) score += ROOT_NAME;\n for (const [name, n] of counts) {\n if (!c.known.has(name)) continue;\n score += n * (claims.get(name) === 1 ? EXCLUSIVE_ELEMENT : SHARED_ELEMENT);\n }\n if (score > bestScore) {\n best = c;\n bestScore = score;\n }\n }\n if (!best) {\n // The vocabulary list is the registry's own and is never empty; the loop\n // assigns on its first pass, because every score beats the -1 it starts\n // from. Saying so out loud beats returning a vocabulary nobody chose.\n throw new LintError(\"No XML vocabularies are registered.\");\n }\n return { best, score: bestScore };\n}\n\n/**\n * Line/column -> offset, over the content as it was read.\n *\n * xmldom normalizes line endings before parsing, so its line and column are\n * against a LF-only copy. Line *numbers* survive that normalization unchanged\n * and CRLF only ever differs at a line terminator, so indexing the original\n * content's line starts with xmldom's (line, column) lands on the same\n * character - which is what keeps `offset` an index into the file the reporter\n * will quote, not into a normalized copy of it.\n */\nclass SourceMap {\n private readonly lineStarts: number[] = [0];\n /** Byte-order mark length, added back to every offset. */\n private readonly bom: number;\n private readonly body: string;\n readonly docEnd: Point;\n\n constructor(content: string) {\n this.bom = content.charCodeAt(0) === 0xfeff ? 1 : 0;\n this.body = content.slice(this.bom);\n for (let i = 0; i < this.body.length; i++) {\n const ch = this.body[i];\n if (ch === \"\\n\") this.lineStarts.push(i + 1);\n else if (ch === \"\\r\") {\n if (this.body[i + 1] === \"\\n\") i++;\n this.lineStarts.push(i + 1);\n }\n }\n // `lineStarts` opens with 0 and is only ever appended to, so the fallback\n // is unreachable - and it is the start of the one and only line anyway.\n const lastStart = this.lineStarts.at(-1) ?? 0;\n this.docEnd = {\n line: this.lineStarts.length,\n column: this.body.length - lastStart + 1,\n offset: content.length,\n };\n }\n\n /** The source text, for the parser to hand to xmldom without the BOM. */\n get text(): string {\n return this.body;\n }\n\n /** Start point of a node, or null when the locator recorded none. */\n point(node: XmlNode | null | undefined): Point | null {\n if (!node) return null;\n const line = node.lineNumber;\n const column = node.columnNumber;\n if (typeof line !== \"number\" || typeof column !== \"number\") return null;\n const start = this.lineStarts[line - 1];\n if (start === undefined) return null;\n const offset = Math.min(start + column - 1, this.body.length) + this.bom;\n return { line, column, offset };\n }\n\n /** End of the line a point sits on, exclusive of its terminator. */\n endOfLine(line: number): Point {\n const start = this.lineStarts[line - 1];\n if (start === undefined) return { ...this.docEnd };\n const next = this.lineStarts[line];\n const end = next === undefined ? this.body.length : next - 1;\n return { line, column: end - start + 1, offset: end + this.bom };\n }\n}\n\n/**\n * The exclusive end of an element: where the next node in document order\n * starts. Whitespace text nodes carry positions too, so for indented XML that\n * is the character immediately after `</tag>`.\n */\nfunction nextInDocumentOrder(el: XmlNode): XmlNode | null {\n let node: XmlNode = el;\n for (;;) {\n if (node.nextSibling) return node.nextSibling;\n const parent: XmlNode | null = node.parentNode;\n if (!parent || parent.nodeType !== ELEMENT_NODE) return null;\n node = parent;\n }\n}\n\n/** Flattens one document into ordered fragments under one vocabulary. */\nclass Flattener {\n readonly fragments: Fragment[] = [];\n\n constructor(\n private readonly c: Compiled,\n private readonly map: SourceMap,\n ) {}\n\n private span(el: XmlNode): Position {\n const start = this.map.point(el) ?? { ...this.map.docEnd };\n const end =\n this.map.point(nextInDocumentOrder(el)) ?? { ...this.map.docEnd };\n // A malformed locator (or an element that ends the document) must never\n // produce a backwards span; rules sort findings by offset.\n return end.offset < start.offset ? { start, end: { ...start } } : { start, end };\n }\n\n /** The title element of a section container, direct or inside a wrapper. */\n private titleOf(el: XmlElement): XmlElement | null {\n for (const child of elementChildren(el)) {\n if (this.c.titles.has(localName(child))) return child;\n }\n for (const child of elementChildren(el)) {\n if (!this.c.titleWrappers.has(localName(child))) continue;\n for (const inner of elementChildren(child)) {\n if (this.c.titles.has(localName(inner))) return inner;\n }\n }\n return null;\n }\n\n /**\n * The exclusive end of an element's start tag: where its first child begins,\n * which for indented XML is the character right after `>`. A childless\n * element has no such node and falls back to the end of the element, which\n * for `<topicref keyref=\"a\"/>` is the same character anyway.\n */\n private startTagEnd(el: XmlElement): Point {\n return this.map.point(el.firstChild) ?? this.span(el).end;\n }\n\n /**\n * The heading a section container carries: its text, and where the heading\n * ends. A `titles` element ends it at its own end. An attribute title and an\n * absent one both end it at the end of the start tag, since neither has a\n * position and anything further would swallow a nested section's heading.\n * Null when the vocabulary says an untitled container is not a section.\n */\n private headingOf(el: XmlElement): { title: string; end: Point } | null {\n const title = this.titleOf(el);\n if (title) {\n return { title: flatten(title.textContent), end: this.span(title).end };\n }\n for (const attr of this.c.vocab.titleAttributes ?? []) {\n const value = el.getAttribute(attr);\n if (value) return { title: flatten(value), end: this.startTagEnd(el) };\n }\n if (this.c.vocab.untitledSections) {\n return { title: \"\", end: this.startTagEnd(el) };\n }\n return null;\n }\n\n /** Walk one element: section, wrapper, content, or skipped subtree. */\n visit(el: XmlElement, level: number): void {\n const name = localName(el);\n\n if (this.c.sections.has(name)) {\n const heading = this.headingOf(el);\n if (!heading) {\n // An untitled section container adds no heading, so it adds no level\n // either; its content belongs to the section that encloses it.\n this.walkChildren(el, level);\n return;\n }\n const next = Math.min(level + 1, 6);\n const id = attributeByLocalName(el, \"id\");\n this.fragments.push({\n type: \"heading\",\n level: next,\n title: heading.title,\n ...(id ? { id } : {}),\n // From the container's start tag through the end of its title: the\n // container is the section, so a section that began at its `<title>`\n // would leave its own opening tag outside itself and stop adjacent\n // sections from tiling the document.\n position: { start: this.span(el).start, end: heading.end },\n });\n this.walkChildren(el, next);\n return;\n }\n\n if (this.c.transparent.has(name)) {\n this.walkChildren(el, level);\n return;\n }\n\n const node = this.content(el);\n if (node) this.fragments.push({ type: \"content\", node });\n // Unmapped: skipped with its subtree, like a Markdown blockquote.\n }\n\n /**\n * Every link target under `el`, in document order. A walk of its own rather\n * than part of `visit`, because `visit` skips unmapped subtrees and\n * `<related-links>` is one of them.\n */\n links(el: XmlElement, out: DocumentTree[\"links\"] = []): DocumentTree[\"links\"] {\n const name = localName(el);\n for (const source of this.c.links) {\n if (!source.elements.has(name)) continue;\n const value = attributeByLocalName(el, source.attribute);\n if (!value) continue;\n const target = source.idref\n ? `#${value}`\n : this.c.vocab.ditaHrefs\n ? ditaTarget(value)\n : value;\n out.push({ target, position: this.span(el) });\n }\n for (const child of elementChildren(el)) this.links(child, out);\n return out;\n }\n\n private walkChildren(el: XmlElement, level: number): void {\n for (const child of elementChildren(el)) this.visit(child, level);\n }\n\n /** One element as a content node, or null when it is not one. */\n private content(el: XmlElement): ContentNode | null {\n const name = localName(el);\n const position = this.span(el);\n\n if (this.c.paragraphs.has(name)) {\n return { kind: \"paragraph\", position, text: flatten(el.textContent) };\n }\n\n if (this.c.code.has(name)) {\n const lang = this.langOf(el);\n return {\n kind: \"codeBlock\",\n position,\n text: codeText(el.textContent),\n ...(lang ? { language: lang } : {}),\n };\n }\n\n const ordered = this.c.ordered.has(name);\n if (ordered || this.c.unordered.has(name)) {\n return {\n kind: \"list\",\n position,\n text: flatten(el.textContent),\n ordered,\n items: [...elementChildren(el)]\n .filter((item) => this.c.items.has(localName(item)))\n .map((item): ListItemNode => ({\n kind: \"listItem\",\n position: this.span(item),\n text: flatten(item.textContent),\n children: this.blockContent(item),\n })),\n };\n }\n\n if (this.c.tables.has(name)) return this.tableNode(el, position);\n\n if (this.c.admonitions.has(name)) {\n const variant = this.admonitionVariantOf(el, name);\n return {\n kind: \"admonition\",\n position,\n text: flatten(el.textContent),\n // A `@type`/name outside the six variants `AdmonitionNode` knows\n // leaves `variant` unset, rather than inventing an equivalence.\n ...(variant ? { variant } : {}),\n children: this.blockContent(el),\n };\n }\n\n if (this.c.images.has(name)) return this.imageNode(el, position);\n\n if (this.c.blockquotes.has(name)) {\n return {\n kind: \"blockquote\",\n position,\n text: flatten(el.textContent),\n children: this.blockContent(el),\n };\n }\n\n if (this.c.definitionLists.has(name)) return this.definitionListNode(el, position);\n\n return null;\n }\n\n /** A table's rows, from any of its CALS wrappers (`tgroup`, `tbody`, `thead`). */\n private tableNode(el: XmlElement, position: Position): TableNode {\n return {\n kind: \"table\",\n position,\n text: flatten(el.textContent),\n children: this.tableRowsOf(el, false),\n };\n }\n\n /**\n * Rows found anywhere under `el`, recursing through every wrapper - `tgroup`,\n * `tbody`, `thead` and the like - regardless of whether it is known\n * elsewhere. A table's internal grouping elements carry no content of their\n * own; only the rows and cells inside them do.\n *\n * `inheritedHeader` tracks whether an enclosing `tableHeaderWrappers` element\n * (CALS's `<thead>`) has been entered; `tableHeaderRows` (DITA's `<sthead>`)\n * marks a row as a header on its own, without a wrapper.\n */\n private tableRowsOf(el: XmlElement, inheritedHeader: boolean): TableRowNode[] {\n const rows: TableRowNode[] = [];\n for (const child of elementChildren(el)) {\n const name = localName(child);\n if (this.c.tableRows.has(name)) {\n rows.push(this.tableRow(child, inheritedHeader || this.c.tableHeaderRows.has(name)));\n continue;\n }\n rows.push(\n ...this.tableRowsOf(child, inheritedHeader || this.c.tableHeaderWrappers.has(name)),\n );\n }\n return rows;\n }\n\n private tableRow(el: XmlElement, header: boolean): TableRowNode {\n const cells: TableCellNode[] = [];\n for (const child of elementChildren(el)) {\n if (!this.c.tableCells.has(localName(child))) continue;\n cells.push({\n kind: \"tableCell\",\n position: this.span(child),\n text: flatten(child.textContent),\n children: this.blockContent(child),\n });\n }\n return {\n kind: \"tableRow\",\n position: this.span(el),\n text: flatten(el.textContent),\n header,\n children: cells,\n };\n }\n\n /**\n * An admonition's variant: the value of `admonitionVariantAttribute` when the\n * vocabulary names one (DITA's `<note type>`, defaulting to `note` when the\n * attribute is absent - DITA's own default), or the element's own lowercased\n * name otherwise (DocBook's `<warning>`, `<tip>`, and so on). Undefined when\n * neither names one of the six variants `AdmonitionNode` knows.\n */\n private admonitionVariantOf(el: XmlElement, name: string): Variant | undefined {\n const attr = this.c.vocab.admonitionVariantAttribute;\n const raw = (attr ? el.getAttribute(attr) : \"\") || name;\n const variant = raw.toLowerCase();\n return isAdmonitionVariant(variant) ? variant : undefined;\n }\n\n /**\n * An image, standing alone or wrapping one. `imageDataElements` names the\n * element carrying the url - `el` itself for a self-contained image (DITA's\n * `<image href>`), or a descendant found by name otherwise (DocBook's\n * `<imagedata fileref>` inside a `<mediaobject>`/`<figure>`). The caption\n * reuses `titleOf`, the same lookup a section uses for its heading - DITA's\n * `<fig><title>` and DocBook's `<figure><title>` are both a direct `<title>`\n * child.\n */\n private imageNode(el: XmlElement, position: Position): ImageNode {\n const name = localName(el);\n const dataEl = this.c.imageDataElements.has(name)\n ? el\n : findDescendant(el, this.c.imageDataElements);\n const attr = this.c.vocab.imageUrlAttribute;\n const url = (dataEl && attr ? dataEl.getAttribute(attr) : \"\") || \"\";\n const altEl = dataEl ? findDirectChild(dataEl, this.c.imageAltElements) : null;\n const title = this.titleOf(el);\n return {\n kind: \"image\",\n position,\n text: flatten(el.textContent),\n url,\n alt: altEl ? flatten(altEl.textContent) : \"\",\n ...(title ? { title: flatten(title.textContent) } : {}),\n };\n }\n\n private definitionListNode(el: XmlElement, position: Position): DefinitionListNode {\n const children: DefinitionItemNode[] = [];\n for (const child of elementChildren(el)) {\n if (this.c.definitionItems.has(localName(child))) {\n children.push(this.definitionItem(child));\n }\n }\n return {\n kind: \"definitionList\",\n position,\n text: flatten(el.textContent),\n children,\n };\n }\n\n /** One entry, pairing its term(s) - joined with \", \" when more than one - with its definition body. */\n private definitionItem(el: XmlElement): DefinitionItemNode {\n const terms: string[] = [];\n let body: XmlElement | null = null;\n for (const child of elementChildren(el)) {\n const name = localName(child);\n if (this.c.definitionTerms.has(name)) {\n terms.push(flatten(child.textContent));\n } else if (body === null && this.c.definitionBodies.has(name)) {\n body = child;\n }\n }\n return {\n kind: \"definitionItem\",\n position: this.span(el),\n text: flatten(el.textContent),\n term: terms.join(\", \"),\n definition: body ? this.blockContent(body) : [],\n };\n }\n\n /**\n * One container's content, with its own loose prose kept as a paragraph.\n * Shared by list items, table cells, admonitions, block quotes, and a\n * definition's body - anywhere the content model asks for a container's\n * `children` rather than a single block.\n *\n * mdast puts a list item's principal text in a `paragraph` child regardless\n * of markup, and `lists: {items: {paragraphs: {min: 1}}}` has to count the\n * same thing in every format. So the loose text is gathered into one, in the\n * position it occupies among the container's blocks.\n *\n * Gathering it rather than checking whether the container has any children is\n * what makes the two cases agree. `<li>bare text</li>` was already\n * reconciled; `<li>Parent<ul>…</ul></li>` was not, because the nested list is\n * a child, so the item looked accounted for and `Parent` became prose\n * nothing counted - while its Markdown, HTML, AsciiDoc, and reST twins all\n * counted one. This is the same fix `html.ts` carries, and the two should\n * stay in step.\n *\n * Unmapped elements contribute their text rather than being skipped, which is\n * what the old whole-item `textContent` did: inside a container they are\n * inline markup - DITA's `<b>`, `<xref>` - not structure worth dropping.\n */\n private blockContent(container: XmlElement): ContentNode[] {\n const out: ContentNode[] = [];\n let text = \"\";\n\n const flush = (): void => {\n const value = flatten(text);\n text = \"\";\n if (value.length === 0) return;\n out.push({ kind: \"paragraph\", position: this.span(container), text: value });\n };\n\n for (let child = container.firstChild; child; child = child.nextSibling) {\n if (child.nodeType !== ELEMENT_NODE) {\n text += child.nodeValue ?? \"\";\n continue;\n }\n\n const el = child as XmlElement;\n const nested = this.c.transparent.has(localName(el))\n ? this.contentChildren(el)\n : [this.content(el)].filter((n): n is ContentNode => n !== null);\n\n if (nested.length > 0) {\n flush();\n out.push(...nested);\n continue;\n }\n text += el.textContent ?? \"\";\n }\n\n flush();\n return out;\n }\n\n private contentChildren(el: XmlElement): ContentNode[] {\n const out: ContentNode[] = [];\n for (const child of elementChildren(el)) {\n if (this.c.transparent.has(localName(child))) {\n out.push(...this.contentChildren(child));\n continue;\n }\n const node = this.content(child);\n if (node) out.push(node);\n }\n return out;\n }\n\n /** A code block's language, with a `language-` prefix stripped. */\n private langOf(el: XmlElement): string | undefined {\n for (const attr of this.c.vocab.codeLangAttributes) {\n const value = el.getAttribute(attr);\n if (value) return value.replace(/^language-/, \"\");\n }\n return undefined;\n }\n}\n\n/**\n * Parse, refusing anything xmldom had to guess at.\n *\n * xmldom is lenient: it throws only on a `fatalError`, and reports `error` and\n * `warning` through the handler while carrying on with a repaired tree. The\n * line between them is drawn at `error` because in XML the element tree *is*\n * the structure - there is no second signal like a `##` to fall back on - so\n * linting a tree xmldom guessed at reports on a document nobody wrote. A\n * mismatched end tag or a stray `<` puts every following element at the wrong\n * depth, and the findings would be confident nonsense. `warning` is left alone:\n * xmldom recovers from an unquoted attribute value without changing the element\n * tree at all, and attributes here are metadata, not structure.\n *\n * This is also the line docmeta's XML extractor draws, so a file manni lint\n * lints is exactly a file docmeta will read metadata from.\n */\nfunction parseDocument(source: string, filePath: string): XmlElement {\n const problems: string[] = [];\n let doc;\n try {\n doc = new DOMParser({\n onError: (level, message) => {\n if (level === \"error\" || level === \"fatalError\") problems.push(message);\n },\n }).parseFromString(source, \"text/xml\");\n } catch (err) {\n const detail = problems[0] ?? errorMessage(err);\n throw new LintError(\n `${filePath}: could not parse as XML: ${firstLine(detail)}`,\n );\n }\n\n const [firstProblem] = problems;\n if (firstProblem !== undefined) {\n throw new LintError(\n `${filePath}: could not parse as XML: ${firstLine(firstProblem)}`,\n );\n }\n\n const root = doc.documentElement;\n if (!root) {\n throw new LintError(`${filePath}: could not parse as XML: no root element`);\n }\n return root;\n}\n\n/** xmldom appends the offending source to some messages; one line is enough. */\nfunction firstLine(message: string): string {\n const [first] = message.split(\"\\n\");\n return (first ?? message).trim();\n}\n\n/**\n * Metadata for routing, from docmeta.\n *\n * **Not `extractFrontmatter`.** `src/parsers/markdown.ts` calls it because for\n * Markdown it is the whole story, but in docmeta that function is specifically\n * the *fenced* `---` block reader (\"core front matter extraction shared by the\n * markdown, mdx, adoc, rst formats\"). An XML file has no fenced block, so\n * `extractFrontmatter(content, \"xml\")` returns `{ data: {}, present: false }`\n * for every XML document ever written, and `type:` routing for `.xml` would\n * silently never fire. docmeta's *registry* is the right door: its XML\n * extractor reads the root element's attributes (`<task type=\"how-to\">` ->\n * `{ type: \"how-to\" }`, minus `xmlns*`, with values parsed as YAML scalars)\n * plus the text of simple direct children as dotted keys (`task.title`). That\n * is a real `type`, so an `.xml` page does route.\n *\n * The HTML parser merges a fenced block with its native reading, fenced\n * winning a collision. This one does not, because an `.xml` file cannot carry a\n * fenced block and still be XML: a leading `---` is character data outside the\n * root element, which xmldom reports as an error and `parseDocument` refuses\n * before metadata is ever read. (HTML has no such rule - a comment or stray\n * text before `<html>` parses fine - which is why the merge is right there and\n * would be unreachable code here.)\n *\n * It throws on malformed XML, the same line `parseDocument` draws, but it is\n * called after the parse so in practice it cannot be the one to complain.\n */\nfunction readMetadata(\n content: string,\n filePath: string,\n): Record<string, unknown> | null {\n const extractor = extractorForExtension(\".xml\");\n if (!extractor) return null;\n try {\n const meta = extractor.extract(content, filePath);\n return meta.present ? meta.data : null;\n } catch (err) {\n throw new LintError(\n `${filePath}: could not read XML metadata: ${firstLine(errorMessage(err))}`,\n );\n }\n}\n\n/**\n * Note on the frontmatter-title rule.\n *\n * `withFrontmatterTitle` in the Markdown parser synthesizes an H1 from\n * `title:` when the body has none, because Docusaurus and Hugo render the page\n * title from frontmatter and their pages legitimately start at `##`. That\n * reasoning does not carry to XML and the rule is deliberately not applied\n * here. An XML document's title is an element - `<title>` - in the body, in\n * document order, exactly where the section fold already looks for it; there is\n * no publishing convention that moves it out. And what docmeta calls this\n * document's \"frontmatter\" is the *root element's own attributes*, so a `title`\n * attribute would be a second title on the very element that already carries\n * the real one: synthesizing a section from it would nest the document's actual\n * title underneath a duplicate of itself. A document with no title element at\n * all is not a page missing its H1, it is a document with no structure to lint,\n * and `parseXml` says so.\n */\n\n/**\n * Parse XML into the generic tree.\n *\n * @param vocabularies Overrides the built-ins; the extension point for a\n * bespoke schema until there is a config surface for it.\n */\nexport function parseXml(\n content: string,\n filePath: string,\n vocabularies: readonly XmlVocabulary[] = XML_VOCABULARIES,\n): DocumentTree {\n const map = new SourceMap(content);\n const root = parseDocument(map.text, filePath);\n\n const compiled = vocabularies.map(compile);\n if (compiled.length === 0) {\n throw new LintError(`${filePath}: no XML vocabularies are configured.`);\n }\n\n const { best, score } = chooseVocabulary(root, compiled);\n const names = compiled.map((c) => c.vocab.label).join(\", \");\n\n // Nothing recognized is an error rather than an empty tree. An empty tree\n // would lint as a document that is missing every section its template asks\n // for - a cascade of findings that says nothing about the page and points\n // nowhere useful. The gap is in the mapping, and this is where to say so.\n if (score <= 0) {\n throw new LintError(\n `${filePath}: no known XML vocabulary matched <${localName(root)}>. ` +\n `manni lint understands ${names}; add an entry to XML_VOCABULARIES ` +\n `in src/parsers/xml.ts to describe another schema.`,\n );\n }\n\n const flattener = new Flattener(best, map);\n flattener.visit(root, 0);\n const fragments = flattener.fragments;\n\n if (!fragments.some((b) => b.type === \"heading\")) {\n throw new LintError(\n `${filePath}: read as ${best.vocab.label}, but no titled section was found. ` +\n `A ${best.vocab.label} section is one of <${best.vocab.sections.join(\">, <\")}> ` +\n `carrying a <${best.vocab.titles.join(\">/<\")}>; without one the document has ` +\n `no structure to check.`,\n );\n }\n\n const frontmatter = readMetadata(content, filePath);\n\n return {\n format: \"xml\",\n filePath,\n frontmatter,\n // The metadata block is the root element's start tag: from its `<` to the\n // character after its `>`, which is where its first child begins.\n frontmatterPosition: frontmatter\n ? {\n start: map.point(root) ?? { ...map.docEnd },\n end:\n map.point(root.firstChild) ??\n map.endOfLine(map.point(root)?.line ?? 1),\n }\n : null,\n sections: sectionize(fragments, map.docEnd),\n links: flattener.links(root),\n };\n}\n\nexport const xmlParser: DocumentParser = {\n name: \"xml\",\n label: \"XML\",\n kinds: [\n \"paragraph\",\n \"codeBlock\",\n \"list\",\n \"listItem\",\n \"table\",\n \"tableRow\",\n \"tableCell\",\n \"admonition\",\n \"image\",\n \"blockquote\",\n \"definitionList\",\n \"definitionItem\",\n ],\n /**\n * `.dita` and `.ditamap` as well as `.xml`, because that is what a DITA topic\n * and a DITA map are actually called on disk and docmeta registers both — a\n * docset whose topics this parser was written for would otherwise be walked\n * past entirely.\n *\n * A map carries no prose, but it is a tree of navigation entries, and that is\n * the same thing a section tree is: `<topicref>` nesting is section nesting.\n * A docset of maps with no map template matches nothing and is skipped as\n * `no-template`, exactly as an untyped Markdown page is.\n */\n extensions: [\".xml\", \".dita\", \".ditamap\"],\n /**\n * A directory walk collects `.dita` and `.ditamap` but not `.xml`. Both of\n * those are documentation by definition; `.xml` is a container a repository\n * uses for build files, sitemaps, and project metadata, none of which match a\n * documentation vocabulary. Sweeping those in made one `pom.xml` fail an\n * otherwise clean tree. Naming an `.xml` file explicitly still parses it.\n */\n walkExtensions: [\".dita\", \".ditamap\"],\n parse: (content, filePath) => parseXml(content, filePath),\n};\n","/**\n * AsciiDoc parser.\n *\n * Asciidoctor already hands back a nested block tree, so the work here is the\n * same as `mdast.ts`'s: flatten it into ordered `Fragment`s and let `sectionize`\n * rebuild the nesting. `table`, `admonition`, `image`, `quote` and `dlist`\n * contexts map onto the shared content model (proposal 0065); a context that\n * still has no kind there - `sidebar`, a thematic break, `verse`, `example`,\n * and so on - is skipped whole rather than mapped to a nearest neighbour, for\n * the reason the Markdown parser skips a construct it does not model: a\n * sidebar is not a paragraph, and counting one as such would make\n * `paragraphs: {max: 3}` fail a document a reader would say satisfies it.\n *\n * Two things about Asciidoctor shape this file:\n *\n * - **Positions come from line numbers, and only line numbers.** `load()` is\n * given `sourcemap: true` so every block carries `getLineNumber()`; nothing\n * reports where a block *ends*, and there are no columns or offsets at all.\n * Those are derived from a line-start index built once over the content.\n * The pre-rewrite `parsers/asciidoc.js` instead reconstructed a `=== Title`\n * marker and ran `content.indexOf()` on it, which mismatches on attribute\n * lines, duplicate titles, and any non-canonical heading syntax.\n * - **Metadata arrives two ways.** AsciiDoc's own is the document header -\n * `= Title` plus `:key: value` entries - and that is how a real page says\n * `:type: how-to`. Some toolchains prepend a Markdown-style `---` fence\n * instead, which is a thematic break to Asciidoctor, so `skip-front-matter`\n * consumes it rather than letting it parse as body content; line numbering\n * is unaffected, so the body still indexes the original file. Both readings\n * run, and the results merge.\n */\nimport { createRequire } from \"node:module\";\nimport type asciidoctor from \"@asciidoctor/core\";\nimport { extractFrontmatter, extractorForExtension } from \"../../meta/index.js\";\nimport type {\n AdmonitionNode,\n ContentNode,\n DefinitionItemNode,\n DocumentParser,\n DocumentTree,\n ListItemNode,\n Point,\n Position,\n TableCellNode,\n TableRowNode,\n} from \"../types.js\";\nimport { LintError } from \"../types.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport type { Fragment } from \"./sectionize.js\";\nimport { sectionize } from \"./sectionize.js\";\nimport {\n fencedPosition,\n withMetadataTitle as withFrontmatterTitle,\n withoutFence,\n} from \"./metadata.js\";\n\n/**\n * `@asciidoctor/core`, not the `asciidoctor` meta-package.\n *\n * Only the parser is wanted here. The meta-package adds `@asciidoctor/cli`\n * (and yargs) plus the ejs, nunjucks and pug template engines, none of which\n * this file can reach - 63 lockfile entries that installed with manni so that\n * one `.adoc` file could be read. The core is the same Asciidoctor at the same\n * version, published as a real ESM module, so the default import is the\n * factory with no CJS interop to undo.\n *\n * Stay on 3.x. `@asciidoctor/core@4` is a rewrite whose `load()` returns a\n * promise, and `DocumentParser.parse` is synchronous for every format. Moving\n * to it would also drop `@asciidoctor/opal-runtime` and with it the deprecated\n * `glob`/`inflight` pair, which 3.x still brings in on its own.\n *\n * Required on the first `.adoc` file rather than imported: Asciidoctor and the\n * Opal runtime cost every `manni lint` and `manni check` run a tenth of a\n * second, and most never read AsciiDoc. `parse` is synchronous, so this is\n * the package's own CommonJS build through `require`, not `await import()`.\n */\nlet processor: ReturnType<typeof asciidoctor> | undefined;\n\nfunction getProcessor(): ReturnType<typeof asciidoctor> {\n if (processor === undefined) {\n const factory = createRequire(import.meta.url)(\"@asciidoctor/core\") as typeof asciidoctor;\n processor = factory();\n }\n return processor;\n}\n\n/**\n * Minimal structural view of an Asciidoctor node.\n *\n * `getBlocks()` is typed `any[]` upstream and is not even homogeneous - a\n * description list returns `[[terms], description]` tuples rather than nodes -\n * so everything is read back through `asNode`, which checks for the one method\n * every real block has.\n */\ninterface AdocNode {\n getContext(): string;\n getId?(): string | undefined;\n getLineNumber?(): number | undefined;\n getBlocks?(): unknown[];\n getLevel?(): number;\n getTitle?(): string | undefined;\n getSource?(): string;\n getContent?(): string;\n getAttribute?(name: string): unknown;\n getItems?(): unknown[];\n getRows?(): AdocRows;\n}\n\n/** A list item. Its principal text is not among its blocks. */\ninterface AdocItem {\n getLineNumber?(): number | undefined;\n getText(): string;\n getBlocks(): unknown[];\n}\n\n/** A table cell, from either a head, body or foot row. */\ninterface AdocCell {\n getLineNumber?(): number | undefined;\n getText(): string;\n}\n\n/** `Table#getRows()`'s own shape: the three row groups, each an array of cell rows. */\ninterface AdocRows {\n getHead(): AdocCell[][];\n getBody(): AdocCell[][];\n getFoot(): AdocCell[][];\n}\n\ninterface AdocDocument extends AdocNode {\n hasHeader(): boolean;\n getHeader(): unknown;\n}\n\nfunction asNode(value: unknown): AdocNode | null {\n const node = value as AdocNode | null;\n return node && typeof node.getContext === \"function\" ? node : null;\n}\n\nfunction asItem(value: unknown): AdocItem | null {\n const item = value as AdocItem | null;\n return item && typeof item.getText === \"function\" ? item : null;\n}\n\n/** Blocks of a container, filtered down to the ones that really are nodes. */\nfunction childrenOf(node: AdocNode): AdocNode[] {\n const blocks = node.getBlocks?.() ?? [];\n return blocks.map(asNode).filter((n): n is AdocNode => n !== null);\n}\n\nfunction lineOf(node: { getLineNumber?(): number | undefined }): number {\n return node.getLineNumber?.() ?? 1;\n}\n\n// ---------------------------------------------------------------------------\n// Positions\n// ---------------------------------------------------------------------------\n\n/**\n * Line numbers to `Point`s.\n *\n * The offsets a reporter prints, and the offsets `validateDocument` sorts\n * findings by, do not exist anywhere in Asciidoctor's output. They are all\n * recovered from one pass over the content that records where each line\n * starts, so a lookup is an array index rather than a search through the text.\n */\ninterface LineIndex {\n /** Column 1 of `line`. */\n start(line: number): Point;\n /** Just past the last character of `line`, before its line break. */\n endOfLine(line: number): Point;\n /** End of the document, for closing the final sections. */\n documentEnd(): Point;\n}\n\nfunction lineIndex(content: string): LineIndex {\n const starts: number[] = [0];\n for (let i = 0; i < content.length; i++) {\n if (content[i] === \"\\n\") starts.push(i + 1);\n }\n\n /** Line numbers come from a third-party tree; keep them inside the file. */\n const clamp = (line: number): number =>\n Math.min(Math.max(Math.trunc(line) || 1, 1), starts.length);\n\n /**\n * Offset of column 1 of a clamped line. `starts` opens with 0 and `clamp`\n * keeps the index inside it, so the fallback is unreachable - and 0 is where\n * a line clamped to 1 starts anyway.\n */\n const startOf = (n: number): number => starts[n - 1] ?? 0;\n\n return {\n start(line) {\n const n = clamp(line);\n return { line: n, column: 1, offset: startOf(n) };\n },\n endOfLine(line) {\n const n = clamp(line);\n const from = startOf(n);\n const next = starts[n];\n let stop = next === undefined ? content.length : next - 1;\n if (stop > from && content[stop - 1] === \"\\r\") stop -= 1;\n return { line: n, column: stop - from + 1, offset: stop };\n },\n documentEnd() {\n return {\n line: starts.length,\n column: content.length - startOf(starts.length) + 1,\n offset: content.length,\n };\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Inline text\n// ---------------------------------------------------------------------------\n\nconst NAMED_ENTITIES: Record<string, string> = {\n amp: \"&\",\n lt: \"<\",\n gt: \">\",\n quot: '\"',\n apos: \"'\",\n nbsp: \" \",\n};\n\n/**\n * Asciidoctor's plain-text rendering, flattened.\n *\n * `getTitle()`, `getContent()`, and `ListItem#getText()` all return inline\n * *HTML*: a heading written with backtick-quoted `lint` comes back as\n * `Use the <code>lint</code> command`. Stripping the tags and decoding the\n * entities is this format's equivalent of `mdast-util-to-string`, and it is\n * what makes `heading: {const: \"Overview\"}` mean the same thing here as it does\n * in Markdown.\n *\n * The one place it is lossy is Asciidoctor's `replacements` substitution, which\n * fires before we ever see the string: a straight apostrophe arrives as\n * `’` and flattens to a curly one, where Markdown would leave it alone.\n * That is Asciidoctor's conversion, not ours, and it exposes no way to ask for\n * a title with quotes substituted but replacements skipped.\n */\nfunction flattenInline(html: string | undefined): string {\n if (!html) return \"\";\n return decodeEntities(html.replace(/<[^>]*>/g, \"\"));\n}\n\nfunction decodeEntities(text: string): string {\n return text\n .replace(/&#(\\d+);/g, (_, dec: string) => String.fromCodePoint(Number(dec)))\n .replace(/&#x([0-9a-f]+);/gi, (_, hex: string) =>\n String.fromCodePoint(Number.parseInt(hex, 16)),\n )\n .replace(\n /&([a-z]+);/gi,\n (whole: string, name: string) => NAMED_ENTITIES[name.toLowerCase()] ?? whole,\n );\n}\n\n/** A link target found in converted inline HTML, with the line of the block it came from. */\ninterface Harvested {\n target: string;\n line: number;\n}\n\n/**\n * Link targets harvested by `inline` during the current `parse`. Module state\n * rather than a parameter threaded through every draft function, which is\n * safe only because `parse` is synchronous and never re-entered: it resets\n * this on the way in and reads it on the way out.\n */\nlet harvested: Harvested[] = [];\n\nconst ANCHOR = /<a\\s([^>]*)>/gi;\nconst HREF = /(?:^|\\s)href=\"([^\"]*)\"/;\nconst CLASS = /(?:^|\\s)class=\"([^\"]*)\"/;\n\n/**\n * `flattenInline`, after taking the `href` of every anchor in the HTML.\n *\n * The converted HTML is the only place Asciidoctor says where a link goes, and\n * flattening is where that is lost, so the targets are taken here or nowhere.\n * Two kinds of anchor are not links: `include`, which is how secure mode\n * renders an `include::` it refused to read, and `footnote`, which points at\n * the footnote list a full HTML conversion would append, not at any section.\n */\nfunction inline(html: string | undefined, line: number): string {\n for (const match of (html ?? \"\").matchAll(ANCHOR)) {\n const attrs = match[1] ?? \"\";\n const href = HREF.exec(attrs)?.[1];\n if (href === undefined) continue;\n const classes = (CLASS.exec(attrs)?.[1] ?? \"\").split(/\\s+/);\n if (classes.includes(\"include\") || classes.includes(\"footnote\")) continue;\n harvested.push({ target: decodeEntities(href), line });\n }\n return flattenInline(html);\n}\n\n// ---------------------------------------------------------------------------\n// Asciidoctor's tree -> drafts\n// ---------------------------------------------------------------------------\n\n/**\n * A block with a start line but no span yet.\n *\n * The walk cannot assign spans as it goes, because a block's end is the start\n * of whatever comes after it - which is only known once the whole document is\n * flat. So the walk emits drafts and `place` closes them.\n */\ntype Draft =\n | { kind: \"heading\"; line: number; level: number; title: string; id?: string }\n | { kind: \"paragraph\"; line: number; text: string }\n | { kind: \"codeBlock\"; line: number; text: string; language?: string }\n | { kind: \"list\"; line: number; ordered: boolean; items: DraftItem[] }\n | { kind: \"table\"; line: number; rows: DraftRow[] }\n | {\n kind: \"admonition\";\n line: number;\n variant: AdmonitionNode[\"variant\"];\n children: Draft[];\n }\n | { kind: \"image\"; line: number; url: string; alt: string; title?: string }\n | { kind: \"blockquote\"; line: number; children: Draft[] }\n | { kind: \"definitionList\"; line: number; items: DraftDefinitionItem[] };\n\n/** Every draft but a heading, which is the only kind that is not content. */\ntype ContentDraft = Exclude<Draft, { kind: \"heading\" }>;\n\ninterface DraftItem {\n line: number;\n text: string;\n children: Draft[];\n}\n\ninterface DraftCell {\n line: number;\n text: string;\n}\n\ninterface DraftRow {\n line: number;\n header: boolean;\n cells: DraftCell[];\n}\n\ninterface DraftDefinitionItem {\n line: number;\n term: string;\n children: Draft[];\n}\n\nfunction stringAttribute(node: AdocNode, name: string): string | undefined {\n const value = node.getAttribute?.(name);\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction draftList(node: AdocNode, ordered: boolean): Draft {\n const items: DraftItem[] = [];\n\n for (const raw of node.getItems?.() ?? []) {\n const item = asItem(raw);\n if (!item) continue;\n\n const line = lineOf(item);\n const text = inline(item.getText(), line);\n const children: Draft[] = [];\n\n // An item's principal text is not one of its blocks, but mdast puts it in\n // a paragraph child - so `lists: {items: {paragraphs: {min: 1}}}` counts\n // the same thing in both formats only if we put it there too.\n if (text.length > 0) children.push({ kind: \"paragraph\", line, text });\n collect(\n item.getBlocks().map(asNode).filter((n): n is AdocNode => n !== null),\n children,\n );\n\n items.push({ line, text, children });\n }\n\n return { kind: \"list\", line: lineOf(node), ordered, items };\n}\n\n/**\n * A block's own children, recursively drafted - the same walk `collect` does\n * at document level, reused for a container whose content is content in its\n * own right (an admonition, a blockquote) rather than a section's directly.\n */\nfunction draftChildren(node: AdocNode): Draft[] {\n const children: Draft[] = [];\n collect(childrenOf(node), children);\n return children;\n}\n\n/**\n * AsciiDoc's own admonition vocabulary is closed - `NOTE`, `TIP`, `IMPORTANT`,\n * `CAUTION`, `WARNING`, and nothing else; there is no `DANGER`. So unlike a\n * format with free-form admonition naming, every real admonition here maps\n * cleanly onto the shared vocabulary, and only a node whose `name` attribute\n * is missing or unrecognised - which real AsciiDoc input cannot produce -\n * fails to.\n */\nconst ADMONITION_VARIANTS = new Set<string>([\n \"note\",\n \"tip\",\n \"important\",\n \"caution\",\n \"warning\",\n]);\n\nfunction admonitionVariant(node: AdocNode): AdmonitionNode[\"variant\"] | null {\n const name = stringAttribute(node, \"name\")?.toLowerCase();\n return name && ADMONITION_VARIANTS.has(name)\n ? (name as AdmonitionNode[\"variant\"])\n : null;\n}\n\n/**\n * An admonition's content, whichever of the two forms it took.\n *\n * A compound admonition (`[TIP]\\n====\\n...\\n====`) has real blocks, and\n * `getContent()` on it returns their *rendered* concatenation - using both\n * would double the content. A simple one (`NOTE: text`) has no blocks at all;\n * its only content is `getContent()`, exactly as a paragraph's is.\n */\nfunction draftAdmonition(node: AdocNode, variant: AdmonitionNode[\"variant\"]): Draft {\n const children = draftChildren(node);\n if (children.length === 0) {\n const text = inline(node.getContent?.(), lineOf(node));\n if (text.length > 0) children.push({ kind: \"paragraph\", line: lineOf(node), text });\n }\n return { kind: \"admonition\", line: lineOf(node), variant, children };\n}\n\n/** A quote block's content, by the same two-form rule as an admonition's. */\nfunction draftBlockquote(node: AdocNode): Draft {\n const children = draftChildren(node);\n if (children.length === 0) {\n const text = inline(node.getContent?.(), lineOf(node));\n if (text.length > 0) children.push({ kind: \"paragraph\", line: lineOf(node), text });\n }\n return { kind: \"blockquote\", line: lineOf(node), children };\n}\n\nfunction draftTable(node: AdocNode): Draft {\n const rows = node.getRows?.();\n const toRow = (header: boolean) => (cells: AdocCell[]): DraftRow => ({\n line: cells[0]?.getLineNumber?.() ?? lineOf(node),\n header,\n cells: cells.map((cell) => {\n const line = cell.getLineNumber?.() ?? lineOf(node);\n return { line, text: inline(cell.getText(), line) };\n }),\n });\n return {\n kind: \"table\",\n line: lineOf(node),\n rows: [\n ...(rows?.getHead().map(toRow(true)) ?? []),\n ...(rows?.getBody().map(toRow(false)) ?? []),\n ...(rows?.getFoot().map(toRow(false)) ?? []),\n ],\n };\n}\n\n/**\n * A description list's items.\n *\n * `getItems()` does not hand back `ListItem`s for a `dlist` the way it does\n * for a `ulist`/`olist`; each entry is a `[terms, description]` tuple, and a\n * missing description arrives as AsciiDoctor's own `nil`, which is a real\n * object in the JS bridge rather than `null` or `undefined` - `asItem` rejects\n * it the same way it rejects anything else with no `getText`.\n */\nfunction draftDefinitionList(node: AdocNode): Draft {\n const items: DraftDefinitionItem[] = [];\n\n for (const entry of node.getItems?.() ?? []) {\n if (!Array.isArray(entry)) continue;\n const [rawTerms, rawDesc] = entry as [unknown, unknown];\n const terms = (Array.isArray(rawTerms) ? rawTerms : [])\n .map(asItem)\n .filter((t): t is AdocItem => t !== null);\n const first = terms[0];\n if (!first) continue;\n\n const children: Draft[] = [];\n const desc = asItem(rawDesc);\n if (desc) {\n const text = inline(desc.getText(), lineOf(desc));\n if (text.length > 0) children.push({ kind: \"paragraph\", line: lineOf(desc), text });\n collect(\n desc.getBlocks().map(asNode).filter((n): n is AdocNode => n !== null),\n children,\n );\n }\n\n items.push({\n line: lineOf(first),\n term: terms.map((t) => inline(t.getText(), lineOf(t))).join(\", \"),\n children,\n });\n }\n\n return { kind: \"definitionList\", line: lineOf(node), items };\n}\n\n/** One block, or null when the content model has no kind for it. */\nfunction draftOf(node: AdocNode): Draft | null {\n switch (node.getContext()) {\n case \"paragraph\":\n return {\n kind: \"paragraph\",\n line: lineOf(node),\n text: inline(node.getContent?.(), lineOf(node)),\n };\n case \"listing\":\n case \"literal\": {\n const lang = stringAttribute(node, \"language\");\n return {\n kind: \"codeBlock\",\n line: lineOf(node),\n // Raw, not converted: a code block's text is its source, and\n // `getContent()` would escape every `<` in it.\n text: node.getSource?.() ?? \"\",\n ...(lang ? { language: lang } : {}),\n };\n }\n case \"ulist\":\n return draftList(node, false);\n case \"olist\":\n return draftList(node, true);\n case \"table\":\n return draftTable(node);\n case \"admonition\": {\n const variant = admonitionVariant(node);\n return variant ? draftAdmonition(node, variant) : null;\n }\n case \"image\": {\n const url = stringAttribute(node, \"target\");\n if (!url) return null;\n const title = inline(node.getTitle?.(), lineOf(node));\n return {\n kind: \"image\",\n line: lineOf(node),\n url,\n alt: stringAttribute(node, \"alt\") ?? \"\",\n ...(title.length > 0 ? { title } : {}),\n };\n }\n case \"quote\":\n return draftBlockquote(node);\n case \"dlist\":\n return draftDefinitionList(node);\n default:\n // Sidebars, thematic breaks, verses, and the rest the content model\n // does not name. Skipped whole: their children are not the section's\n // content either.\n return null;\n }\n}\n\n/**\n * Flatten a container's children into drafts, in document order.\n *\n * `section` contributes a heading and then its own children as siblings, which\n * is what turns Asciidoctor's nesting back into the flat stream `sectionize`\n * folds.\n *\n * Two containers are transparent - recursed through, contributing nothing of\n * their own - because neither is a construct the author meant as content:\n *\n * - `preamble`, a wrapper Asciidoctor inserts between a document title and the\n * first section. Skipping it would swallow the lead prose.\n * - `open` (`--`). That is how an author attaches several blocks to one list\n * item, so skipping it would make a numbered step's whole body invisible to\n * a template. The constructs a `--` block can be *turned into* do not arrive\n * here at all: `[NOTE]` becomes an `admonition`, `[quote]` a `quote`,\n * `[sidebar]` a `sidebar`, each with its own context and each skipped by the\n * default branch, which is the line mdast draws around a blockquote. So a\n * node still reporting `open` is the bare attach-blocks form by elimination.\n */\nfunction collect(nodes: AdocNode[], out: Draft[]): void {\n for (const node of nodes) {\n const context = node.getContext();\n\n if (context === \"section\") {\n // Explicit (`[[id]]`, `[#id]`) or the one Asciidoctor generated\n // (`_install`): either way, the anchor an `xref` to it resolves to.\n const id = node.getId?.();\n out.push({\n kind: \"heading\",\n line: lineOf(node),\n // Asciidoctor's `=` title is level 0, so every level is one shallower\n // than the heading level the rest of the tool speaks in.\n level: (node.getLevel?.() ?? 0) + 1,\n title: inline(node.getTitle?.(), lineOf(node)),\n ...(id ? { id } : {}),\n });\n collect(childrenOf(node), out);\n continue;\n }\n\n if (context === \"preamble\" || context === \"open\") {\n collect(childrenOf(node), out);\n continue;\n }\n\n const draft = draftOf(node);\n if (draft) out.push(draft);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Drafts -> blocks\n// ---------------------------------------------------------------------------\n\n/**\n * Give every draft a span.\n *\n * A heading spans its own title line, the way an mdast heading spans its `#`\n * line. Everything else ends where the next block begins, and the last block at\n * `end` - the convention `sectionize` already uses for sections, applied one\n * level down because Asciidoctor reports where a block starts and nothing at\n * all about where it stops.\n */\nfunction place(drafts: Draft[], end: Point, index: LineIndex): Fragment[] {\n return drafts.map((draft, i): Fragment => {\n const next = drafts[i + 1];\n const boundary = next ? index.start(next.line) : end;\n\n if (draft.kind === \"heading\") {\n return {\n type: \"heading\",\n level: draft.level,\n title: draft.title,\n ...(draft.id !== undefined ? { id: draft.id } : {}),\n position: {\n start: index.start(draft.line),\n end: index.endOfLine(draft.line),\n },\n };\n }\n\n return {\n type: \"content\",\n node: contentNode(\n draft,\n { start: index.start(draft.line), end: boundary },\n index,\n ),\n };\n });\n}\n\n/** `place`, for content that cannot contain a heading. */\nfunction placeContent(drafts: Draft[], end: Point, index: LineIndex): ContentNode[] {\n return place(drafts, end, index).flatMap((fragment) =>\n fragment.type === \"content\" ? [fragment.node] : [],\n );\n}\n\nfunction placeItems(items: DraftItem[], end: Point, index: LineIndex): ListItemNode[] {\n return items.map((item, i) => {\n const next = items[i + 1];\n const boundary = next ? index.start(next.line) : end;\n return {\n kind: \"listItem\",\n position: { start: index.start(item.line), end: boundary },\n text: item.text,\n children: placeContent(item.children, boundary, index),\n };\n });\n}\n\n/**\n * A table cell's own span: its starting line only.\n *\n * Asciidoctor reports a line per cell, but several cells on one row commonly\n * share a single source line, so there is no line-based boundary between\n * them the way there is between rows or list items. A cell spans just the\n * line it starts on, the way a heading spans its own title line.\n */\nfunction placeCells(cells: DraftCell[], index: LineIndex): TableCellNode[] {\n return cells.map((cell) => ({\n kind: \"tableCell\",\n position: { start: index.start(cell.line), end: index.endOfLine(cell.line) },\n text: cell.text,\n children: [],\n }));\n}\n\nfunction placeRows(rows: DraftRow[], end: Point, index: LineIndex): TableRowNode[] {\n return rows.map((row, i) => {\n const next = rows[i + 1];\n const boundary = next ? index.start(next.line) : end;\n const cells = placeCells(row.cells, index);\n return {\n kind: \"tableRow\",\n position: { start: index.start(row.line), end: boundary },\n text: cells.map((cell) => cell.text).join(\" | \"),\n header: row.header,\n children: cells,\n };\n });\n}\n\nfunction placeDefinitionItems(\n items: DraftDefinitionItem[],\n end: Point,\n index: LineIndex,\n): DefinitionItemNode[] {\n return items.map((item, i) => {\n const next = items[i + 1];\n const boundary = next ? index.start(next.line) : end;\n const definition = placeContent(item.children, boundary, index);\n const definitionText = definition.map((node) => node.text).join(\" \");\n return {\n kind: \"definitionItem\",\n position: { start: index.start(item.line), end: boundary },\n text: definitionText.length > 0 ? `${item.term}: ${definitionText}` : item.term,\n term: item.term,\n definition,\n };\n });\n}\n\nfunction contentNode(\n draft: ContentDraft,\n position: Position,\n index: LineIndex,\n): ContentNode {\n switch (draft.kind) {\n case \"paragraph\":\n return { kind: \"paragraph\", position, text: draft.text };\n case \"codeBlock\":\n return {\n kind: \"codeBlock\",\n position,\n text: draft.text,\n ...(draft.language ? { language: draft.language } : {}),\n };\n case \"list\":\n return {\n kind: \"list\",\n position,\n // Informational only - no rule reads a list's own text - so the items\n // are joined one per line rather than run together the way\n // `mdast-util-to-string` concatenates them.\n text: draft.items.map((item) => item.text).join(\"\\n\"),\n ordered: draft.ordered,\n items: placeItems(draft.items, position.end, index),\n };\n case \"table\": {\n const rows = placeRows(draft.rows, position.end, index);\n return {\n kind: \"table\",\n position,\n text: rows.map((row) => row.text).join(\"\\n\"),\n children: rows,\n };\n }\n case \"admonition\": {\n const children = placeContent(draft.children, position.end, index);\n return {\n kind: \"admonition\",\n position,\n text: children.map((node) => node.text).join(\"\\n\\n\"),\n variant: draft.variant,\n children,\n };\n }\n case \"image\":\n return {\n kind: \"image\",\n position,\n text: draft.alt,\n url: draft.url,\n alt: draft.alt,\n ...(draft.title ? { title: draft.title } : {}),\n };\n case \"blockquote\": {\n const children = placeContent(draft.children, position.end, index);\n return {\n kind: \"blockquote\",\n position,\n text: children.map((node) => node.text).join(\"\\n\\n\"),\n children,\n };\n }\n case \"definitionList\": {\n const children = placeDefinitionItems(draft.items, position.end, index);\n return {\n kind: \"definitionList\",\n position,\n // `item.text`, which is `\"term: definition\"`, not `item.term`. A\n // node's `text` is its flattened rendering, so dropping the definition\n // bodies here would make a pattern rule find a word in every format\n // except this one.\n text: children.map((item) => item.text).join(\"\\n\"),\n children,\n };\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Document metadata\n// ---------------------------------------------------------------------------\n\n/**\n * The AsciiDoc-aware reader, which the plain `extractFrontmatter` is not.\n *\n * `extractFrontmatter(content, \"asciidoc\")` reads only the fenced `--- ... ---`\n * block some toolchains prepend - its format argument is a label copied onto\n * the result, not a parser selector. AsciiDoc's own metadata is the document\n * header: the `= Title` line plus `:key: value` attribute entries, up to the\n * first blank line. That is how a real page declares `:type: how-to`, and\n * reading it is what makes type routing work for `.adoc` at all.\n */\nconst nativeExtractor = extractorForExtension(\".adoc\");\n\ninterface Metadata {\n data: Record<string, unknown> | null;\n position: Position | null;\n}\n\n/**\n * Span of the native header: the run of lines before the first blank one,\n * which is exactly the range docmeta's extractor reads attributes from.\n */\nfunction headerPosition(content: string, index: LineIndex): Position | null {\n let last = 0;\n for (const [i, line] of content.split(/\\r?\\n/).entries()) {\n if (line.trim() === \"\") break;\n last = i + 1;\n }\n if (last === 0) return null;\n return { start: index.start(1), end: index.endOfLine(last) };\n}\n\n/**\n * Both metadata styles, merged, with the fenced block winning a key collision:\n * a file carrying a fence has chosen it as its metadata of record. `present` is\n * the OR of the two, so a page with only `:type: how-to` still reports\n * frontmatter and still routes.\n */\nfunction metadata(content: string, filePath: string, index: LineIndex): Metadata {\n const fenced = extractFrontmatter(content, \"asciidoc\");\n // Read the native header from the fence-free remainder: docmeta's AsciiDoc\n // extractor returns the fence and stops when one is present, so asking it\n // about the whole file would discard `:type:` on any page that has both.\n const native = nativeExtractor?.extract(\n fenced.present ? withoutFence(content) : content,\n filePath,\n );\n\n if (!fenced.present && !native?.present) return { data: null, position: null };\n\n return {\n data: { ...(native?.data ?? {}), ...(fenced.present ? fenced.data : {}) },\n position:\n (fenced.present ? fencedPosition(content) : null) ??\n headerPosition(content, index),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Parser\n// ---------------------------------------------------------------------------\n\nfunction load(content: string, filePath: string): AdocDocument {\n const asciidoc = getProcessor();\n try {\n return asciidoc.load(content, {\n // Without this every block's `getLineNumber()` is undefined and there are\n // no positions to derive at all.\n sourcemap: true,\n // Asciidoctor.js's default already, pinned because it is what keeps\n // `include::` from reading the disk: a refused include renders as a link\n // to its target, which `inline` then drops.\n safe: \"secure\",\n attributes: {\n // A leading `---` fence is a thematic break in AsciiDoc; this consumes\n // it as metadata instead, without disturbing line numbering.\n \"skip-front-matter\": true,\n // `xref:other.adoc[]` keeps its source suffix rather than becoming\n // `other.html`, so a harvested link names the file that exists.\n relfilesuffix: \".adoc\",\n },\n }) as unknown as AdocDocument;\n } catch (err) {\n // Asciidoctor recovers from malformed *documents* - it warns about an\n // unterminated block and carries on - so this fires when the loader itself\n // refuses the input. Either way it is the file's problem, not a crash.\n throw new LintError(\n `${filePath}: could not parse as asciidoc: ${errorMessage(err)}`,\n );\n }\n}\n\n/**\n * The document title, as a heading block.\n *\n * `= Title` is not a block: Asciidoctor keeps it as the document header, and\n * `getDocumentTitle()` lies about it - with no header at all it falls back to\n * the first section's title - so this goes through `hasHeader()`. A header made\n * only of attribute entries has no title to contribute, and emitting an empty\n * heading for it would both invent a section and block the frontmatter title\n * those attributes may be carrying.\n */\nfunction headerDraft(doc: AdocDocument): Draft | null {\n if (!doc.hasHeader()) return null;\n const header = asNode(doc.getHeader());\n if (!header) return null;\n const title = inline(header.getTitle?.(), lineOf(header));\n if (title.length === 0) return null;\n return {\n kind: \"heading\",\n line: lineOf(header),\n level: (header.getLevel?.() ?? 0) + 1,\n title,\n };\n}\n\nfunction parse(content: string, filePath: string): DocumentTree {\n const doc = load(content, filePath);\n const index = lineIndex(content);\n\n harvested = [];\n const drafts: Draft[] = [];\n const header = headerDraft(doc);\n if (header) drafts.push(header);\n collect(childrenOf(doc), drafts);\n // Stable, so links on one line keep their order. Needed at all because a\n // description list's terms are read after its body.\n const links = harvested\n .sort((a, b) => a.line - b.line)\n .map(({ target, line }) => ({\n target,\n position: { start: index.start(line), end: index.endOfLine(line) },\n }));\n\n const meta = metadata(content, filePath, index);\n const end = index.documentEnd();\n\n return {\n format: \"asciidoc\",\n filePath,\n frontmatter: meta.data,\n frontmatterPosition: meta.position,\n sections: sectionize(\n withFrontmatterTitle(place(drafts, end, index), meta.data, meta.position),\n end,\n ),\n links,\n };\n}\n\nexport const asciidocParser: DocumentParser = {\n name: \"asciidoc\",\n label: \"AsciiDoc\",\n kinds: [\n \"paragraph\",\n \"codeBlock\",\n \"list\",\n \"listItem\",\n \"table\",\n \"tableRow\",\n \"tableCell\",\n \"admonition\",\n \"image\",\n \"blockquote\",\n \"definitionList\",\n \"definitionItem\",\n ],\n extensions: [\".adoc\", \".asciidoc\"],\n parse,\n};\n","/**\n * Parser registry. Maps file extensions to parsers and resolves a parser by\n * name for the `--as` override.\n *\n * Shaped after docmeta's extractor registry, and for the same reason:\n * everything downstream of `parse()` operates on the generic `DocumentTree`, so\n * adding a format is one file plus one line here - no change to matching,\n * rules, templates, or reporting.\n *\n * A format is registered here when, and only when, a parser reads it. That is\n * what `manni lint tools` lists and what `--as` accepts, so neither can name a\n * format the tool does not read. An extension no parser claims is skipped by\n * name, never parsed as Markdown the way the pre-rewrite `inferFileType` did.\n */\nimport type { ContentKind, DocumentParser } from \"../types.js\";\nimport { markdownParser, mdxParser } from \"./markdown.js\";\nimport { htmlParser } from \"./html.js\";\nimport { rstParser } from \"./rst.js\";\nimport { xmlParser } from \"./xml.js\";\nimport { asciidocParser } from \"./asciidoc.js\";\n\nexport const PARSERS: DocumentParser[] = [\n markdownParser,\n mdxParser,\n htmlParser,\n asciidocParser,\n rstParser,\n xmlParser,\n];\n\nconst byExtension = new Map<string, DocumentParser>();\nconst byName = new Map<string, DocumentParser>();\nfor (const parser of PARSERS) {\n byName.set(parser.name, parser);\n for (const ext of parser.extensions) byExtension.set(ext.toLowerCase(), parser);\n}\n\n/** Resolve a parser for a file extension (including the dot). */\nexport function parserForExtension(ext: string): DocumentParser | undefined {\n return byExtension.get(ext.toLowerCase());\n}\n\n/** Resolve a parser by its `--as` name. */\nexport function parserByName(name: string): DocumentParser | undefined {\n return byName.get(name.toLowerCase());\n}\n\n/** Extensions collected from a directory walk. */\nexport function supportedExtensions(): string[] {\n return PARSERS.flatMap((p) => p.walkExtensions ?? p.extensions);\n}\n\n/**\n * Why a file no parser claims is skipped. One sentence for every command that\n * says it, so `lint` and `templates` cannot drift apart. `name` is the\n * extension, or the file itself when it has none.\n */\nexport function unsupportedFormatMessage(name: string): string {\n return `no parser is registered for \"${name}\". Supported extensions: ${supportedExtensions().join(\", \")}. Use --as to override.`;\n}\n\n/** Every format the tool reads, for `manni lint tools`. */\nexport function listFormats(): {\n name: string;\n label: string;\n extensions: string[];\n kinds: ContentKind[];\n}[] {\n return PARSERS.map((p) => ({\n name: p.name,\n label: p.label,\n extensions: p.extensions,\n kinds: p.kinds,\n }));\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,SAAS,eAAe;AACxB,OAAO,iBAAiB;AACxB,OAAO,eAAe;AACtB,OAAO,uBAAuB;AAC9B,OAAO,eAAe;;;ACGtB,SAAS,YAAY,qBAAqB;AAyC1C,IAAM,OAAiB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gC;AAC9C,SAAO,QAAQ,QAAQ,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU;AAChE;AAOO,SAAS,yBAAyB,MAAsB;AAC7D,SAAO,gCAAgC,IAAI,4BAA4B,oBAAoB,EAAE,KAAK,IAAI,CAAC;AACzG;AAGO,SAAS,cAKZ;AACF,SAAO,QAAQ,IAAI,CAAC,OAAO;AAAA,IACzB,MAAM,EAAE;AAAA,IACR,OAAO,EAAE;AAAA,IACT,YAAY,EAAE;AAAA,IACd,OAAO,EAAE;AAAA,EACX,EAAE;AACJ;","names":["firstLine","metadata","processor","ZERO","positionOf","childContent","toContentNode","inline","documentEnd","ADMONITION_VARIANTS","firstLine","text","under","title","last","rawText","collectLinks","elementChildren","ADMONITION_VARIANTS","readMetadata","flattenInline","ADMONITION_VARIANTS","parse"]}
|