@plebeiantech/lat.md 0.12.3-fork.13 → 0.12.3-fork.15
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 +24 -0
- package/dist/src/cli/check-context.d.ts +56 -0
- package/dist/src/cli/check-context.js +215 -0
- package/dist/src/cli/check-coverage.js +9 -5
- package/dist/src/cli/check-frontmatter.js +1 -1
- package/dist/src/cli/check-mode.js +1 -1
- package/dist/src/cli/check-status.js +1 -1
- package/dist/src/cli/check.d.ts +19 -12
- package/dist/src/cli/check.js +259 -206
- package/dist/src/cli/context.js +1 -1
- package/dist/src/cli/expand.d.ts +1 -2
- package/dist/src/cli/expand.js +52 -5
- package/dist/src/cli/external.d.ts +11 -0
- package/dist/src/cli/external.js +185 -0
- package/dist/src/cli/fork-instructions.d.ts +1 -0
- package/dist/src/cli/fork-instructions.js +3 -2
- package/dist/src/cli/hook.d.ts +26 -0
- package/dist/src/cli/hook.js +112 -40
- package/dist/src/cli/index.js +55 -3
- package/dist/src/cli/init.d.ts +1 -0
- package/dist/src/cli/init.js +40 -2
- package/dist/src/cli/locate.js +4 -3
- package/dist/src/cli/refs.d.ts +2 -1
- package/dist/src/cli/refs.js +88 -43
- package/dist/src/cli/reindex.js +2 -1
- package/dist/src/cli/search.d.ts +12 -3
- package/dist/src/cli/search.js +45 -49
- package/dist/src/cli/section.d.ts +3 -1
- package/dist/src/cli/section.js +114 -38
- package/dist/src/code-refs.d.ts +17 -5
- package/dist/src/code-refs.js +246 -65
- package/dist/src/context.d.ts +3 -0
- package/dist/src/document-formats.d.ts +7 -0
- package/dist/src/document-formats.js +39 -0
- package/dist/src/extensions/alert-marker.d.ts +25 -0
- package/dist/src/extensions/alert-marker.js +55 -0
- package/dist/src/external-documents.d.ts +56 -0
- package/dist/src/external-documents.js +404 -0
- package/dist/src/external-sources.d.ts +136 -0
- package/dist/src/external-sources.js +1098 -0
- package/dist/src/fork/antigravity-hook.d.ts +47 -0
- package/dist/src/fork/antigravity-hook.js +424 -0
- package/dist/src/fork/antigravity-init.d.ts +17 -0
- package/dist/src/fork/antigravity-init.js +124 -0
- package/dist/src/fork/frontmatter-fields.d.ts +36 -0
- package/dist/src/fork/frontmatter-fields.js +23 -0
- package/dist/src/format.d.ts +5 -2
- package/dist/src/format.js +8 -3
- package/dist/src/graph-export.js +1 -1
- package/dist/src/lattice-model.d.ts +77 -0
- package/dist/src/lattice-model.js +464 -0
- package/dist/src/lattice.d.ts +9 -104
- package/dist/src/lattice.js +69 -516
- package/dist/src/markdown-analysis-cache.d.ts +20 -0
- package/dist/src/markdown-analysis-cache.js +139 -0
- package/dist/src/markdown-analysis-worker.d.ts +16 -0
- package/dist/src/markdown-analysis-worker.js +33 -0
- package/dist/src/markdown-analysis.d.ts +50 -0
- package/dist/src/markdown-analysis.js +139 -0
- package/dist/src/markdown-analyzer-loader.d.ts +4 -0
- package/dist/src/markdown-analyzer-loader.js +13 -0
- package/dist/src/markdown-validation.d.ts +25 -0
- package/dist/src/markdown-validation.js +104 -0
- package/dist/src/mcp/server.js +27 -11
- package/dist/src/parser-cache.d.ts +17 -0
- package/dist/src/parser-cache.js +65 -0
- package/dist/src/parser-import.d.ts +8 -0
- package/dist/src/parser-import.js +1 -0
- package/dist/src/parser.js +80 -5
- package/dist/src/path.d.ts +2 -0
- package/dist/src/path.js +4 -0
- package/dist/src/profiler.d.ts +16 -0
- package/dist/src/profiler.js +81 -0
- package/dist/src/project-analysis.d.ts +59 -0
- package/dist/src/project-analysis.js +233 -0
- package/dist/src/project-discovery.d.ts +6 -0
- package/dist/src/project-discovery.js +30 -0
- package/dist/src/repository-path.d.ts +11 -0
- package/dist/src/repository-path.js +52 -0
- package/dist/src/search/db.d.ts +1 -1
- package/dist/src/search/db.js +2 -2
- package/dist/src/search/embedder.d.ts +2 -1
- package/dist/src/search/embedder.js +6 -5
- package/dist/src/search/index.d.ts +2 -1
- package/dist/src/search/index.js +10 -8
- package/dist/src/search/query.d.ts +20 -0
- package/dist/src/search/query.js +67 -0
- package/dist/src/search/search.d.ts +3 -1
- package/dist/src/search/search.js +5 -2
- package/dist/src/source-formats.d.ts +7 -0
- package/dist/src/source-formats.js +26 -0
- package/dist/src/source-parser.d.ts +44 -4
- package/dist/src/source-parser.js +494 -57
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/src/view/client/assets/MarkdownEditor-B7quqPb8.js +28 -0
- package/dist/src/view/client/assets/OrbitControls-DwcpQNja.js +1 -0
- package/dist/src/view/client/assets/STLLoader-CLWTKt5i.js +1 -0
- package/dist/src/view/client/assets/abnfDiagram-VCTEODGH-V7-T6qsl.js +1 -0
- package/dist/src/view/client/assets/arc-BnwR8Bu7.js +1 -0
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-u97vDna9.js +36 -0
- package/dist/src/view/client/assets/blockDiagram-I7D4REHJ-DETl8e_H.js +129 -0
- package/dist/src/view/client/assets/c4Diagram-7LVT6UL2-DJRAT1Ve.js +38 -0
- package/dist/src/view/client/assets/channel-BwQbnWCN.js +1 -0
- package/dist/src/view/client/assets/chunk-2Q5K7J3B-C0TmOC1Q.js +1 -0
- package/dist/src/view/client/assets/chunk-5VM5RSS4-dfBOrYE6.js +15 -0
- package/dist/src/view/client/assets/chunk-F27PBJKO-DAnks99K.js +1 -0
- package/dist/src/view/client/assets/chunk-IMKFNOWR-CPjB07if.js +231 -0
- package/dist/src/view/client/assets/chunk-JWPE2WC7-VvU_gZI6.js +1 -0
- package/dist/src/view/client/assets/chunk-POPQ4Y6H-DDUbVF55.js +1 -0
- package/dist/src/view/client/assets/chunk-SVP7TREG-BHROkr6D.js +88 -0
- package/dist/src/view/client/assets/chunk-TICWLB2K-95PzGIOg.js +206 -0
- package/dist/src/view/client/assets/chunk-XXDRQBXY-MdmuLhIs.js +1 -0
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-HvQKkIS-.js +1 -0
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-HvQKkIS-.js +1 -0
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-CauUf_rN.js +1 -0
- package/dist/src/view/client/assets/cynefin-OW5HDTMX-CeA8IKWo.js +166 -0
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-L1rtcT8l.js +62 -0
- package/dist/src/view/client/assets/cytoscape.esm-DzSz-X2X.js +321 -0
- package/dist/src/view/client/assets/dagre-GXQ25YYZ-DLQwTa3H.js +4 -0
- package/dist/src/view/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/src/view/client/assets/diagram-S7CK7UJ4-kbKdIyXG.js +30 -0
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-kmzp92RC.js +41 -0
- package/dist/src/view/client/assets/diagram-VSXAHHWV-EXJTU8qq.js +3 -0
- package/dist/src/view/client/assets/diagram-VX7I27RA-DAiIyMCG.js +24 -0
- package/dist/src/view/client/assets/diagram-Z3DM3KII-G9wz50ZV.js +24 -0
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-D2tVRCNA.js +1 -0
- package/dist/src/view/client/assets/erDiagram-RLTQ6QDP-C925J5A3.js +99 -0
- package/dist/src/view/client/assets/flowDiagram-HODETNUW-DzoCa-Nq.js +168 -0
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-D2ebbg4p.js +292 -0
- package/dist/src/view/client/assets/gitGraphDiagram-WWUBYQGX-B4QratYy.js +106 -0
- package/dist/src/view/client/assets/index-BnENo9bV.js +1 -0
- package/dist/src/view/client/assets/index-D0ajr_Ja.css +1 -0
- package/dist/src/view/client/assets/index-KZcnpXJH.js +321 -0
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-DL4mtHkt.js +2 -0
- package/dist/src/view/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/src/view/client/assets/ishikawaDiagram-5VMMS53U-CW4mto2d.js +70 -0
- package/dist/src/view/client/assets/journeyDiagram-3NMN7TZE-8R4eacFW.js +139 -0
- package/dist/src/view/client/assets/kanban-definition-UXKFOSKX-Cy9ioXEJ.js +89 -0
- package/dist/src/view/client/assets/katex-HP8lGamR.js +257 -0
- package/dist/src/view/client/assets/layout-C0MFuhth.js +1 -0
- package/dist/src/view/client/assets/linear-Dv3N4dQR.js +1 -0
- package/dist/src/view/client/assets/logo-small-RR_KBOAT.svg +149 -0
- package/dist/src/view/client/assets/maplibre-gl-DnqZgfUS.js +800 -0
- package/dist/src/view/client/assets/mermaid.core-bds9A7e2.js +310 -0
- package/dist/src/view/client/assets/mindmap-definition-YA3MSWOX-DjmGW355.js +96 -0
- package/dist/src/view/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-BWsZp0ab.js +1 -0
- package/dist/src/view/client/assets/pieDiagram-E7YTZNPT-CCH2gGR-.js +39 -0
- package/dist/src/view/client/assets/quadrantDiagram-AXDQQJYC-CjocPJFz.js +7 -0
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-BjLeb2KF.js +1 -0
- package/dist/src/view/client/assets/requirementDiagram-BXWQKSXE-Ct6AoXRr.js +84 -0
- package/dist/src/view/client/assets/sankeyDiagram-P5KCCOFB-CIpgGN_w.js +40 -0
- package/dist/src/view/client/assets/sequenceDiagram-WJ2MYXX4-DrmLFj6w.js +162 -0
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-BdFMe2Lr.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-Zd9F1goW.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-ByIKCftl.js +1 -0
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-a7VFwi00.js +1 -0
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-CzxaUHB-.js +8 -0
- package/dist/src/view/client/assets/three.module-PDSP0dbZ.js +4108 -0
- package/dist/src/view/client/assets/timeline-definition-24CTP7MA-BExPu6X5.js +120 -0
- package/dist/src/view/client/assets/vennDiagram-4TSXK5OY-PC1MU3si.js +34 -0
- package/dist/src/view/client/assets/wardleyDiagram-VM6X3IG4-DNWqU3fa.js +78 -0
- package/dist/src/view/client/assets/xychartDiagram-S5SC5T6Z-E1uA28_D.js +7 -0
- package/dist/src/view/client/index.html +2 -2
- package/dist/src/view/client-shell.d.ts +2 -0
- package/dist/src/view/client-shell.js +5 -0
- package/dist/src/view/diagnostics.d.ts +3 -2
- package/dist/src/view/diagnostics.js +49 -58
- package/dist/src/view/document-edit.d.ts +8 -0
- package/dist/src/view/document-edit.js +25 -0
- package/dist/src/view/document-route.d.ts +12 -0
- package/dist/src/view/document-route.js +93 -0
- package/dist/src/view/document-tree.d.ts +18 -0
- package/dist/src/view/document-tree.js +139 -0
- package/dist/src/view/external-document-tree.d.ts +3 -0
- package/dist/src/view/external-document-tree.js +674 -0
- package/dist/src/view/git-diff.js +187 -0
- package/dist/src/view/git.js +1 -1
- package/dist/src/view/graph.d.ts +3 -2
- package/dist/src/view/graph.js +94 -7
- package/dist/src/view/highlight.d.ts +10 -2
- package/dist/src/view/highlight.js +4540 -1360
- package/dist/src/view/markdown.d.ts +3 -2
- package/dist/src/view/markdown.js +214 -53
- package/dist/src/view/protocol.d.ts +59 -6
- package/dist/src/view/references.d.ts +10 -25
- package/dist/src/view/references.js +117 -107
- package/dist/src/view/repository.d.ts +13 -3
- package/dist/src/view/repository.js +234 -15
- package/dist/src/view/search.d.ts +1 -1
- package/dist/src/view/search.js +3 -7
- package/dist/src/view/server.d.ts +11 -2
- package/dist/src/view/server.js +212 -70
- package/dist/src/view/source-target.js +5 -8
- package/dist/src/view/static-build.d.ts +1 -0
- package/dist/src/view/static-build.js +245 -42
- package/dist/src/view/static-protocol.d.ts +19 -2
- package/dist/src/view/store.d.ts +16 -3
- package/dist/src/view/store.js +228 -36
- package/dist/src/view/table-of-contents.d.ts +2 -2
- package/dist/src/view/table-of-contents.js +2 -22
- package/dist/src/walk.d.ts +5 -3
- package/dist/src/walk.js +102 -8
- package/dist/vendor/lat.md-server/cli.d.ts +2 -0
- package/dist/vendor/lat.md-server/cli.js +12 -0
- package/dist/vendor/lat.md-server/index.d.ts +38 -0
- package/dist/vendor/lat.md-server/index.js +128 -0
- package/package.json +52 -12
- package/plugins/lat-md/README.md +61 -0
- package/plugins/lat-md/hooks.json +38 -0
- package/plugins/lat-md/plugin.json +9 -0
- package/plugins/lat-md/rules/AGENTS.md +118 -0
- package/plugins/lat-md/skills/lat-md/SKILL.md +178 -0
- package/plugins/lat-md/skills/lat-md-conventions/SKILL.md +182 -0
- package/templates/AGENTS.md +15 -3
- package/templates/cursor-rules.md +12 -3
- package/templates/skill/SKILL.md +22 -1
- package/dist/src/view/client/assets/index-C3iaZyYT.css +0 -1
- package/dist/src/view/client/assets/index-KWi67IMz.js +0 -334
- package/dist/src/view/client/assets/logo-CNF8zs47.svg +0 -182
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
|
+
import type { ViewDocumentTree } from './protocol.js';
|
|
2
3
|
export type WikiLinkContext = {
|
|
3
4
|
line: number;
|
|
4
5
|
};
|
|
@@ -19,8 +20,8 @@ export type MarkdownRenderOptions = {
|
|
|
19
20
|
lineOffset?: number;
|
|
20
21
|
rewriteMarkdownLink?: (url: string) => string;
|
|
21
22
|
};
|
|
22
|
-
/**
|
|
23
|
+
/** Normalize a lat.md file into the safe, parser-neutral view tree. */
|
|
23
24
|
export declare function renderMarkdown(markdown: string, filePath: string, resolveWikiLink?: WikiLinkResolver, options?: MarkdownRenderOptions, parsedTree?: Root): Promise<{
|
|
24
|
-
|
|
25
|
+
tree: ViewDocumentTree;
|
|
25
26
|
title: string;
|
|
26
27
|
}>;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { basename, extname } from 'node:path';
|
|
2
2
|
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
|
|
3
|
+
import rehypeRaw from 'rehype-raw';
|
|
4
|
+
import rehypeKatex from 'rehype-katex';
|
|
3
5
|
import rehypeSlug from 'rehype-slug';
|
|
4
|
-
import
|
|
6
|
+
import remarkEmoji from 'remark-emoji';
|
|
5
7
|
import remarkRehype from 'remark-rehype';
|
|
6
8
|
import { unified } from 'unified';
|
|
7
9
|
import { visit } from 'unist-util-visit';
|
|
8
10
|
import { parse } from '../parser.js';
|
|
11
|
+
import { decorateExternalSiteLinks, toViewDocumentTree, } from './document-tree.js';
|
|
12
|
+
import { highlightCode } from './highlight.js';
|
|
9
13
|
const CODE_LINK_CLASSES = [
|
|
10
14
|
'wiki-link-code',
|
|
11
15
|
'wiki-link-active',
|
|
@@ -17,19 +21,61 @@ const CODE_LINK_CLASSES = [
|
|
|
17
21
|
'code-language-rs',
|
|
18
22
|
'code-language-go',
|
|
19
23
|
'code-language-c',
|
|
24
|
+
'code-language-dart',
|
|
25
|
+
'code-language-java',
|
|
20
26
|
];
|
|
21
27
|
const ERROR_CLASS = 'markdown-error';
|
|
22
|
-
const EXTERNAL_LINK_CLASS = 'external-link';
|
|
23
|
-
const EXTERNAL_LINK_ICON_CLASS = 'external-link-icon';
|
|
24
28
|
const GIT_CLASSES = ['git-added', 'git-removed'];
|
|
25
|
-
|
|
29
|
+
const GEOJSON_SOURCE_CLASS = 'markdown-geojson-source';
|
|
30
|
+
const HIGHLIGHT_CLASS = 'hljs';
|
|
31
|
+
const MERMAID_SOURCE_CLASS = 'markdown-mermaid-source';
|
|
32
|
+
const MATH_DIFF_BLOCK_CLASS = 'git-math-block';
|
|
33
|
+
const RICH_FENCE_SOURCE_CLASS = 'markdown-diagram-source';
|
|
34
|
+
const STL_SOURCE_CLASS = 'markdown-stl-source';
|
|
35
|
+
const TOPOJSON_SOURCE_CLASS = 'markdown-topojson-source';
|
|
36
|
+
const ALERT_KINDS = ['note', 'tip', 'important', 'warning', 'caution'];
|
|
37
|
+
const ALERT_CLASSES = [
|
|
38
|
+
'markdown-alert',
|
|
39
|
+
'markdown-alert-title',
|
|
40
|
+
...ALERT_KINDS.map((kind) => `markdown-alert-${kind}`),
|
|
41
|
+
];
|
|
42
|
+
const GITHUB_CUSTOM_EMOJI = new Set([
|
|
43
|
+
'atom',
|
|
44
|
+
'basecamp',
|
|
45
|
+
'basecampy',
|
|
46
|
+
'bowtie',
|
|
47
|
+
'electron',
|
|
48
|
+
'feelsgood',
|
|
49
|
+
'finnadie',
|
|
50
|
+
'fishsticks',
|
|
51
|
+
'fu',
|
|
52
|
+
'goberserk',
|
|
53
|
+
'godmode',
|
|
54
|
+
'hurtrealbad',
|
|
55
|
+
'neckbeard',
|
|
56
|
+
'octocat',
|
|
57
|
+
'rage1',
|
|
58
|
+
'rage2',
|
|
59
|
+
'rage3',
|
|
60
|
+
'rage4',
|
|
61
|
+
'shipit',
|
|
62
|
+
'suspect',
|
|
63
|
+
'trollface',
|
|
64
|
+
]);
|
|
65
|
+
function classAttributes(tag, extraClasses = []) {
|
|
26
66
|
const attributes = defaultSchema.attributes?.[tag] ?? [];
|
|
27
67
|
const allowedClasses = attributes.flatMap((attribute) => Array.isArray(attribute) && attribute[0] === 'className'
|
|
28
68
|
? attribute.slice(1)
|
|
29
69
|
: []);
|
|
30
70
|
return [
|
|
31
71
|
...attributes.filter((attribute) => !(Array.isArray(attribute) && attribute[0] === 'className')),
|
|
32
|
-
[
|
|
72
|
+
[
|
|
73
|
+
'className',
|
|
74
|
+
...allowedClasses,
|
|
75
|
+
ERROR_CLASS,
|
|
76
|
+
...GIT_CLASSES,
|
|
77
|
+
...extraClasses,
|
|
78
|
+
],
|
|
33
79
|
];
|
|
34
80
|
}
|
|
35
81
|
const sanitizeSchema = {
|
|
@@ -45,50 +91,151 @@ const sanitizeSchema = {
|
|
|
45
91
|
'wiki-link-segmented',
|
|
46
92
|
'wiki-link-code',
|
|
47
93
|
'wiki-link-active',
|
|
48
|
-
EXTERNAL_LINK_CLASS,
|
|
49
94
|
ERROR_CLASS,
|
|
50
95
|
...GIT_CLASSES,
|
|
51
96
|
],
|
|
52
97
|
],
|
|
53
98
|
blockquote: classAttributes('blockquote'),
|
|
54
|
-
code: classAttributes('code'
|
|
99
|
+
code: classAttributes('code', [
|
|
100
|
+
HIGHLIGHT_CLASS,
|
|
101
|
+
'math-display',
|
|
102
|
+
'math-inline',
|
|
103
|
+
]),
|
|
55
104
|
del: classAttributes('del'),
|
|
56
|
-
|
|
105
|
+
details: [...(defaultSchema.attributes?.details ?? []), ['open', true]],
|
|
106
|
+
div: classAttributes('div', [...ALERT_CLASSES, MATH_DIFF_BLOCK_CLASS]),
|
|
57
107
|
h1: classAttributes('h1'),
|
|
58
108
|
h2: classAttributes('h2'),
|
|
59
109
|
h3: classAttributes('h3'),
|
|
60
110
|
h4: classAttributes('h4'),
|
|
61
111
|
h5: classAttributes('h5'),
|
|
62
112
|
h6: classAttributes('h6'),
|
|
63
|
-
img: classAttributes('img'),
|
|
113
|
+
img: classAttributes('img', ['markdown-emoji']),
|
|
114
|
+
input: [...(defaultSchema.attributes?.input ?? []), ['checked', true]],
|
|
64
115
|
ins: classAttributes('ins'),
|
|
65
116
|
li: classAttributes('li'),
|
|
66
117
|
ol: classAttributes('ol'),
|
|
67
|
-
p: classAttributes('p'),
|
|
68
|
-
pre: classAttributes('pre'
|
|
118
|
+
p: classAttributes('p', ALERT_CLASSES),
|
|
119
|
+
pre: classAttributes('pre', [
|
|
120
|
+
GEOJSON_SOURCE_CLASS,
|
|
121
|
+
MERMAID_SOURCE_CLASS,
|
|
122
|
+
RICH_FENCE_SOURCE_CLASS,
|
|
123
|
+
STL_SOURCE_CLASS,
|
|
124
|
+
TOPOJSON_SOURCE_CLASS,
|
|
125
|
+
]),
|
|
69
126
|
span: [
|
|
70
127
|
...(defaultSchema.attributes?.span ?? []),
|
|
71
128
|
'ariaHidden',
|
|
72
129
|
'ariaLabel',
|
|
130
|
+
'role',
|
|
73
131
|
[
|
|
74
132
|
'className',
|
|
75
133
|
'wiki-link-context',
|
|
76
134
|
'wiki-link-leaf',
|
|
77
135
|
'wiki-link-ref-count',
|
|
78
|
-
EXTERNAL_LINK_ICON_CLASS,
|
|
79
136
|
...CODE_LINK_CLASSES.slice(2),
|
|
137
|
+
/^hljs-./,
|
|
80
138
|
ERROR_CLASS,
|
|
81
139
|
...GIT_CLASSES,
|
|
82
140
|
],
|
|
83
141
|
],
|
|
142
|
+
table: classAttributes('table'),
|
|
143
|
+
tr: classAttributes('tr'),
|
|
84
144
|
ul: classAttributes('ul'),
|
|
85
145
|
},
|
|
86
146
|
};
|
|
87
|
-
const
|
|
88
|
-
|
|
147
|
+
const highlightedCodeHandler = (state, rawNode) => {
|
|
148
|
+
const node = rawNode;
|
|
149
|
+
const language = node.lang?.split(/\s+/, 1)[0];
|
|
150
|
+
const richSourceClass = language?.toLowerCase() === 'mermaid'
|
|
151
|
+
? MERMAID_SOURCE_CLASS
|
|
152
|
+
: language?.toLowerCase() === 'geojson'
|
|
153
|
+
? GEOJSON_SOURCE_CLASS
|
|
154
|
+
: language?.toLowerCase() === 'topojson'
|
|
155
|
+
? TOPOJSON_SOURCE_CLASS
|
|
156
|
+
: language?.toLowerCase() === 'stl'
|
|
157
|
+
? STL_SOURCE_CLASS
|
|
158
|
+
: null;
|
|
159
|
+
const highlighted = language && !richSourceClass ? highlightCode(language, node.value) : null;
|
|
160
|
+
const code = {
|
|
161
|
+
type: 'element',
|
|
162
|
+
tagName: 'code',
|
|
163
|
+
properties: {
|
|
164
|
+
className: [
|
|
165
|
+
...(language ? [`language-${language}`] : []),
|
|
166
|
+
...(highlighted === null ? [] : [HIGHLIGHT_CLASS]),
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
children: highlighted === null
|
|
170
|
+
? [
|
|
171
|
+
{
|
|
172
|
+
type: 'text',
|
|
173
|
+
value: node.value ? `${node.value}\n` : '',
|
|
174
|
+
},
|
|
175
|
+
]
|
|
176
|
+
: [...highlighted.children, { type: 'text', value: '\n' }],
|
|
177
|
+
...(node.meta ? { data: { meta: node.meta } } : {}),
|
|
178
|
+
};
|
|
179
|
+
state.patch(node, code);
|
|
180
|
+
const result = state.applyData(node, code);
|
|
181
|
+
const pre = {
|
|
182
|
+
type: 'element',
|
|
183
|
+
tagName: 'pre',
|
|
184
|
+
properties: {
|
|
185
|
+
className: richSourceClass
|
|
186
|
+
? [RICH_FENCE_SOURCE_CLASS, richSourceClass]
|
|
187
|
+
: [],
|
|
188
|
+
},
|
|
189
|
+
children: [result],
|
|
190
|
+
};
|
|
191
|
+
state.patch(node, pre);
|
|
192
|
+
return pre;
|
|
193
|
+
};
|
|
194
|
+
const documentTreeProcessor = unified()
|
|
195
|
+
.use(remarkRehype, {
|
|
196
|
+
allowDangerousHtml: true,
|
|
197
|
+
handlers: { code: highlightedCodeHandler },
|
|
198
|
+
})
|
|
199
|
+
.use(rehypeRaw)
|
|
89
200
|
.use(rehypeSanitize, sanitizeSchema)
|
|
90
|
-
.use(
|
|
91
|
-
.use(
|
|
201
|
+
.use(rehypeKatex)
|
|
202
|
+
.use(rehypeSlug);
|
|
203
|
+
const emojiProcessor = unified().use(remarkEmoji, { accessible: true });
|
|
204
|
+
function transformCustomEmoji(tree) {
|
|
205
|
+
visit(tree, 'text', (node, index, parent) => {
|
|
206
|
+
if (index === undefined || !parent || !node.value.includes(':'))
|
|
207
|
+
return;
|
|
208
|
+
const pattern = /:([a-z0-9_+-]+):/g;
|
|
209
|
+
const children = [];
|
|
210
|
+
let cursor = 0;
|
|
211
|
+
let match;
|
|
212
|
+
while ((match = pattern.exec(node.value))) {
|
|
213
|
+
if (!GITHUB_CUSTOM_EMOJI.has(match[1]))
|
|
214
|
+
continue;
|
|
215
|
+
if (match.index > cursor) {
|
|
216
|
+
children.push({
|
|
217
|
+
type: 'text',
|
|
218
|
+
value: node.value.slice(cursor, match.index),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
children.push({
|
|
222
|
+
type: 'image',
|
|
223
|
+
url: `https://github.githubassets.com/images/icons/emoji/${match[1]}.png?v8`,
|
|
224
|
+
alt: match[0],
|
|
225
|
+
title: null,
|
|
226
|
+
data: { hProperties: { className: ['markdown-emoji'] } },
|
|
227
|
+
});
|
|
228
|
+
cursor = match.index + match[0].length;
|
|
229
|
+
}
|
|
230
|
+
if (children.length === 0)
|
|
231
|
+
return;
|
|
232
|
+
if (cursor < node.value.length) {
|
|
233
|
+
children.push({ type: 'text', value: node.value.slice(cursor) });
|
|
234
|
+
}
|
|
235
|
+
parent.children.splice(index, 1, ...children);
|
|
236
|
+
return index + children.length;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
92
239
|
function nodeText(node) {
|
|
93
240
|
if (typeof node.value === 'string')
|
|
94
241
|
return node.value;
|
|
@@ -98,6 +245,38 @@ function nodeText(node) {
|
|
|
98
245
|
.map((child) => nodeText(child))
|
|
99
246
|
.join('');
|
|
100
247
|
}
|
|
248
|
+
function transformAlerts(tree) {
|
|
249
|
+
visit(tree, 'blockquote', (node) => {
|
|
250
|
+
const firstBlock = node.children[0];
|
|
251
|
+
if (firstBlock?.type !== 'paragraph')
|
|
252
|
+
return;
|
|
253
|
+
const firstInline = firstBlock.children[0];
|
|
254
|
+
if (firstInline?.type !== 'alertMarker')
|
|
255
|
+
return;
|
|
256
|
+
const label = firstInline.value;
|
|
257
|
+
const kind = label.toLowerCase();
|
|
258
|
+
firstBlock.children.shift();
|
|
259
|
+
if (firstBlock.children.length === 0)
|
|
260
|
+
node.children.shift();
|
|
261
|
+
node.data = {
|
|
262
|
+
...node.data,
|
|
263
|
+
hName: 'div',
|
|
264
|
+
hProperties: {
|
|
265
|
+
...(node.data?.hProperties ?? {}),
|
|
266
|
+
className: ['markdown-alert', `markdown-alert-${kind}`],
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
node.children.unshift({
|
|
270
|
+
type: 'paragraph',
|
|
271
|
+
data: {
|
|
272
|
+
hProperties: { className: ['markdown-alert-title'] },
|
|
273
|
+
},
|
|
274
|
+
children: [
|
|
275
|
+
{ type: 'text', value: label[0] + label.slice(1).toLowerCase() },
|
|
276
|
+
],
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
101
280
|
function wikiLinkContent(node) {
|
|
102
281
|
if (node.data.alias) {
|
|
103
282
|
return {
|
|
@@ -151,6 +330,10 @@ function codeLanguage(target) {
|
|
|
151
330
|
case '.c':
|
|
152
331
|
case '.h':
|
|
153
332
|
return { className: 'code-language-c', label: 'C' };
|
|
333
|
+
case '.dart':
|
|
334
|
+
return { className: 'code-language-dart', label: 'DART' };
|
|
335
|
+
case '.java':
|
|
336
|
+
return { className: 'code-language-java', label: 'JAVA' };
|
|
154
337
|
default:
|
|
155
338
|
return null;
|
|
156
339
|
}
|
|
@@ -194,22 +377,6 @@ function codeLinkContent(language, children) {
|
|
|
194
377
|
...rest,
|
|
195
378
|
];
|
|
196
379
|
}
|
|
197
|
-
function externalLinkIcon() {
|
|
198
|
-
return {
|
|
199
|
-
type: 'emphasis',
|
|
200
|
-
data: {
|
|
201
|
-
hName: 'span',
|
|
202
|
-
hProperties: {
|
|
203
|
-
ariaHidden: 'true',
|
|
204
|
-
className: [EXTERNAL_LINK_ICON_CLASS],
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
children: [],
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function isExternalSiteUrl(url) {
|
|
211
|
-
return /^(?:https?:)?\/\//i.test(url);
|
|
212
|
-
}
|
|
213
380
|
function referenceCountBadge(count) {
|
|
214
381
|
return {
|
|
215
382
|
type: 'emphasis',
|
|
@@ -291,10 +458,13 @@ function markMarkdownErrors(tree, errors) {
|
|
|
291
458
|
};
|
|
292
459
|
}
|
|
293
460
|
}
|
|
294
|
-
/**
|
|
461
|
+
/** Normalize a lat.md file into the safe, parser-neutral view tree. */
|
|
295
462
|
export async function renderMarkdown(markdown, filePath, resolveWikiLink, options = {}, parsedTree) {
|
|
296
463
|
const tree = parsedTree ? structuredClone(parsedTree) : parse(markdown);
|
|
297
464
|
tree.children = tree.children.filter((node) => node.type !== 'yaml');
|
|
465
|
+
await emojiProcessor.run(tree);
|
|
466
|
+
transformCustomEmoji(tree);
|
|
467
|
+
transformAlerts(tree);
|
|
298
468
|
if (options.errors)
|
|
299
469
|
markMarkdownErrors(tree, options.errors);
|
|
300
470
|
visit(tree, 'link', (node) => {
|
|
@@ -312,23 +482,11 @@ export async function renderMarkdown(markdown, filePath, resolveWikiLink, option
|
|
|
312
482
|
if (options.rewriteMarkdownLink) {
|
|
313
483
|
node.url = options.rewriteMarkdownLink(authoredUrl);
|
|
314
484
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
? currentClasses.map(String)
|
|
321
|
-
: currentClasses
|
|
322
|
-
? [String(currentClasses)]
|
|
323
|
-
: [];
|
|
324
|
-
node.data = {
|
|
325
|
-
...node.data,
|
|
326
|
-
hProperties: {
|
|
327
|
-
...properties,
|
|
328
|
-
className: [...classes, EXTERNAL_LINK_CLASS],
|
|
329
|
-
},
|
|
330
|
-
};
|
|
331
|
-
node.children.push(externalLinkIcon());
|
|
485
|
+
});
|
|
486
|
+
visit(tree, 'image', (node) => {
|
|
487
|
+
if (options.rewriteMarkdownLink) {
|
|
488
|
+
node.url = options.rewriteMarkdownLink(node.url);
|
|
489
|
+
}
|
|
332
490
|
});
|
|
333
491
|
const firstHeading = tree.children.find((node) => node.type === 'heading');
|
|
334
492
|
const title = firstHeading
|
|
@@ -354,7 +512,7 @@ export async function renderMarkdown(markdown, filePath, resolveWikiLink, option
|
|
|
354
512
|
if (resolution) {
|
|
355
513
|
const { href, referenceCount } = resolution;
|
|
356
514
|
const content = wikiLinkContent(node);
|
|
357
|
-
const language = href.startsWith('/code/')
|
|
515
|
+
const language = href.startsWith('/code/') || href.startsWith('/external/')
|
|
358
516
|
? codeLanguage(node.value)
|
|
359
517
|
: null;
|
|
360
518
|
const classes = content.segmented ? ['wiki-link-segmented'] : [];
|
|
@@ -404,6 +562,9 @@ export async function renderMarkdown(markdown, filePath, resolveWikiLink, option
|
|
|
404
562
|
value: `[[${node.value}${alias}]]`,
|
|
405
563
|
};
|
|
406
564
|
});
|
|
407
|
-
const hast = await
|
|
408
|
-
return {
|
|
565
|
+
const hast = await documentTreeProcessor.run(tree);
|
|
566
|
+
return {
|
|
567
|
+
tree: decorateExternalSiteLinks(toViewDocumentTree(hast)),
|
|
568
|
+
title,
|
|
569
|
+
};
|
|
409
570
|
}
|
|
@@ -2,8 +2,14 @@ export type ViewGitFileStatus = 'modified' | 'new';
|
|
|
2
2
|
export type ViewGitState = {
|
|
3
3
|
files: Record<string, ViewGitFileStatus>;
|
|
4
4
|
};
|
|
5
|
+
export type ViewExternalFile = {
|
|
6
|
+
handle: string;
|
|
7
|
+
path: string;
|
|
8
|
+
target: string;
|
|
9
|
+
};
|
|
5
10
|
export type ViewIndex = {
|
|
6
11
|
files: string[];
|
|
12
|
+
externalFiles: ViewExternalFile[];
|
|
7
13
|
entry: string;
|
|
8
14
|
errorCounts: Record<string, number>;
|
|
9
15
|
git: ViewGitState | null;
|
|
@@ -30,10 +36,36 @@ export type ViewSearchResponse = {
|
|
|
30
36
|
query: string;
|
|
31
37
|
results: ViewSearchResult[];
|
|
32
38
|
};
|
|
33
|
-
export type
|
|
39
|
+
export type ViewDocumentProperty = string | number | boolean | null | (string | number)[];
|
|
40
|
+
export type ViewDocumentText = {
|
|
41
|
+
type: 'text';
|
|
42
|
+
value: string;
|
|
43
|
+
};
|
|
44
|
+
export type ViewDocumentElement = {
|
|
45
|
+
type: 'element';
|
|
46
|
+
tagName: string;
|
|
47
|
+
properties: Record<string, ViewDocumentProperty>;
|
|
48
|
+
children: ViewDocumentNode[];
|
|
49
|
+
};
|
|
50
|
+
export type ViewDocumentNode = ViewDocumentText | ViewDocumentElement;
|
|
51
|
+
/** Versioned, parser-neutral presentation tree sent to the browser. */
|
|
52
|
+
export type ViewDocumentTree = {
|
|
53
|
+
version: 1;
|
|
54
|
+
type: 'root';
|
|
55
|
+
children: ViewDocumentNode[];
|
|
56
|
+
};
|
|
57
|
+
export type ViewSectionCommandOutput = {
|
|
58
|
+
output: string;
|
|
59
|
+
tree: ViewDocumentTree;
|
|
60
|
+
isError: boolean;
|
|
61
|
+
};
|
|
62
|
+
export type ViewProjectGeneration = {
|
|
34
63
|
generation: number;
|
|
35
64
|
markdownGeneration: number;
|
|
36
65
|
};
|
|
66
|
+
export type ViewProjectChange = ViewProjectGeneration & {
|
|
67
|
+
instanceId: string;
|
|
68
|
+
};
|
|
37
69
|
export type ViewGraphNodeKind = 'document' | 'source' | 'code-reference';
|
|
38
70
|
export type ViewGraphNode = {
|
|
39
71
|
id: string;
|
|
@@ -49,6 +81,7 @@ export type ViewGraphNode = {
|
|
|
49
81
|
symbol?: string;
|
|
50
82
|
line?: number;
|
|
51
83
|
snippet?: string;
|
|
84
|
+
externalTarget?: string;
|
|
52
85
|
gitStatus?: ViewGitFileStatus;
|
|
53
86
|
errorCount?: number;
|
|
54
87
|
};
|
|
@@ -75,8 +108,8 @@ export type ViewDocumentTocItem = {
|
|
|
75
108
|
export type ViewDocument = {
|
|
76
109
|
path: string;
|
|
77
110
|
title: string;
|
|
78
|
-
|
|
79
|
-
|
|
111
|
+
tree: ViewDocumentTree;
|
|
112
|
+
gitTree: ViewDocumentTree | null;
|
|
80
113
|
graphNodeIds: Record<string, string>;
|
|
81
114
|
tableOfContents: ViewDocumentTocItem[];
|
|
82
115
|
errors: ViewDocumentError[];
|
|
@@ -85,12 +118,23 @@ export type ViewDocument = {
|
|
|
85
118
|
requireCodeMention: boolean;
|
|
86
119
|
};
|
|
87
120
|
};
|
|
121
|
+
export type ViewDocumentSource = {
|
|
122
|
+
path: string;
|
|
123
|
+
content: string;
|
|
124
|
+
};
|
|
125
|
+
export type ViewDocumentEditRequest = {
|
|
126
|
+
baseContent: string;
|
|
127
|
+
content: string;
|
|
128
|
+
};
|
|
129
|
+
export type ViewDocumentEditResponse = ViewDocumentSource & {
|
|
130
|
+
merged: boolean;
|
|
131
|
+
};
|
|
88
132
|
export type ViewMarkdownBackReference = {
|
|
89
133
|
kind: 'markdown';
|
|
90
134
|
sectionId: string;
|
|
91
135
|
breadcrumbs: string[];
|
|
92
136
|
paragraph: string;
|
|
93
|
-
|
|
137
|
+
paragraphTree: ViewDocumentTree;
|
|
94
138
|
url: string;
|
|
95
139
|
};
|
|
96
140
|
export type ViewCodeBackReference = {
|
|
@@ -110,13 +154,13 @@ export type ViewSourceReference = {
|
|
|
110
154
|
sectionId: string;
|
|
111
155
|
breadcrumbs: string[];
|
|
112
156
|
paragraph: string;
|
|
113
|
-
|
|
157
|
+
paragraphTree: ViewDocumentTree;
|
|
114
158
|
url: string;
|
|
115
159
|
};
|
|
116
160
|
export type ViewSourceDocument = {
|
|
117
161
|
path: string;
|
|
118
162
|
content: string;
|
|
119
|
-
|
|
163
|
+
highlightedLines: ViewDocumentTree[];
|
|
120
164
|
focus: {
|
|
121
165
|
symbol: string;
|
|
122
166
|
kind: string;
|
|
@@ -127,6 +171,15 @@ export type ViewSourceDocument = {
|
|
|
127
171
|
context: ViewSourceReference | null;
|
|
128
172
|
otherReferences: ViewSourceReference[];
|
|
129
173
|
};
|
|
174
|
+
export type ViewExternalDocument = {
|
|
175
|
+
kind: 'markdown';
|
|
176
|
+
target: string;
|
|
177
|
+
document: ViewDocument;
|
|
178
|
+
} | {
|
|
179
|
+
kind: 'source';
|
|
180
|
+
target: string;
|
|
181
|
+
source: ViewSourceDocument;
|
|
182
|
+
};
|
|
130
183
|
export type ViewError = {
|
|
131
184
|
error: string;
|
|
132
185
|
};
|
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
import type { Root } from 'mdast';
|
|
2
1
|
import type { CodeRef } from '../code-refs.js';
|
|
3
|
-
import { type
|
|
2
|
+
import { type Section } from '../lattice-model.js';
|
|
3
|
+
import { type MarkdownFileAnalysis, type MarkdownParagraph } from '../markdown-analysis.js';
|
|
4
4
|
import { type WikiLinkResolver } from './markdown.js';
|
|
5
5
|
import type { ViewCodeBackReference, ViewSectionBackReferences, ViewSourceReference } from './protocol.js';
|
|
6
6
|
export type SourceReferenceOrigin = {
|
|
7
7
|
sectionId: string;
|
|
8
8
|
line: number;
|
|
9
9
|
};
|
|
10
|
-
type ParagraphContent =
|
|
11
|
-
|
|
12
|
-
startLine: number;
|
|
13
|
-
text: string;
|
|
14
|
-
};
|
|
15
|
-
type MarkdownLink = {
|
|
16
|
-
kind: 'image' | 'link';
|
|
17
|
-
line: number;
|
|
18
|
-
url: string;
|
|
19
|
-
};
|
|
20
|
-
export type ViewParsedMarkdownFile = {
|
|
21
|
-
absolutePath: string;
|
|
22
|
-
content: string;
|
|
23
|
-
path: string;
|
|
24
|
-
projectPath: string;
|
|
25
|
-
tree: Root;
|
|
26
|
-
sections: Section[];
|
|
27
|
-
wikiRefs: Ref[];
|
|
28
|
-
paragraphs: Map<number, ParagraphContent>;
|
|
29
|
-
markdownLinks: MarkdownLink[];
|
|
30
|
-
validationLinks: MdLink[];
|
|
31
|
-
};
|
|
10
|
+
type ParagraphContent = MarkdownParagraph;
|
|
11
|
+
export type ViewParsedMarkdownFile = MarkdownFileAnalysis;
|
|
32
12
|
export type ViewCodeReferenceFile = {
|
|
33
13
|
path: string;
|
|
34
14
|
lines: string[];
|
|
@@ -48,12 +28,17 @@ export type ViewReferenceIndex = {
|
|
|
48
28
|
incomingBySection: ReadonlyMap<string, readonly IndexedBackReference[]>;
|
|
49
29
|
sourceByTarget: ReadonlyMap<string, readonly IndexedMarkdownReference[]>;
|
|
50
30
|
sourceReferenceCounts: ReadonlyMap<string, number>;
|
|
31
|
+
externalByTarget: ReadonlyMap<string, readonly IndexedBackReference[]>;
|
|
51
32
|
};
|
|
52
33
|
/** Parse one Markdown file once into every structure needed by the view store. */
|
|
53
34
|
export declare function parseViewMarkdownFile(absolutePath: string, content: string, latDir: string, projectRoot: string): ViewParsedMarkdownFile;
|
|
54
35
|
export declare function linkedSection(url: string, sourcePath: string, sectionsByPath: ReadonlyMap<string, Section[]>): Section | null;
|
|
55
36
|
/** Resolve cached outgoing occurrences into direct section and source indexes. */
|
|
56
|
-
export declare function buildViewReferenceIndex(markdownFiles: Iterable<ViewParsedMarkdownFile>, codeFiles: Iterable<ViewCodeReferenceFile>, allSections: Section[]): ViewReferenceIndex;
|
|
37
|
+
export declare function buildViewReferenceIndex(markdownFiles: Iterable<ViewParsedMarkdownFile>, codeFiles: Iterable<ViewCodeReferenceFile>, allSections: Section[], resolveExternalTarget?: (target: string) => string | null): ViewReferenceIndex;
|
|
38
|
+
/** Render exact local Markdown and code backlinks for external targets. */
|
|
39
|
+
export declare function renderExternalSectionBackReferences(index: ViewReferenceIndex, targets: ReadonlyMap<string, string>, latDir: string, projectRoot: string, createWikiLinkResolver?: (requestedPath: string) => Promise<WikiLinkResolver>): Promise<ViewSectionBackReferences[]>;
|
|
40
|
+
/** Adapt exact external backlinks to the source context presentation. */
|
|
41
|
+
export declare function renderExternalSourceReferences(index: ViewReferenceIndex, target: string, latDir: string, projectRoot: string, createWikiLinkResolver?: (requestedPath: string) => Promise<WikiLinkResolver>): Promise<ViewSourceReference[]>;
|
|
57
42
|
/** Render direct reverse-index entries for the sections visible in one file. */
|
|
58
43
|
export declare function renderSectionBackReferences(index: ViewReferenceIndex, visibleSections: Section[], latDir: string, projectRoot: string, createWikiLinkResolver?: (requestedPath: string) => Promise<WikiLinkResolver>): Promise<ViewSectionBackReferences[]>;
|
|
59
44
|
/** Render cached Markdown occurrences that point to one source target. */
|