@plebeiantech/lat.md 0.12.3-fork.2 → 0.12.3-fork.21
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 +31 -2
- package/dist/src/cli/agent-invocation.d.ts +6 -0
- package/dist/src/cli/agent-invocation.js +23 -0
- package/dist/src/cli/checklist-menu.d.ts +2 -1
- package/dist/src/cli/checklist-menu.js +3 -2
- package/dist/src/cli/comment-guard.d.ts +14 -0
- package/dist/src/cli/comment-guard.js +10 -33
- package/dist/src/cli/comment-reminder.d.ts +65 -6
- package/dist/src/cli/comment-reminder.js +164 -28
- package/dist/src/cli/fork-instructions.d.ts +20 -0
- package/dist/src/cli/fork-instructions.js +184 -0
- package/dist/src/cli/fork-scaffold.d.ts +106 -0
- package/dist/src/cli/fork-scaffold.js +490 -0
- package/dist/src/cli/graph.d.ts +1 -1
- package/dist/src/cli/hook.d.ts +26 -0
- package/dist/src/cli/hook.js +115 -64
- package/dist/src/cli/index.js +166 -64
- package/dist/src/cli/init-preferences.d.ts +4 -0
- package/dist/src/cli/init-preferences.js +36 -0
- package/dist/src/cli/init.d.ts +2 -1
- package/dist/src/cli/init.js +107 -50
- package/dist/src/cli/reindex.d.ts +1 -1
- package/dist/src/cli/reindex.js +7 -10
- package/dist/src/cli/search.d.ts +14 -4
- package/dist/src/cli/search.js +116 -100
- package/dist/src/cli/ui-build-server.d.ts +12 -0
- package/dist/src/cli/ui-build-server.js +26 -0
- package/dist/src/cli/ui-build.d.ts +4 -0
- package/dist/src/cli/ui-build.js +13 -0
- package/dist/src/cli/ui.d.ts +1 -1
- package/dist/src/cli/ui.js +18 -2
- 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/upstream-drift-cli.js +2 -0
- package/dist/src/fork/upstream-drift.d.ts +26 -0
- package/dist/src/fork/upstream-drift.js +185 -0
- package/dist/src/fork/upstream-guard-cli.d.ts +1 -0
- package/dist/src/fork/upstream-guard-cli.js +2 -0
- package/dist/src/fork/upstream-guard.d.ts +72 -0
- package/dist/src/fork/upstream-guard.js +445 -0
- package/dist/src/graph-export.d.ts +2 -0
- package/dist/src/graph-export.js +38 -19
- package/dist/src/knowledge/claude-memory.d.ts +1 -0
- package/dist/src/knowledge/claude-memory.js +33 -4
- package/dist/src/knowledge/index.js +2 -2
- package/dist/src/mcp/server.js +34 -18
- package/dist/src/search/cache.d.ts +3 -0
- package/dist/src/search/cache.js +104 -0
- package/dist/src/search/chunks.d.ts +23 -0
- package/dist/src/search/chunks.js +200 -0
- package/dist/src/search/db.d.ts +28 -16
- package/dist/src/search/db.js +106 -40
- package/dist/src/search/embedder.d.ts +2 -1
- package/dist/src/search/embedder.js +7 -6
- package/dist/src/search/index.d.ts +6 -2
- package/dist/src/search/index.js +176 -53
- package/dist/src/search/lexical.d.ts +6 -0
- package/dist/src/search/lexical.js +36 -0
- package/dist/src/search/lock.d.ts +5 -0
- package/dist/src/search/lock.js +45 -0
- package/dist/src/search/query.d.ts +26 -0
- package/dist/src/search/query.js +103 -0
- package/dist/src/search/search.d.ts +17 -7
- package/dist/src/search/search.js +164 -14
- package/dist/src/search/types.d.ts +15 -0
- package/dist/src/search/types.js +1 -0
- package/dist/src/view/client/assets/GraphView-0bPe_Q5I.js +456 -0
- 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-1_8mI7lO.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/_commonjsHelpers-CqkleIqs.js +1 -0
- package/dist/src/view/client/assets/abnfDiagram-VCTEODGH-BLIuikwY.js +1 -0
- package/dist/src/view/client/assets/arc-D4PzdKSA.js +1 -0
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-35Egww62.js +36 -0
- package/dist/src/view/client/assets/blockDiagram-I7D4REHJ-tqNy53-W.js +129 -0
- package/dist/src/view/client/assets/c4Diagram-7LVT6UL2-DZ_GcD9K.js +38 -0
- package/dist/src/view/client/assets/channel-DensupHE.js +1 -0
- package/dist/src/view/client/assets/chunk-2Q5K7J3B-BUjq4Q7b.js +1 -0
- package/dist/src/view/client/assets/chunk-5VM5RSS4-BsIix6I5.js +15 -0
- package/dist/src/view/client/assets/chunk-F27PBJKO-Dxo7UheG.js +1 -0
- package/dist/src/view/client/assets/chunk-IMKFNOWR-C5lzUDK5.js +231 -0
- package/dist/src/view/client/assets/chunk-JWPE2WC7-qCHQlKfY.js +1 -0
- package/dist/src/view/client/assets/chunk-POPQ4Y6H-CDPKw21I.js +1 -0
- package/dist/src/view/client/assets/chunk-SVP7TREG-CD_C-9M-.js +88 -0
- package/dist/src/view/client/assets/chunk-TICWLB2K-ZMatRvad.js +206 -0
- package/dist/src/view/client/assets/chunk-XXDRQBXY-dDs4quwg.js +1 -0
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-CV7ArHLW.js +1 -0
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-CV7ArHLW.js +1 -0
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-CwH3-T1N.js +1 -0
- package/dist/src/view/client/assets/cynefin-OW5HDTMX-DodS6r00.js +166 -0
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-D7WDoy0K.js +62 -0
- package/dist/src/view/client/assets/cytoscape.esm-DzSz-X2X.js +321 -0
- package/dist/src/view/client/assets/dagre-GXQ25YYZ-yc2GTi5h.js +4 -0
- package/dist/src/view/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/src/view/client/assets/diagram-S7CK7UJ4-CEP0FGL8.js +30 -0
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-BZIEojBf.js +41 -0
- package/dist/src/view/client/assets/diagram-VSXAHHWV-BSB6COmM.js +3 -0
- package/dist/src/view/client/assets/diagram-VX7I27RA-DqfR3psV.js +24 -0
- package/dist/src/view/client/assets/diagram-Z3DM3KII-B79t0s5P.js +24 -0
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-CqbCQhE1.js +1 -0
- package/dist/src/view/client/assets/erDiagram-RLTQ6QDP-BVfoYIhJ.js +99 -0
- package/dist/src/view/client/assets/flowDiagram-HODETNUW-Dfyjm6ib.js +168 -0
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-Da9ta_k3.js +292 -0
- package/dist/src/view/client/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/src/view/client/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/src/view/client/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/src/view/client/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/dist/src/view/client/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/src/view/client/assets/gitGraphDiagram-WWUBYQGX-BDqlQ6LG.js +106 -0
- package/dist/src/view/client/assets/index-BnENo9bV.js +1 -0
- package/dist/src/view/client/assets/index-DG0Ez15D.css +1 -0
- package/dist/src/view/client/assets/index-heNSjszK.js +13 -0
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-CozIUYm1.js +2 -0
- package/dist/src/view/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/src/view/client/assets/ishikawaDiagram-5VMMS53U-tkBLr-Tn.js +70 -0
- package/dist/src/view/client/assets/journeyDiagram-3NMN7TZE-Dcd_Ofwc.js +139 -0
- package/dist/src/view/client/assets/kanban-definition-UXKFOSKX-CQvZmdAf.js +89 -0
- package/dist/src/view/client/assets/katex-HP8lGamR.js +257 -0
- package/dist/src/view/client/assets/layout-BxuGL0Ip.js +1 -0
- package/dist/src/view/client/assets/linear-D8tR6G5K.js +1 -0
- package/dist/src/view/client/assets/logo-RR_KBOAT.svg +149 -0
- package/dist/src/view/client/assets/maplibre-gl-CDX6Zuow.js +800 -0
- package/dist/src/view/client/assets/mermaid.core-BlHZooLK.js +310 -0
- package/dist/src/view/client/assets/mindmap-definition-YA3MSWOX-BqvVz5lC.js +96 -0
- package/dist/src/view/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-BkbOOTxX.js +1 -0
- package/dist/src/view/client/assets/pieDiagram-E7YTZNPT-BToTpG0m.js +39 -0
- package/dist/src/view/client/assets/quadrantDiagram-AXDQQJYC-CerD2TfT.js +7 -0
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-B2oElPYD.js +1 -0
- package/dist/src/view/client/assets/requirementDiagram-BXWQKSXE-BCL8RGFd.js +84 -0
- package/dist/src/view/client/assets/sankeyDiagram-P5KCCOFB-BqnkNRPm.js +40 -0
- package/dist/src/view/client/assets/sequenceDiagram-WJ2MYXX4-DKSKYknp.js +162 -0
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-D8reQ7IM.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-B-Eme-BN.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-yXL-Y-Ym.js +1 -0
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-lK0158X4.js +1 -0
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-CGn5WOGw.js +8 -0
- package/dist/src/view/client/assets/three.module-PDSP0dbZ.js +4108 -0
- package/dist/src/view/client/assets/timeline-definition-24CTP7MA-imh-edhJ.js +120 -0
- package/dist/src/view/client/assets/vennDiagram-4TSXK5OY-Ixwhcd6r.js +34 -0
- package/dist/src/view/client/assets/wardleyDiagram-VM6X3IG4-Cvr_zzKI.js +78 -0
- package/dist/src/view/client/assets/xychartDiagram-S5SC5T6Z-BvcmHKlQ.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 +14 -0
- package/dist/src/view/document-route.js +126 -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 +205 -1
- package/dist/src/view/git.js +1 -1
- package/dist/src/view/graph.d.ts +7 -0
- package/dist/src/view/graph.js +267 -0
- package/dist/src/view/highlight.d.ts +10 -2
- package/dist/src/view/highlight.js +50648 -3166
- package/dist/src/view/markdown.d.ts +8 -3
- package/dist/src/view/markdown.js +311 -41
- package/dist/src/view/preindexed-search.d.ts +15 -0
- package/dist/src/view/preindexed-search.js +25 -0
- package/dist/src/view/protocol.d.ts +95 -6
- package/dist/src/view/protocol.js +1 -1
- package/dist/src/view/publication.d.ts +2 -0
- package/dist/src/view/publication.js +78 -0
- package/dist/src/view/references.d.ts +13 -26
- package/dist/src/view/references.js +150 -119
- package/dist/src/view/repository.d.ts +18 -5
- package/dist/src/view/repository.js +269 -27
- package/dist/src/view/request-security.d.ts +5 -0
- package/dist/src/view/request-security.js +46 -0
- package/dist/src/view/search-result.d.ts +4 -0
- package/dist/src/view/search-result.js +25 -0
- package/dist/src/view/search.d.ts +7 -2
- package/dist/src/view/search.js +23 -33
- package/dist/src/view/server-build.d.ts +21 -0
- package/dist/src/view/server-build.js +145 -0
- package/dist/src/view/server-deployment.d.ts +31 -0
- package/dist/src/view/server-deployment.js +94 -0
- package/dist/src/view/server-index-worker.d.ts +6 -0
- package/dist/src/view/server-index-worker.js +14 -0
- package/dist/src/view/server.d.ts +14 -2
- package/dist/src/view/server.js +254 -51
- package/dist/src/view/source-target.d.ts +10 -0
- package/dist/src/view/source-target.js +43 -0
- package/dist/src/view/static-build.d.ts +32 -0
- package/dist/src/view/static-build.js +741 -0
- package/dist/src/view/static-protocol.d.ts +47 -0
- package/dist/src/view/static-protocol.js +15 -0
- package/dist/src/view/store.d.ts +26 -3
- package/dist/src/view/store.js +325 -44
- package/dist/src/view/table-of-contents.d.ts +9 -0
- package/dist/src/view/table-of-contents.js +83 -0
- package/dist/src/view/vercel-build.d.ts +24 -0
- package/dist/src/view/vercel-build.js +140 -0
- package/dist/src/view/vercel-server-build.d.ts +10 -0
- package/dist/src/view/vercel-server-build.js +61 -0
- 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 +72 -25
- 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 +19 -20
- package/templates/cursor-rules.md +14 -7
- package/templates/fork/conventions.md +173 -0
- package/templates/opencode-plugin.ts +9 -9
- package/templates/pi-extension.ts +11 -11
- package/templates/skill/SKILL.md +28 -17
- package/dist/src/cli/check-frontmatter.d.ts +0 -12
- package/dist/src/cli/check-frontmatter.js +0 -44
- package/dist/src/cli/check-mode.d.ts +0 -6
- package/dist/src/cli/check-mode.js +0 -303
- package/dist/src/cli/check-status.d.ts +0 -74
- package/dist/src/cli/check-status.js +0 -217
- package/dist/src/cli/check.d.ts +0 -45
- package/dist/src/cli/check.js +0 -777
- package/dist/src/cli/context.d.ts +0 -11
- package/dist/src/cli/context.js +0 -58
- package/dist/src/cli/expand.d.ts +0 -8
- package/dist/src/cli/expand.js +0 -94
- package/dist/src/cli/gen-index.d.ts +0 -45
- package/dist/src/cli/gen-index.js +0 -235
- package/dist/src/cli/link-scheme.d.ts +0 -54
- package/dist/src/cli/link-scheme.js +0 -101
- package/dist/src/cli/locate.d.ts +0 -2
- package/dist/src/cli/locate.js +0 -17
- package/dist/src/cli/refs.d.ts +0 -22
- package/dist/src/cli/refs.js +0 -229
- package/dist/src/cli/section.d.ts +0 -43
- package/dist/src/cli/section.js +0 -252
- package/dist/src/cli/select-menu.d.ts +0 -13
- package/dist/src/cli/select-menu.js +0 -100
- package/dist/src/code-refs.d.ts +0 -17
- package/dist/src/code-refs.js +0 -277
- package/dist/src/config.d.ts +0 -29
- package/dist/src/config.js +0 -83
- package/dist/src/context.d.ts +0 -23
- package/dist/src/context.js +0 -11
- package/dist/src/extensions/wiki-link/from-markdown.d.ts +0 -5
- package/dist/src/extensions/wiki-link/from-markdown.js +0 -34
- package/dist/src/extensions/wiki-link/index.d.ts +0 -4
- package/dist/src/extensions/wiki-link/index.js +0 -3
- package/dist/src/extensions/wiki-link/syntax.d.ts +0 -14
- package/dist/src/extensions/wiki-link/syntax.js +0 -121
- package/dist/src/extensions/wiki-link/to-markdown.d.ts +0 -5
- package/dist/src/extensions/wiki-link/to-markdown.js +0 -28
- package/dist/src/extensions/wiki-link/types.d.ts +0 -34
- package/dist/src/format.d.ts +0 -8
- package/dist/src/format.js +0 -43
- package/dist/src/init-version.d.ts +0 -10
- package/dist/src/init-version.js +0 -49
- package/dist/src/lattice.d.ts +0 -108
- package/dist/src/lattice.js +0 -816
- package/dist/src/parser.d.ts +0 -3
- package/dist/src/parser.js +0 -18
- package/dist/src/source-parser.d.ts +0 -27
- package/dist/src/source-parser.js +0 -916
- package/dist/src/untrusted.d.ts +0 -24
- package/dist/src/untrusted.js +0 -97
- package/dist/src/view/client/assets/index-B0n0u03y.css +0 -1
- package/dist/src/view/client/assets/index-xm2_px4q.js +0 -23
- package/dist/src/walk.d.ts +0 -18
- package/dist/src/walk.js +0 -27
- /package/dist/src/{extensions/wiki-link/types.js → fork/upstream-drift-cli.d.ts} +0 -0
|
@@ -1,8 +1,13 @@
|
|
|
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
|
};
|
|
5
|
-
export type
|
|
6
|
+
export type WikiLinkResolution = {
|
|
7
|
+
href: string;
|
|
8
|
+
referenceCount: number;
|
|
9
|
+
};
|
|
10
|
+
export type WikiLinkResolver = (target: string, context: WikiLinkContext) => WikiLinkResolution | null | Promise<WikiLinkResolution | null>;
|
|
6
11
|
export type MarkdownRenderOptions = {
|
|
7
12
|
activeMarkdownLink?: string;
|
|
8
13
|
activeWikiLink?: string;
|
|
@@ -15,8 +20,8 @@ export type MarkdownRenderOptions = {
|
|
|
15
20
|
lineOffset?: number;
|
|
16
21
|
rewriteMarkdownLink?: (url: string) => string;
|
|
17
22
|
};
|
|
18
|
-
/**
|
|
23
|
+
/** Normalize a lat.md file into the safe, parser-neutral view tree. */
|
|
19
24
|
export declare function renderMarkdown(markdown: string, filePath: string, resolveWikiLink?: WikiLinkResolver, options?: MarkdownRenderOptions, parsedTree?: Root): Promise<{
|
|
20
|
-
|
|
25
|
+
tree: ViewDocumentTree;
|
|
21
26
|
title: string;
|
|
22
27
|
}>;
|
|
@@ -1,28 +1,83 @@
|
|
|
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
|
-
import { parse } from '
|
|
10
|
+
import { parse } from '@plebeiantech/lat.md-core/parser';
|
|
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',
|
|
12
16
|
'code-link-language',
|
|
17
|
+
'code-link-leading',
|
|
13
18
|
'code-language-ts',
|
|
14
19
|
'code-language-js',
|
|
15
20
|
'code-language-py',
|
|
21
|
+
'code-language-rb',
|
|
16
22
|
'code-language-rs',
|
|
17
23
|
'code-language-go',
|
|
18
24
|
'code-language-c',
|
|
25
|
+
'code-language-dart',
|
|
26
|
+
'code-language-java',
|
|
27
|
+
'code-language-swift',
|
|
19
28
|
];
|
|
20
29
|
const ERROR_CLASS = 'markdown-error';
|
|
21
30
|
const GIT_CLASSES = ['git-added', 'git-removed'];
|
|
22
|
-
|
|
31
|
+
const GEOJSON_SOURCE_CLASS = 'markdown-geojson-source';
|
|
32
|
+
const HIGHLIGHT_CLASS = 'hljs';
|
|
33
|
+
const MERMAID_SOURCE_CLASS = 'markdown-mermaid-source';
|
|
34
|
+
const MATH_DIFF_BLOCK_CLASS = 'git-math-block';
|
|
35
|
+
const RICH_FENCE_SOURCE_CLASS = 'markdown-diagram-source';
|
|
36
|
+
const STL_SOURCE_CLASS = 'markdown-stl-source';
|
|
37
|
+
const TOPOJSON_SOURCE_CLASS = 'markdown-topojson-source';
|
|
38
|
+
const ALERT_KINDS = ['note', 'tip', 'important', 'warning', 'caution'];
|
|
39
|
+
const ALERT_CLASSES = [
|
|
40
|
+
'markdown-alert',
|
|
41
|
+
'markdown-alert-title',
|
|
42
|
+
...ALERT_KINDS.map((kind) => `markdown-alert-${kind}`),
|
|
43
|
+
];
|
|
44
|
+
const GITHUB_CUSTOM_EMOJI = new Set([
|
|
45
|
+
'atom',
|
|
46
|
+
'basecamp',
|
|
47
|
+
'basecampy',
|
|
48
|
+
'bowtie',
|
|
49
|
+
'electron',
|
|
50
|
+
'feelsgood',
|
|
51
|
+
'finnadie',
|
|
52
|
+
'fishsticks',
|
|
53
|
+
'fu',
|
|
54
|
+
'goberserk',
|
|
55
|
+
'godmode',
|
|
56
|
+
'hurtrealbad',
|
|
57
|
+
'neckbeard',
|
|
58
|
+
'octocat',
|
|
59
|
+
'rage1',
|
|
60
|
+
'rage2',
|
|
61
|
+
'rage3',
|
|
62
|
+
'rage4',
|
|
63
|
+
'shipit',
|
|
64
|
+
'suspect',
|
|
65
|
+
'trollface',
|
|
66
|
+
]);
|
|
67
|
+
function classAttributes(tag, extraClasses = []) {
|
|
68
|
+
const attributes = defaultSchema.attributes?.[tag] ?? [];
|
|
69
|
+
const allowedClasses = attributes.flatMap((attribute) => Array.isArray(attribute) && attribute[0] === 'className'
|
|
70
|
+
? attribute.slice(1)
|
|
71
|
+
: []);
|
|
23
72
|
return [
|
|
24
|
-
...(
|
|
25
|
-
[
|
|
73
|
+
...attributes.filter((attribute) => !(Array.isArray(attribute) && attribute[0] === 'className')),
|
|
74
|
+
[
|
|
75
|
+
'className',
|
|
76
|
+
...allowedClasses,
|
|
77
|
+
ERROR_CLASS,
|
|
78
|
+
...GIT_CLASSES,
|
|
79
|
+
...extraClasses,
|
|
80
|
+
],
|
|
26
81
|
];
|
|
27
82
|
}
|
|
28
83
|
const sanitizeSchema = {
|
|
@@ -43,39 +98,146 @@ const sanitizeSchema = {
|
|
|
43
98
|
],
|
|
44
99
|
],
|
|
45
100
|
blockquote: classAttributes('blockquote'),
|
|
46
|
-
code: classAttributes('code'
|
|
101
|
+
code: classAttributes('code', [
|
|
102
|
+
HIGHLIGHT_CLASS,
|
|
103
|
+
'math-display',
|
|
104
|
+
'math-inline',
|
|
105
|
+
]),
|
|
47
106
|
del: classAttributes('del'),
|
|
48
|
-
|
|
107
|
+
details: [...(defaultSchema.attributes?.details ?? []), ['open', true]],
|
|
108
|
+
div: classAttributes('div', [...ALERT_CLASSES, MATH_DIFF_BLOCK_CLASS]),
|
|
49
109
|
h1: classAttributes('h1'),
|
|
50
110
|
h2: classAttributes('h2'),
|
|
51
111
|
h3: classAttributes('h3'),
|
|
52
112
|
h4: classAttributes('h4'),
|
|
53
113
|
h5: classAttributes('h5'),
|
|
54
114
|
h6: classAttributes('h6'),
|
|
55
|
-
img: classAttributes('img'),
|
|
115
|
+
img: classAttributes('img', ['markdown-emoji']),
|
|
116
|
+
input: [...(defaultSchema.attributes?.input ?? []), ['checked', true]],
|
|
56
117
|
ins: classAttributes('ins'),
|
|
57
118
|
li: classAttributes('li'),
|
|
58
|
-
|
|
59
|
-
|
|
119
|
+
ol: classAttributes('ol'),
|
|
120
|
+
p: classAttributes('p', ALERT_CLASSES),
|
|
121
|
+
pre: classAttributes('pre', [
|
|
122
|
+
GEOJSON_SOURCE_CLASS,
|
|
123
|
+
MERMAID_SOURCE_CLASS,
|
|
124
|
+
RICH_FENCE_SOURCE_CLASS,
|
|
125
|
+
STL_SOURCE_CLASS,
|
|
126
|
+
TOPOJSON_SOURCE_CLASS,
|
|
127
|
+
]),
|
|
60
128
|
span: [
|
|
61
129
|
...(defaultSchema.attributes?.span ?? []),
|
|
62
130
|
'ariaHidden',
|
|
131
|
+
'ariaLabel',
|
|
132
|
+
'role',
|
|
63
133
|
[
|
|
64
134
|
'className',
|
|
65
135
|
'wiki-link-context',
|
|
66
136
|
'wiki-link-leaf',
|
|
137
|
+
'wiki-link-ref-count',
|
|
67
138
|
...CODE_LINK_CLASSES.slice(2),
|
|
139
|
+
/^hljs-./,
|
|
68
140
|
ERROR_CLASS,
|
|
69
141
|
...GIT_CLASSES,
|
|
70
142
|
],
|
|
71
143
|
],
|
|
144
|
+
table: classAttributes('table'),
|
|
145
|
+
tr: classAttributes('tr'),
|
|
146
|
+
ul: classAttributes('ul'),
|
|
72
147
|
},
|
|
73
148
|
};
|
|
74
|
-
const
|
|
75
|
-
|
|
149
|
+
const highlightedCodeHandler = (state, rawNode) => {
|
|
150
|
+
const node = rawNode;
|
|
151
|
+
const language = node.lang?.split(/\s+/, 1)[0];
|
|
152
|
+
const richSourceClass = language?.toLowerCase() === 'mermaid'
|
|
153
|
+
? MERMAID_SOURCE_CLASS
|
|
154
|
+
: language?.toLowerCase() === 'geojson'
|
|
155
|
+
? GEOJSON_SOURCE_CLASS
|
|
156
|
+
: language?.toLowerCase() === 'topojson'
|
|
157
|
+
? TOPOJSON_SOURCE_CLASS
|
|
158
|
+
: language?.toLowerCase() === 'stl'
|
|
159
|
+
? STL_SOURCE_CLASS
|
|
160
|
+
: null;
|
|
161
|
+
const highlighted = language && !richSourceClass ? highlightCode(language, node.value) : null;
|
|
162
|
+
const code = {
|
|
163
|
+
type: 'element',
|
|
164
|
+
tagName: 'code',
|
|
165
|
+
properties: {
|
|
166
|
+
className: [
|
|
167
|
+
...(language ? [`language-${language}`] : []),
|
|
168
|
+
...(highlighted === null ? [] : [HIGHLIGHT_CLASS]),
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
children: highlighted === null
|
|
172
|
+
? [
|
|
173
|
+
{
|
|
174
|
+
type: 'text',
|
|
175
|
+
value: node.value ? `${node.value}\n` : '',
|
|
176
|
+
},
|
|
177
|
+
]
|
|
178
|
+
: [...highlighted.children, { type: 'text', value: '\n' }],
|
|
179
|
+
...(node.meta ? { data: { meta: node.meta } } : {}),
|
|
180
|
+
};
|
|
181
|
+
state.patch(node, code);
|
|
182
|
+
const result = state.applyData(node, code);
|
|
183
|
+
const pre = {
|
|
184
|
+
type: 'element',
|
|
185
|
+
tagName: 'pre',
|
|
186
|
+
properties: {
|
|
187
|
+
className: richSourceClass
|
|
188
|
+
? [RICH_FENCE_SOURCE_CLASS, richSourceClass]
|
|
189
|
+
: [],
|
|
190
|
+
},
|
|
191
|
+
children: [result],
|
|
192
|
+
};
|
|
193
|
+
state.patch(node, pre);
|
|
194
|
+
return pre;
|
|
195
|
+
};
|
|
196
|
+
const documentTreeProcessor = unified()
|
|
197
|
+
.use(remarkRehype, {
|
|
198
|
+
allowDangerousHtml: true,
|
|
199
|
+
handlers: { code: highlightedCodeHandler },
|
|
200
|
+
})
|
|
201
|
+
.use(rehypeRaw)
|
|
76
202
|
.use(rehypeSanitize, sanitizeSchema)
|
|
77
|
-
.use(
|
|
78
|
-
.use(
|
|
203
|
+
.use(rehypeKatex)
|
|
204
|
+
.use(rehypeSlug);
|
|
205
|
+
const emojiProcessor = unified().use(remarkEmoji, { accessible: true });
|
|
206
|
+
function transformCustomEmoji(tree) {
|
|
207
|
+
visit(tree, 'text', (node, index, parent) => {
|
|
208
|
+
if (index === undefined || !parent || !node.value.includes(':'))
|
|
209
|
+
return;
|
|
210
|
+
const pattern = /:([a-z0-9_+-]+):/g;
|
|
211
|
+
const children = [];
|
|
212
|
+
let cursor = 0;
|
|
213
|
+
let match;
|
|
214
|
+
while ((match = pattern.exec(node.value))) {
|
|
215
|
+
if (!GITHUB_CUSTOM_EMOJI.has(match[1]))
|
|
216
|
+
continue;
|
|
217
|
+
if (match.index > cursor) {
|
|
218
|
+
children.push({
|
|
219
|
+
type: 'text',
|
|
220
|
+
value: node.value.slice(cursor, match.index),
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
children.push({
|
|
224
|
+
type: 'image',
|
|
225
|
+
url: `https://github.githubassets.com/images/icons/emoji/${match[1]}.png?v8`,
|
|
226
|
+
alt: match[0],
|
|
227
|
+
title: null,
|
|
228
|
+
data: { hProperties: { className: ['markdown-emoji'] } },
|
|
229
|
+
});
|
|
230
|
+
cursor = match.index + match[0].length;
|
|
231
|
+
}
|
|
232
|
+
if (children.length === 0)
|
|
233
|
+
return;
|
|
234
|
+
if (cursor < node.value.length) {
|
|
235
|
+
children.push({ type: 'text', value: node.value.slice(cursor) });
|
|
236
|
+
}
|
|
237
|
+
parent.children.splice(index, 1, ...children);
|
|
238
|
+
return index + children.length;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
79
241
|
function nodeText(node) {
|
|
80
242
|
if (typeof node.value === 'string')
|
|
81
243
|
return node.value;
|
|
@@ -85,6 +247,38 @@ function nodeText(node) {
|
|
|
85
247
|
.map((child) => nodeText(child))
|
|
86
248
|
.join('');
|
|
87
249
|
}
|
|
250
|
+
function transformAlerts(tree) {
|
|
251
|
+
visit(tree, 'blockquote', (node) => {
|
|
252
|
+
const firstBlock = node.children[0];
|
|
253
|
+
if (firstBlock?.type !== 'paragraph')
|
|
254
|
+
return;
|
|
255
|
+
const firstInline = firstBlock.children[0];
|
|
256
|
+
if (firstInline?.type !== 'alertMarker')
|
|
257
|
+
return;
|
|
258
|
+
const label = firstInline.value;
|
|
259
|
+
const kind = label.toLowerCase();
|
|
260
|
+
firstBlock.children.shift();
|
|
261
|
+
if (firstBlock.children.length === 0)
|
|
262
|
+
node.children.shift();
|
|
263
|
+
node.data = {
|
|
264
|
+
...node.data,
|
|
265
|
+
hName: 'div',
|
|
266
|
+
hProperties: {
|
|
267
|
+
...(node.data?.hProperties ?? {}),
|
|
268
|
+
className: ['markdown-alert', `markdown-alert-${kind}`],
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
node.children.unshift({
|
|
272
|
+
type: 'paragraph',
|
|
273
|
+
data: {
|
|
274
|
+
hProperties: { className: ['markdown-alert-title'] },
|
|
275
|
+
},
|
|
276
|
+
children: [
|
|
277
|
+
{ type: 'text', value: label[0] + label.slice(1).toLowerCase() },
|
|
278
|
+
],
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
}
|
|
88
282
|
function wikiLinkContent(node) {
|
|
89
283
|
if (node.data.alias) {
|
|
90
284
|
return {
|
|
@@ -131,6 +325,10 @@ function codeLanguage(target) {
|
|
|
131
325
|
return { className: 'code-language-js', label: 'JS' };
|
|
132
326
|
case '.py':
|
|
133
327
|
return { className: 'code-language-py', label: 'PY' };
|
|
328
|
+
case '.erb':
|
|
329
|
+
case '.rake':
|
|
330
|
+
case '.rb':
|
|
331
|
+
return { className: 'code-language-rb', label: 'RB' };
|
|
134
332
|
case '.rs':
|
|
135
333
|
return { className: 'code-language-rs', label: 'RS' };
|
|
136
334
|
case '.go':
|
|
@@ -138,6 +336,12 @@ function codeLanguage(target) {
|
|
|
138
336
|
case '.c':
|
|
139
337
|
case '.h':
|
|
140
338
|
return { className: 'code-language-c', label: 'C' };
|
|
339
|
+
case '.dart':
|
|
340
|
+
return { className: 'code-language-dart', label: 'DART' };
|
|
341
|
+
case '.swift':
|
|
342
|
+
return { className: 'code-language-swift', label: 'SWIFT' };
|
|
343
|
+
case '.java':
|
|
344
|
+
return { className: 'code-language-java', label: 'JAVA' };
|
|
141
345
|
default:
|
|
142
346
|
return null;
|
|
143
347
|
}
|
|
@@ -155,6 +359,45 @@ function languageIcon(language) {
|
|
|
155
359
|
children: [{ type: 'text', value: language.label }],
|
|
156
360
|
};
|
|
157
361
|
}
|
|
362
|
+
function codeLinkContent(language, children) {
|
|
363
|
+
const [first, ...rest] = children;
|
|
364
|
+
if (!first)
|
|
365
|
+
return [languageIcon(language)];
|
|
366
|
+
let leading = first;
|
|
367
|
+
let remainder = null;
|
|
368
|
+
if (first.type === 'text') {
|
|
369
|
+
const breakAt = first.value.search(/\s/);
|
|
370
|
+
if (breakAt > 0) {
|
|
371
|
+
leading = { ...first, value: first.value.slice(0, breakAt) };
|
|
372
|
+
remainder = { ...first, value: first.value.slice(breakAt) };
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return [
|
|
376
|
+
{
|
|
377
|
+
type: 'emphasis',
|
|
378
|
+
data: {
|
|
379
|
+
hName: 'span',
|
|
380
|
+
hProperties: { className: ['code-link-leading'] },
|
|
381
|
+
},
|
|
382
|
+
children: [languageIcon(language), leading],
|
|
383
|
+
},
|
|
384
|
+
...(remainder ? [remainder] : []),
|
|
385
|
+
...rest,
|
|
386
|
+
];
|
|
387
|
+
}
|
|
388
|
+
function referenceCountBadge(count) {
|
|
389
|
+
return {
|
|
390
|
+
type: 'emphasis',
|
|
391
|
+
data: {
|
|
392
|
+
hName: 'span',
|
|
393
|
+
hProperties: {
|
|
394
|
+
className: ['wiki-link-ref-count'],
|
|
395
|
+
ariaLabel: `${count} ${count === 1 ? 'reference' : 'references'}`,
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
children: [{ type: 'text', value: String(count) }],
|
|
399
|
+
};
|
|
400
|
+
}
|
|
158
401
|
function targetMatches(node, target) {
|
|
159
402
|
if (node.type === 'wikiLink') {
|
|
160
403
|
return node.value.toLowerCase() === target.toLowerCase();
|
|
@@ -223,30 +466,41 @@ function markMarkdownErrors(tree, errors) {
|
|
|
223
466
|
};
|
|
224
467
|
}
|
|
225
468
|
}
|
|
226
|
-
/**
|
|
469
|
+
/** Normalize a lat.md file into the safe, parser-neutral view tree. */
|
|
227
470
|
export async function renderMarkdown(markdown, filePath, resolveWikiLink, options = {}, parsedTree) {
|
|
228
471
|
const tree = parsedTree ? structuredClone(parsedTree) : parse(markdown);
|
|
229
472
|
tree.children = tree.children.filter((node) => node.type !== 'yaml');
|
|
473
|
+
await emojiProcessor.run(tree);
|
|
474
|
+
transformCustomEmoji(tree);
|
|
475
|
+
transformAlerts(tree);
|
|
230
476
|
if (options.errors)
|
|
231
477
|
markMarkdownErrors(tree, options.errors);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
node.data
|
|
238
|
-
|
|
239
|
-
hProperties
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
478
|
+
visit(tree, 'link', (node) => {
|
|
479
|
+
const authoredUrl = node.url;
|
|
480
|
+
if (options.activeMarkdownLink &&
|
|
481
|
+
authoredUrl === options.activeMarkdownLink) {
|
|
482
|
+
node.data = {
|
|
483
|
+
...node.data,
|
|
484
|
+
hProperties: {
|
|
485
|
+
...(node.data?.hProperties ?? {}),
|
|
486
|
+
className: ['wiki-link-active'],
|
|
487
|
+
},
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
if (options.rewriteMarkdownLink) {
|
|
491
|
+
node.url = options.rewriteMarkdownLink(authoredUrl);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
visit(tree, 'image', (node) => {
|
|
495
|
+
if (options.rewriteMarkdownLink) {
|
|
496
|
+
node.url = options.rewriteMarkdownLink(node.url);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
visit(tree, 'definition', (node) => {
|
|
500
|
+
if (options.rewriteMarkdownLink) {
|
|
501
|
+
node.url = options.rewriteMarkdownLink(node.url);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
250
504
|
const firstHeading = tree.children.find((node) => node.type === 'heading');
|
|
251
505
|
const title = firstHeading
|
|
252
506
|
? nodeText(firstHeading)
|
|
@@ -266,11 +520,12 @@ export async function renderMarkdown(markdown, filePath, resolveWikiLink, option
|
|
|
266
520
|
visit(tree, 'wikiLink', (node, index, parent) => {
|
|
267
521
|
if (index === undefined || !parent || !('children' in parent))
|
|
268
522
|
return;
|
|
269
|
-
const
|
|
523
|
+
const resolution = resolvedLinks.get(node);
|
|
270
524
|
const markedProperties = node.data?.hProperties;
|
|
271
|
-
if (
|
|
525
|
+
if (resolution) {
|
|
526
|
+
const { href, referenceCount } = resolution;
|
|
272
527
|
const content = wikiLinkContent(node);
|
|
273
|
-
const language = href.startsWith('/code/')
|
|
528
|
+
const language = href.startsWith('/code/') || href.startsWith('/external/')
|
|
274
529
|
? codeLanguage(node.value)
|
|
275
530
|
: null;
|
|
276
531
|
const classes = content.segmented ? ['wiki-link-segmented'] : [];
|
|
@@ -296,9 +551,12 @@ export async function renderMarkdown(markdown, filePath, resolveWikiLink, option
|
|
|
296
551
|
},
|
|
297
552
|
}
|
|
298
553
|
: undefined,
|
|
299
|
-
children:
|
|
300
|
-
|
|
301
|
-
|
|
554
|
+
children: [
|
|
555
|
+
...(language
|
|
556
|
+
? codeLinkContent(language, content.children)
|
|
557
|
+
: content.children),
|
|
558
|
+
...(referenceCount > 1 ? [referenceCountBadge(referenceCount)] : []),
|
|
559
|
+
],
|
|
302
560
|
};
|
|
303
561
|
return;
|
|
304
562
|
}
|
|
@@ -317,6 +575,18 @@ export async function renderMarkdown(markdown, filePath, resolveWikiLink, option
|
|
|
317
575
|
value: `[[${node.value}${alias}]]`,
|
|
318
576
|
};
|
|
319
577
|
});
|
|
320
|
-
const hast = await
|
|
321
|
-
|
|
578
|
+
const hast = await documentTreeProcessor.run(tree);
|
|
579
|
+
// Attach source ranges after sanitization, before positions are discarded.
|
|
580
|
+
visit(hast, 'element', (node) => {
|
|
581
|
+
if (!/^(p|pre|li|tr|h[1-6])$/.test(node.tagName) || !node.position)
|
|
582
|
+
return;
|
|
583
|
+
node.properties['data-source-start-line'] =
|
|
584
|
+
node.position.start.line + (options.lineOffset ?? 0);
|
|
585
|
+
node.properties['data-source-end-line'] =
|
|
586
|
+
node.position.end.line + (options.lineOffset ?? 0);
|
|
587
|
+
});
|
|
588
|
+
return {
|
|
589
|
+
tree: decorateExternalSiteLinks(toViewDocumentTree(hast)),
|
|
590
|
+
title,
|
|
591
|
+
};
|
|
322
592
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Section } from '@plebeiantech/lat.md-core/lattice-model';
|
|
2
|
+
import type { CreateSearchEngine } from '../search/embedder.js';
|
|
3
|
+
import { type IndexedSearchSession } from '../search/query.js';
|
|
4
|
+
import type { ViewSearchResponse } from './protocol.js';
|
|
5
|
+
export type PreindexedViewSearchDependencies = {
|
|
6
|
+
openSearchSession: (latDir: string, options: {
|
|
7
|
+
cacheDir?: string;
|
|
8
|
+
createSearchEngine?: CreateSearchEngine;
|
|
9
|
+
}) => Promise<IndexedSearchSession>;
|
|
10
|
+
};
|
|
11
|
+
export type PreindexedViewSearch = ((query: string) => Promise<ViewSearchResponse>) & {
|
|
12
|
+
close: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
/** Serve a built search index without importing indexing or Markdown parsers. */
|
|
15
|
+
export declare function createPreindexedViewSearch(latDir: string, cacheDir: string, sections: readonly Section[], documentPaths: ReadonlyMap<string, string>, dependencies?: PreindexedViewSearchDependencies, createSearchEngine?: CreateSearchEngine): Promise<PreindexedViewSearch>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { openIndexedSearchSession, resolveSearchMatches, } from '../search/query.js';
|
|
2
|
+
import { viewSearchResult } from './search-result.js';
|
|
3
|
+
const VIEW_SEARCH_LIMIT = 10;
|
|
4
|
+
/** Serve a built search index without importing indexing or Markdown parsers. */
|
|
5
|
+
export async function createPreindexedViewSearch(latDir, cacheDir, sections, documentPaths, dependencies = {
|
|
6
|
+
openSearchSession: openIndexedSearchSession,
|
|
7
|
+
}, createSearchEngine) {
|
|
8
|
+
const sectionById = new Map(sections.map((section) => [section.id.toLowerCase(), section]));
|
|
9
|
+
const session = await dependencies.openSearchSession(latDir, {
|
|
10
|
+
cacheDir,
|
|
11
|
+
createSearchEngine,
|
|
12
|
+
});
|
|
13
|
+
const search = async (rawQuery) => {
|
|
14
|
+
const query = rawQuery.trim();
|
|
15
|
+
if (!query)
|
|
16
|
+
return { query: '', results: [] };
|
|
17
|
+
const results = await session.search(query, VIEW_SEARCH_LIMIT);
|
|
18
|
+
return {
|
|
19
|
+
query,
|
|
20
|
+
results: resolveSearchMatches(results, sectionById).map((match) => viewSearchResult(latDir, match, documentPaths)),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
search.close = session.close;
|
|
24
|
+
return search;
|
|
25
|
+
}
|