@limetech/kompendium 1.1.1
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/LICENSE +21 -0
- package/README.md +313 -0
- package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +13 -0
- package/dist/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
- package/dist/cjs/anchor-scroll-BmplAyR0.js +69 -0
- package/dist/cjs/anchor-scroll-BmplAyR0.js.map +1 -0
- package/dist/cjs/index-DYiJ6dQL.js +1866 -0
- package/dist/cjs/index-DYiJ6dQL.js.map +1 -0
- package/dist/cjs/index.cjs.js +3 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/kompendium-app.kompendium-darkmode-switch.kompendium-navigation.kompendium-search.stencil-route.stencil-route-switch.stencil-router.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-app_7.cjs.entry.js +2924 -0
- package/dist/cjs/kompendium-code.cjs.entry.js +2724 -0
- package/dist/cjs/kompendium-code.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-component.cjs.entry.js +207 -0
- package/dist/cjs/kompendium-component.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-debug.cjs.entry.js +47 -0
- package/dist/cjs/kompendium-debug.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-example-code.cjs.entry.js +20 -0
- package/dist/cjs/kompendium-example-code.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-example-markdown.cjs.entry.js +165 -0
- package/dist/cjs/kompendium-example-markdown.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-guide.cjs.entry.js +33 -0
- package/dist/cjs/kompendium-guide.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-markdown.cjs.entry.js +48923 -0
- package/dist/cjs/kompendium-markdown.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-playground.cjs.entry.js +89 -0
- package/dist/cjs/kompendium-playground.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-proplist.kompendium-taglist.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-proplist_2.cjs.entry.js +49 -0
- package/dist/cjs/kompendium-type.cjs.entry.js +83 -0
- package/dist/cjs/kompendium-type.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium.cjs.js +25 -0
- package/dist/cjs/kompendium.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/markdown-types-B884tLd-.js +15 -0
- package/dist/cjs/markdown-types-B884tLd-.js.map +1 -0
- package/dist/cjs/methods-DoA78dOH.js +97 -0
- package/dist/cjs/methods-DoA78dOH.js.map +1 -0
- package/dist/cjs/types-SjA7Kcy_.js +8 -0
- package/dist/cjs/types-SjA7Kcy_.js.map +1 -0
- package/dist/collection/assets/favicon.svg +65 -0
- package/dist/collection/assets/icons/bookmark-fill.svg +1 -0
- package/dist/collection/assets/icons/danger.svg +1 -0
- package/dist/collection/assets/icons/debug.svg +1 -0
- package/dist/collection/assets/icons/important.svg +1 -0
- package/dist/collection/assets/icons/info.svg +1 -0
- package/dist/collection/assets/icons/logo.svg +1 -0
- package/dist/collection/assets/icons/note.svg +1 -0
- package/dist/collection/assets/icons/search.svg +1 -0
- package/dist/collection/assets/icons/tip.svg +1 -0
- package/dist/collection/assets/icons/warning.svg +1 -0
- package/dist/collection/assets/logotype.svg +64 -0
- package/dist/collection/collection-manifest.json +35 -0
- package/dist/collection/components/anchor-scroll.js +61 -0
- package/dist/collection/components/anchor-scroll.js.map +1 -0
- package/dist/collection/components/app/app.css +125 -0
- package/dist/collection/components/app/app.js +149 -0
- package/dist/collection/components/app/app.js.map +1 -0
- package/dist/collection/components/code/code.css +250 -0
- package/dist/collection/components/code/code.js +82 -0
- package/dist/collection/components/code/code.js.map +1 -0
- package/dist/collection/components/code/examples/code.js +14 -0
- package/dist/collection/components/code/examples/code.js.map +1 -0
- package/dist/collection/components/component/component.css +383 -0
- package/dist/collection/components/component/component.js +191 -0
- package/dist/collection/components/component/component.js.map +1 -0
- package/dist/collection/components/component/templates/events.js +32 -0
- package/dist/collection/components/component/templates/events.js.map +1 -0
- package/dist/collection/components/component/templates/examples.js +17 -0
- package/dist/collection/components/component/templates/examples.js.map +1 -0
- package/dist/collection/components/component/templates/methods.js +54 -0
- package/dist/collection/components/component/templates/methods.js.map +1 -0
- package/dist/collection/components/component/templates/props.js +36 -0
- package/dist/collection/components/component/templates/props.js.map +1 -0
- package/dist/collection/components/component/templates/slots.js +14 -0
- package/dist/collection/components/component/templates/slots.js.map +1 -0
- package/dist/collection/components/component/templates/style.js +14 -0
- package/dist/collection/components/component/templates/style.js.map +1 -0
- package/dist/collection/components/darkmode-switch/darkmode-switch.css +141 -0
- package/dist/collection/components/darkmode-switch/darkmode-switch.js +90 -0
- package/dist/collection/components/darkmode-switch/darkmode-switch.js.map +1 -0
- package/dist/collection/components/darkmode-switch/types.js +2 -0
- package/dist/collection/components/darkmode-switch/types.js.map +1 -0
- package/dist/collection/components/debug/debug.js +146 -0
- package/dist/collection/components/debug/debug.js.map +1 -0
- package/dist/collection/components/guide/guide.js +61 -0
- package/dist/collection/components/guide/guide.js.map +1 -0
- package/dist/collection/components/markdown/examples/markdown-example.js +150 -0
- package/dist/collection/components/markdown/examples/markdown-example.js.map +1 -0
- package/dist/collection/components/markdown/examples/markdown.js +14 -0
- package/dist/collection/components/markdown/examples/markdown.js.map +1 -0
- package/dist/collection/components/markdown/markdown-types.js +8 -0
- package/dist/collection/components/markdown/markdown-types.js.map +1 -0
- package/dist/collection/components/markdown/markdown.css +660 -0
- package/dist/collection/components/markdown/markdown.js +83 -0
- package/dist/collection/components/markdown/markdown.js.map +1 -0
- package/dist/collection/components/navigation/navigation.css +403 -0
- package/dist/collection/components/navigation/navigation.js +184 -0
- package/dist/collection/components/navigation/navigation.js.map +1 -0
- package/dist/collection/components/playground/playground.css +198 -0
- package/dist/collection/components/playground/playground.js +174 -0
- package/dist/collection/components/playground/playground.js.map +1 -0
- package/dist/collection/components/playground/playground.types.js +2 -0
- package/dist/collection/components/playground/playground.types.js.map +1 -0
- package/dist/collection/components/proplist/proplist.css +334 -0
- package/dist/collection/components/proplist/proplist.js +53 -0
- package/dist/collection/components/proplist/proplist.js.map +1 -0
- package/dist/collection/components/search/search.css +183 -0
- package/dist/collection/components/search/search.js +76 -0
- package/dist/collection/components/search/search.js.map +1 -0
- package/dist/collection/components/taglist/taglist.css +58 -0
- package/dist/collection/components/taglist/taglist.js +82 -0
- package/dist/collection/components/taglist/taglist.js.map +1 -0
- package/dist/collection/components/type/templates/alias.js +11 -0
- package/dist/collection/components/type/templates/alias.js.map +1 -0
- package/dist/collection/components/type/templates/enum.js +25 -0
- package/dist/collection/components/type/templates/enum.js.map +1 -0
- package/dist/collection/components/type/templates/interface.js +13 -0
- package/dist/collection/components/type/templates/interface.js.map +1 -0
- package/dist/collection/components/type/type.js +97 -0
- package/dist/collection/components/type/type.js.map +1 -0
- package/dist/collection/index.js +4 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/kompendium/config.js +7 -0
- package/dist/collection/kompendium/config.js.map +1 -0
- package/dist/collection/kompendium/filesystem.js +9 -0
- package/dist/collection/kompendium/filesystem.js.map +1 -0
- package/dist/collection/kompendium/generator.js +217 -0
- package/dist/collection/kompendium/generator.js.map +1 -0
- package/dist/collection/kompendium/guides.js +30 -0
- package/dist/collection/kompendium/guides.js.map +1 -0
- package/dist/collection/kompendium/index.js +2 -0
- package/dist/collection/kompendium/index.js.map +1 -0
- package/dist/collection/kompendium/markdown-admonitions.js +82 -0
- package/dist/collection/kompendium/markdown-admonitions.js.map +1 -0
- package/dist/collection/kompendium/markdown-code.js +40 -0
- package/dist/collection/kompendium/markdown-code.js.map +1 -0
- package/dist/collection/kompendium/markdown-frontmatter.js +12 -0
- package/dist/collection/kompendium/markdown-frontmatter.js.map +1 -0
- package/dist/collection/kompendium/markdown-nodes.js +10 -0
- package/dist/collection/kompendium/markdown-nodes.js.map +1 -0
- package/dist/collection/kompendium/markdown-typelinks.js +115 -0
- package/dist/collection/kompendium/markdown-typelinks.js.map +1 -0
- package/dist/collection/kompendium/markdown.js +35 -0
- package/dist/collection/kompendium/markdown.js.map +1 -0
- package/dist/collection/kompendium/menu.js +149 -0
- package/dist/collection/kompendium/menu.js.map +1 -0
- package/dist/collection/kompendium/schema.js +167 -0
- package/dist/collection/kompendium/schema.js.map +1 -0
- package/dist/collection/kompendium/search.js +144 -0
- package/dist/collection/kompendium/search.js.map +1 -0
- package/dist/collection/kompendium/source.js +81 -0
- package/dist/collection/kompendium/source.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/basic.js +48 -0
- package/dist/collection/kompendium/test/fixtures/basic.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/example-type.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/example-type.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/node-modules-type.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/node-modules-type.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/private-types.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/private-types.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/stencil-component-types.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/stencil-component-types.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/test-helper-type.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/test-helper-type.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/valid-types.js +29 -0
- package/dist/collection/kompendium/test/fixtures/filtering/valid-types.js.map +1 -0
- package/dist/collection/kompendium/typedoc.js +481 -0
- package/dist/collection/kompendium/typedoc.js.map +1 -0
- package/dist/collection/kompendium/watch.js +9 -0
- package/dist/collection/kompendium/watch.js.map +1 -0
- package/dist/collection/types.js +2 -0
- package/dist/collection/types.js.map +1 -0
- package/dist/config.ts +8 -0
- package/dist/esm/_commonjsHelpers-BFTU3MAI.js +10 -0
- package/dist/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
- package/dist/esm/anchor-scroll-BAGXN2n6.js +65 -0
- package/dist/esm/anchor-scroll-BAGXN2n6.js.map +1 -0
- package/dist/esm/index-9UrzenzW.js +1857 -0
- package/dist/esm/index-9UrzenzW.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/kompendium-app.kompendium-darkmode-switch.kompendium-navigation.kompendium-search.stencil-route.stencil-route-switch.stencil-router.entry.js.map +1 -0
- package/dist/esm/kompendium-app_7.entry.js +2916 -0
- package/dist/esm/kompendium-code.entry.js +2722 -0
- package/dist/esm/kompendium-code.entry.js.map +1 -0
- package/dist/esm/kompendium-component.entry.js +205 -0
- package/dist/esm/kompendium-component.entry.js.map +1 -0
- package/dist/esm/kompendium-debug.entry.js +45 -0
- package/dist/esm/kompendium-debug.entry.js.map +1 -0
- package/dist/esm/kompendium-example-code.entry.js +18 -0
- package/dist/esm/kompendium-example-code.entry.js.map +1 -0
- package/dist/esm/kompendium-example-markdown.entry.js +163 -0
- package/dist/esm/kompendium-example-markdown.entry.js.map +1 -0
- package/dist/esm/kompendium-guide.entry.js +31 -0
- package/dist/esm/kompendium-guide.entry.js.map +1 -0
- package/dist/esm/kompendium-markdown.entry.js +48921 -0
- package/dist/esm/kompendium-markdown.entry.js.map +1 -0
- package/dist/esm/kompendium-playground.entry.js +87 -0
- package/dist/esm/kompendium-playground.entry.js.map +1 -0
- package/dist/esm/kompendium-proplist.kompendium-taglist.entry.js.map +1 -0
- package/dist/esm/kompendium-proplist_2.entry.js +46 -0
- package/dist/esm/kompendium-type.entry.js +81 -0
- package/dist/esm/kompendium-type.entry.js.map +1 -0
- package/dist/esm/kompendium.js +21 -0
- package/dist/esm/kompendium.js.map +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/markdown-types-Ajsawr_9.js +12 -0
- package/dist/esm/markdown-types-Ajsawr_9.js.map +1 -0
- package/dist/esm/methods-BAjd6f7g.js +94 -0
- package/dist/esm/methods-BAjd6f7g.js.map +1 -0
- package/dist/esm/types-BIPLEi1G.js +6 -0
- package/dist/esm/types-BIPLEi1G.js.map +1 -0
- package/dist/filesystem.ts +9 -0
- package/dist/generator.ts +302 -0
- package/dist/guides.ts +49 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/index.ts +1 -0
- package/dist/kompendium/index.esm.js +2 -0
- package/dist/kompendium/index.esm.js.map +1 -0
- package/dist/kompendium/kompendium-app.kompendium-darkmode-switch.kompendium-navigation.kompendium-search.stencil-route.stencil-route-switch.stencil-router.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-code.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-component.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-debug.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-example-code.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-example-markdown.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-guide.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-markdown.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-playground.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-proplist.kompendium-taglist.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-type.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium.css +47 -0
- package/dist/kompendium/kompendium.esm.js +2 -0
- package/dist/kompendium/kompendium.esm.js.map +1 -0
- package/dist/kompendium/loader.esm.js.map +1 -0
- package/dist/kompendium/p-15e4b2c0.entry.js +2 -0
- package/dist/kompendium/p-15e4b2c0.entry.js.map +1 -0
- package/dist/kompendium/p-1cf0168f.entry.js +2 -0
- package/dist/kompendium/p-1cf0168f.entry.js.map +1 -0
- package/dist/kompendium/p-29c23c89.entry.js +2 -0
- package/dist/kompendium/p-29c23c89.entry.js.map +1 -0
- package/dist/kompendium/p-3981d11f.entry.js +2 -0
- package/dist/kompendium/p-3981d11f.entry.js.map +1 -0
- package/dist/kompendium/p-93f0548d.entry.js +2 -0
- package/dist/kompendium/p-93f0548d.entry.js.map +1 -0
- package/dist/kompendium/p-97b02575.entry.js +2 -0
- package/dist/kompendium/p-97b02575.entry.js.map +1 -0
- package/dist/kompendium/p-9UrzenzW.js +3 -0
- package/dist/kompendium/p-9UrzenzW.js.map +1 -0
- package/dist/kompendium/p-Ajsawr_9.js +2 -0
- package/dist/kompendium/p-Ajsawr_9.js.map +1 -0
- package/dist/kompendium/p-BAGXN2n6.js +2 -0
- package/dist/kompendium/p-BAGXN2n6.js.map +1 -0
- package/dist/kompendium/p-BFTU3MAI.js +2 -0
- package/dist/kompendium/p-BFTU3MAI.js.map +1 -0
- package/dist/kompendium/p-BIPLEi1G.js +2 -0
- package/dist/kompendium/p-BIPLEi1G.js.map +1 -0
- package/dist/kompendium/p-CnQEA7KO.js +2 -0
- package/dist/kompendium/p-CnQEA7KO.js.map +1 -0
- package/dist/kompendium/p-b0f95bd6.entry.js +2 -0
- package/dist/kompendium/p-b0f95bd6.entry.js.map +1 -0
- package/dist/kompendium/p-d9bcc473.entry.js +10 -0
- package/dist/kompendium/p-d9bcc473.entry.js.map +1 -0
- package/dist/kompendium/p-e36f3f1e.entry.js +2 -0
- package/dist/kompendium/p-e36f3f1e.entry.js.map +1 -0
- package/dist/kompendium/p-e52a2f57.entry.js +2 -0
- package/dist/kompendium/p-e52a2f57.entry.js.map +1 -0
- package/dist/kompendium/p-ec5861de.entry.js +2 -0
- package/dist/kompendium/p-ec5861de.entry.js.map +1 -0
- package/dist/markdown-admonitions.ts +112 -0
- package/dist/markdown-code.ts +51 -0
- package/dist/markdown-frontmatter.ts +19 -0
- package/dist/markdown-nodes.ts +23 -0
- package/dist/markdown-typelinks.ts +166 -0
- package/dist/markdown.ts +49 -0
- package/dist/menu.ts +189 -0
- package/dist/schema.ts +233 -0
- package/dist/search.ts +197 -0
- package/dist/source.ts +129 -0
- package/dist/typedoc.ts +665 -0
- package/dist/types/components/anchor-scroll.d.ts +36 -0
- package/dist/types/components/app/app.d.ts +22 -0
- package/dist/types/components/code/code.d.ts +26 -0
- package/dist/types/components/code/examples/code.d.ts +3 -0
- package/dist/types/components/component/component.d.ts +32 -0
- package/dist/types/components/component/templates/events.d.ts +5 -0
- package/dist/types/components/component/templates/examples.d.ts +9 -0
- package/dist/types/components/component/templates/methods.d.ts +5 -0
- package/dist/types/components/component/templates/props.d.ts +5 -0
- package/dist/types/components/component/templates/slots.d.ts +5 -0
- package/dist/types/components/component/templates/style.d.ts +5 -0
- package/dist/types/components/darkmode-switch/darkmode-switch.d.ts +18 -0
- package/dist/types/components/darkmode-switch/types.d.ts +2 -0
- package/dist/types/components/debug/debug.d.ts +24 -0
- package/dist/types/components/guide/guide.d.ts +14 -0
- package/dist/types/components/markdown/examples/markdown-example.d.ts +1 -0
- package/dist/types/components/markdown/examples/markdown.d.ts +7 -0
- package/dist/types/components/markdown/markdown-types.d.ts +2 -0
- package/dist/types/components/markdown/markdown.d.ts +20 -0
- package/dist/types/components/navigation/navigation.d.ts +35 -0
- package/dist/types/components/playground/playground.d.ts +32 -0
- package/dist/types/components/playground/playground.types.d.ts +1 -0
- package/dist/types/components/proplist/proplist.d.ts +12 -0
- package/dist/types/components/search/search.d.ts +15 -0
- package/dist/types/components/taglist/taglist.d.ts +16 -0
- package/dist/types/components/type/templates/alias.d.ts +4 -0
- package/dist/types/components/type/templates/enum.d.ts +4 -0
- package/dist/types/components/type/templates/interface.d.ts +4 -0
- package/dist/types/components/type/type.d.ts +15 -0
- package/dist/types/components.d.ts +517 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/kompendium/config.d.ts +2 -0
- package/dist/types/kompendium/filesystem.d.ts +1 -0
- package/dist/types/kompendium/generator.d.ts +4 -0
- package/dist/types/kompendium/guides.d.ts +9 -0
- package/dist/types/kompendium/index.d.ts +1 -0
- package/dist/types/kompendium/markdown-admonitions.d.ts +3 -0
- package/dist/types/kompendium/markdown-code.d.ts +2 -0
- package/dist/types/kompendium/markdown-frontmatter.d.ts +6 -0
- package/dist/types/kompendium/markdown-nodes.d.ts +12 -0
- package/dist/types/kompendium/markdown-typelinks.d.ts +21 -0
- package/dist/types/kompendium/markdown.d.ts +8 -0
- package/dist/types/kompendium/menu.d.ts +12 -0
- package/dist/types/kompendium/schema.d.ts +9 -0
- package/dist/types/kompendium/search.d.ts +3 -0
- package/dist/types/kompendium/source.d.ts +10 -0
- package/dist/types/kompendium/test/fixtures/basic.d.ts +65 -0
- package/dist/types/kompendium/test/fixtures/filtering/example-type.d.ts +8 -0
- package/dist/types/kompendium/test/fixtures/filtering/node-modules-type.d.ts +8 -0
- package/dist/types/kompendium/test/fixtures/filtering/private-types.d.ts +23 -0
- package/dist/types/kompendium/test/fixtures/filtering/stencil-component-types.d.ts +19 -0
- package/dist/types/kompendium/test/fixtures/filtering/test-helper-type.d.ts +8 -0
- package/dist/types/kompendium/test/fixtures/filtering/valid-types.d.ts +42 -0
- package/dist/types/kompendium/typedoc.d.ts +2 -0
- package/dist/types/kompendium/watch.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1746 -0
- package/dist/types/types.d.ts +119 -0
- package/dist/watch.ts +14 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +116 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/kompendium/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { kompendium } from './generator';\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { visit } from "unist-util-visit";
|
|
2
|
+
import { isParent } from "./markdown-nodes";
|
|
3
|
+
const ADMONITION_TYPES = new Map([
|
|
4
|
+
['note', 'secondary'],
|
|
5
|
+
['important', 'info'],
|
|
6
|
+
['tip', 'success'],
|
|
7
|
+
['warning', 'danger'],
|
|
8
|
+
['caution', 'warning'],
|
|
9
|
+
]);
|
|
10
|
+
const TYPES_PATTERN = [...ADMONITION_TYPES.keys()].join('|');
|
|
11
|
+
const LEGACY_SYNTAX = new RegExp(`^(:::(?:${TYPES_PATTERN}))[^\\S\\n]+(?!\\[)(.+?)[^\\S\\n]*$`, 'gm');
|
|
12
|
+
export function normalizeLegacyAdmonitions(text) {
|
|
13
|
+
return text.replace(LEGACY_SYNTAX, '$1[$2]');
|
|
14
|
+
}
|
|
15
|
+
export function admonitions() {
|
|
16
|
+
return (tree) => {
|
|
17
|
+
visit(tree, 'containerDirective', (node) => {
|
|
18
|
+
const ifmClass = ADMONITION_TYPES.get(node.name);
|
|
19
|
+
if (!ifmClass) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const { label, children } = extractLabel(node);
|
|
23
|
+
const content = children;
|
|
24
|
+
node.data = {
|
|
25
|
+
hName: 'div',
|
|
26
|
+
hProperties: {
|
|
27
|
+
className: [
|
|
28
|
+
'admonition',
|
|
29
|
+
`admonition-${node.name}`,
|
|
30
|
+
'alert',
|
|
31
|
+
`alert--${ifmClass}`,
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
node.children = [
|
|
36
|
+
{
|
|
37
|
+
type: 'admonitionHeading',
|
|
38
|
+
data: {
|
|
39
|
+
hName: 'div',
|
|
40
|
+
hProperties: { className: ['admonition-heading'] },
|
|
41
|
+
},
|
|
42
|
+
children: [
|
|
43
|
+
{
|
|
44
|
+
type: 'admonitionTitle',
|
|
45
|
+
data: { hName: 'h5' },
|
|
46
|
+
children: [{ type: 'text', value: label }],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'admonitionContent',
|
|
52
|
+
data: {
|
|
53
|
+
hName: 'div',
|
|
54
|
+
hProperties: { className: ['admonition-content'] },
|
|
55
|
+
},
|
|
56
|
+
children: content,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function extractLabel(node) {
|
|
63
|
+
const labelNode = node.children.find((child) => { var _a; return (_a = child.data) === null || _a === void 0 ? void 0 : _a.directiveLabel; });
|
|
64
|
+
if (!labelNode || !isParent(labelNode)) {
|
|
65
|
+
return { label: node.name, children: node.children };
|
|
66
|
+
}
|
|
67
|
+
const filtered = node.children.filter((child) => child !== labelNode);
|
|
68
|
+
return {
|
|
69
|
+
label: extractText(labelNode) || node.name,
|
|
70
|
+
children: filtered,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function extractText(node) {
|
|
74
|
+
if (node.type === 'text') {
|
|
75
|
+
return node.value;
|
|
76
|
+
}
|
|
77
|
+
if (!isParent(node)) {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
return node.children.map(extractText).join('');
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=markdown-admonitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-admonitions.js","sourceRoot":"","sources":["../../src/kompendium/markdown-admonitions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAO5C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC7B,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,WAAW,EAAE,MAAM,CAAC;IACrB,CAAC,KAAK,EAAE,SAAS,CAAC;IAClB,CAAC,SAAS,EAAE,QAAQ,CAAC;IACrB,CAAC,SAAS,EAAE,SAAS,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CA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from './markdown-nodes';\n\ninterface DirectiveNode extends Parent {\n name: string;\n data?: Record<string, unknown>;\n}\n\nconst ADMONITION_TYPES = new Map([\n ['note', 'secondary'],\n ['important', 'info'],\n ['tip', 'success'],\n ['warning', 'danger'],\n ['caution', 'warning'],\n]);\n\nconst TYPES_PATTERN = [...ADMONITION_TYPES.keys()].join('|');\nconst LEGACY_SYNTAX = new RegExp(\n `^(:::(?:${TYPES_PATTERN}))[^\\\\S\\\\n]+(?!\\\\[)(.+?)[^\\\\S\\\\n]*$`,\n 'gm',\n);\n\nexport function normalizeLegacyAdmonitions(text: string): string {\n return text.replace(LEGACY_SYNTAX, '$1[$2]');\n}\n\nexport function admonitions(): (tree: Node) => void {\n return (tree: Node) => {\n visit(tree, 'containerDirective', (node: DirectiveNode) => {\n const ifmClass = ADMONITION_TYPES.get(node.name);\n if (!ifmClass) {\n return;\n }\n\n const { label, children } = extractLabel(node);\n const content = children;\n\n node.data = {\n hName: 'div',\n hProperties: {\n className: [\n 'admonition',\n `admonition-${node.name}`,\n 'alert',\n `alert--${ifmClass}`,\n ],\n },\n };\n\n node.children = [\n {\n type: 'admonitionHeading',\n data: {\n hName: 'div',\n hProperties: { className: ['admonition-heading'] },\n },\n children: [\n {\n type: 'admonitionTitle',\n data: { hName: 'h5' },\n children: [{ type: 'text', value: label }],\n },\n ],\n },\n {\n type: 'admonitionContent',\n data: {\n hName: 'div',\n hProperties: { className: ['admonition-content'] },\n },\n children: content,\n },\n ];\n });\n };\n}\n\ninterface ExtractedLabel {\n label: string;\n children: Node[];\n}\n\nfunction extractLabel(node: DirectiveNode): ExtractedLabel {\n const labelNode = node.children.find(\n (child: Node & { data?: Record<string, unknown> }) =>\n child.data?.directiveLabel,\n );\n\n if (!labelNode || !isParent(labelNode)) {\n return { label: node.name, children: node.children };\n }\n\n const filtered = node.children.filter((child: Node) => child !== labelNode);\n\n return {\n label: extractText(labelNode) || node.name,\n children: filtered,\n };\n}\n\nfunction extractText(node: Node): string {\n if (node.type === 'text') {\n return (node as Node & { value: string }).value;\n }\n\n if (!isParent(node)) {\n return '';\n }\n\n return node.children.map(extractText).join('');\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { map } from "unist-util-map";
|
|
2
|
+
import { isElement } from "./markdown-nodes";
|
|
3
|
+
export function kompendiumCode() {
|
|
4
|
+
return transformer;
|
|
5
|
+
}
|
|
6
|
+
function transformer(tree) {
|
|
7
|
+
return map(tree, mapCodeNode);
|
|
8
|
+
}
|
|
9
|
+
function mapCodeNode(node) {
|
|
10
|
+
if (!isElement(node)) {
|
|
11
|
+
return node;
|
|
12
|
+
}
|
|
13
|
+
if (node.tagName !== 'code') {
|
|
14
|
+
return node;
|
|
15
|
+
}
|
|
16
|
+
const language = getLanguage(node.properties);
|
|
17
|
+
if (!language) {
|
|
18
|
+
return node;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...node,
|
|
22
|
+
type: 'element',
|
|
23
|
+
tagName: 'kompendium-code',
|
|
24
|
+
properties: {
|
|
25
|
+
language: language,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function getLanguage(props) {
|
|
30
|
+
const className = props === null || props === void 0 ? void 0 : props.className;
|
|
31
|
+
if (!Array.isArray(className)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const languageClass = className.find((name) => name.startsWith('language-'));
|
|
35
|
+
if (!languageClass) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
return languageClass.replace('language-', '');
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=markdown-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-code.js","sourceRoot":"","sources":["../../src/kompendium/markdown-code.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,UAAU,cAAc;IAC1B,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,IAAU;IAC3B,OAAO,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,WAAW,CAAC,IAAU;IAC3B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO;QACH,GAAG,IAAI;QACP,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,iBAAiB;QAC1B,UAAU,EAAE;YACR,QAAQ,EAAE,QAAQ;SACrB;KACJ,CAAC;AACN,CAAC;AAED,SAAS,WAAW,CAAC,KAA+B;IAChD,MAAM,SAAS,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC;IACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,OAAO;IACX,CAAC;IAED,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAClD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAC/B,CAAC;IACF,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO;IACX,CAAC;IAED,OAAO,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC","sourcesContent":["import type { Node } from 'unist';\nimport { map } from 'unist-util-map';\nimport { isElement } from './markdown-nodes';\n\nexport function kompendiumCode(): (tree: Node) => Node {\n return transformer;\n}\n\nfunction transformer(tree: Node) {\n return map(tree, mapCodeNode);\n}\n\nfunction mapCodeNode(node: Node) {\n if (!isElement(node)) {\n return node;\n }\n\n if (node.tagName !== 'code') {\n return node;\n }\n\n const language = getLanguage(node.properties);\n if (!language) {\n return node;\n }\n\n return {\n ...node,\n type: 'element',\n tagName: 'kompendium-code',\n properties: {\n language: language,\n },\n };\n}\n\nfunction getLanguage(props?: Record<string, unknown>) {\n const className = props?.className;\n if (!Array.isArray(className)) {\n return;\n }\n\n const languageClass = className.find((name: string) =>\n name.startsWith('language-'),\n );\n if (!languageClass) {\n return;\n }\n\n return languageClass.replace('language-', '');\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { visit } from "unist-util-visit";
|
|
2
|
+
import YAML from "yaml";
|
|
3
|
+
export function saveFrontmatter() {
|
|
4
|
+
return transformer;
|
|
5
|
+
}
|
|
6
|
+
function transformer(tree, file) {
|
|
7
|
+
visit(tree, 'yaml', storeData(file));
|
|
8
|
+
}
|
|
9
|
+
const storeData = (file) => (item) => {
|
|
10
|
+
file.data.frontmatter = item.value ? YAML.parse(item.value) : undefined;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=markdown-frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-frontmatter.js","sourceRoot":"","sources":["../../src/kompendium/markdown-frontmatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAMxB,MAAM,UAAU,eAAe;IAC3B,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,IAAU,EAAE,IAAW;IACxC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,EAAE,CAAC,CAAC,IAA+B,EAAE,EAAE;IACnE,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["import type { Node } from 'unist';\nimport { visit } from 'unist-util-visit';\nimport YAML from 'yaml';\n\ninterface VFile {\n data: Record<string, unknown>;\n}\n\nexport function saveFrontmatter(): (tree: Node, file: VFile) => void {\n return transformer;\n}\n\nfunction transformer(tree: Node, file: VFile) {\n visit(tree, 'yaml', storeData(file));\n}\n\nconst storeData = (file: VFile) => (item: Node & { value?: string }) => {\n file.data.frontmatter = item.value ? YAML.parse(item.value) : undefined;\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function isParent(node) {
|
|
2
|
+
return 'children' in node;
|
|
3
|
+
}
|
|
4
|
+
export function isTextNode(node) {
|
|
5
|
+
return node.type === 'text';
|
|
6
|
+
}
|
|
7
|
+
export function isElement(node) {
|
|
8
|
+
return node.type === 'element' && 'tagName' in node;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=markdown-nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-nodes.js","sourceRoot":"","sources":["../../src/kompendium/markdown-nodes.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,QAAQ,CAAC,IAAU;IAC/B,OAAO,UAAU,IAAI,IAAI,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAU;IACjC,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAU;IAChC,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,IAAI,IAAI,CAAC;AACxD,CAAC","sourcesContent":["import type { Node, Parent } from 'unist';\n\nexport interface ElementNode extends Parent {\n tagName: string;\n properties?: Record<string, unknown>;\n}\n\nexport interface TextNode extends Node {\n type: 'text';\n value: string;\n}\n\nexport function isParent(node: Node): node is Parent {\n return 'children' in node;\n}\n\nexport function isTextNode(node: Node): node is TextNode {\n return node.type === 'text';\n}\n\nexport function isElement(node: Node): node is ElementNode {\n return node.type === 'element' && 'tagName' in node;\n}\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { isElement, isParent, isTextNode } from "./markdown-nodes";
|
|
2
|
+
export function typeLinks(options = {}) {
|
|
3
|
+
return transformer(options.types);
|
|
4
|
+
}
|
|
5
|
+
const transformer = (types = []) => (tree) => {
|
|
6
|
+
if (types.length === 0) {
|
|
7
|
+
return tree;
|
|
8
|
+
}
|
|
9
|
+
const preCodeElements = collectPreCodeElements(tree);
|
|
10
|
+
return flatMap(tree, mapCodeNode(types, preCodeElements));
|
|
11
|
+
};
|
|
12
|
+
function collectPreCodeElements(node) {
|
|
13
|
+
const set = new Set();
|
|
14
|
+
collectPreCode(node, set);
|
|
15
|
+
return set;
|
|
16
|
+
}
|
|
17
|
+
function collectPreCode(node, set) {
|
|
18
|
+
if (!isParent(node)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (isElement(node) && node.tagName === 'pre') {
|
|
22
|
+
for (const child of node.children) {
|
|
23
|
+
if (isElement(child) && child.tagName === 'code') {
|
|
24
|
+
set.add(child);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const child of node.children) {
|
|
29
|
+
collectPreCode(child, set);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const mapCodeNode = (types = [], preCodeElements) => (node, _, parent) => {
|
|
33
|
+
if (!isTextNode(node)) {
|
|
34
|
+
return [node];
|
|
35
|
+
}
|
|
36
|
+
if (!parent || !isElement(parent)) {
|
|
37
|
+
return [node];
|
|
38
|
+
}
|
|
39
|
+
if (parent.tagName !== 'code') {
|
|
40
|
+
return [node];
|
|
41
|
+
}
|
|
42
|
+
if (preCodeElements.has(parent)) {
|
|
43
|
+
return [node];
|
|
44
|
+
}
|
|
45
|
+
return wrapText(node, types);
|
|
46
|
+
};
|
|
47
|
+
export function wrapText(node, types = []) {
|
|
48
|
+
return splitTypeString(node.value).map(createNode(types));
|
|
49
|
+
}
|
|
50
|
+
const createNode = (types = []) => (type) => {
|
|
51
|
+
if (!types.includes(type)) {
|
|
52
|
+
return createTextNode(type);
|
|
53
|
+
}
|
|
54
|
+
return createLinkNode(type);
|
|
55
|
+
};
|
|
56
|
+
function createTextNode(text) {
|
|
57
|
+
return {
|
|
58
|
+
type: 'text',
|
|
59
|
+
value: text,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function createLinkNode(type) {
|
|
63
|
+
return {
|
|
64
|
+
type: 'element',
|
|
65
|
+
tagName: 'a',
|
|
66
|
+
properties: {
|
|
67
|
+
href: `#/type/${type}`,
|
|
68
|
+
},
|
|
69
|
+
children: [
|
|
70
|
+
{
|
|
71
|
+
type: 'text',
|
|
72
|
+
value: type,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function splitTypeString(typeString) {
|
|
78
|
+
const pattern = /(\b\w+\b)+/g;
|
|
79
|
+
const types = typeString.match(pattern);
|
|
80
|
+
const result = [];
|
|
81
|
+
if (!types) {
|
|
82
|
+
return [typeString];
|
|
83
|
+
}
|
|
84
|
+
let currentString = typeString;
|
|
85
|
+
types.forEach((type) => {
|
|
86
|
+
const index = currentString.indexOf(type);
|
|
87
|
+
if (index > 0) {
|
|
88
|
+
result.push(currentString.substring(0, index));
|
|
89
|
+
}
|
|
90
|
+
result.push(type);
|
|
91
|
+
currentString = currentString.substring(index + type.length);
|
|
92
|
+
});
|
|
93
|
+
if (currentString.length > 0) {
|
|
94
|
+
result.push(currentString);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
function transformChildren(node, fn) {
|
|
99
|
+
if (!isParent(node)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
node.children = node.children.flatMap((child, i) => transform(child, i, node, fn));
|
|
103
|
+
}
|
|
104
|
+
function transform(node, index, parent, fn) {
|
|
105
|
+
transformChildren(node, fn);
|
|
106
|
+
return fn(node, index, parent);
|
|
107
|
+
}
|
|
108
|
+
function flatMap(ast, fn) {
|
|
109
|
+
const result = transform(ast, 0, null, fn);
|
|
110
|
+
if (result.length !== 1) {
|
|
111
|
+
throw new Error(`flatMap: root must map to exactly one node, got ${result.length}`);
|
|
112
|
+
}
|
|
113
|
+
return result[0];
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=markdown-typelinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-typelinks.js","sourceRoot":"","sources":["../../src/kompendium/markdown-typelinks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInE,MAAM,UAAU,SAAS,CACrB,UAAgC,EAAE;IAElC,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,WAAW,GACb,CAAC,QAAkB,EAAE,EAAE,EAAE,CACzB,CAAC,IAAU,EAAQ,EAAE;IACjB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,eAAe,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAErD,OAAO,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEN,SAAS,sBAAsB,CAAC,IAAU;IACtC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAQ,CAAC;IAC5B,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAE1B,OAAO,GAAG,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,IAAU,EAAE,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Parent, isTextNode } from './markdown-nodes';\n\ntype MapFn = (node: Node, index: number, parent: Node | null) => Node[];\n\nexport function typeLinks(\n options: { types?: string[] } = {},\n): (tree: Node) => Node {\n return transformer(options.types);\n}\n\nconst transformer =\n (types: string[] = []) =>\n (tree: Node): Node => {\n if (types.length === 0) {\n return tree;\n }\n\n const preCodeElements = collectPreCodeElements(tree);\n\n return flatMap(tree, mapCodeNode(types, preCodeElements));\n };\n\nfunction collectPreCodeElements(node: Node): Set<Node> {\n const set = new Set<Node>();\n collectPreCode(node, set);\n\n return set;\n}\n\nfunction collectPreCode(node: Node, set: Set<Node>) {\n if (!isParent(node)) {\n return;\n }\n\n if (isElement(node) && node.tagName === 'pre') {\n for (const child of node.children) {\n if (isElement(child) && child.tagName === 'code') {\n set.add(child);\n }\n }\n }\n\n for (const child of node.children) {\n collectPreCode(child, set);\n }\n}\n\nconst mapCodeNode =\n (types: string[] = [], preCodeElements: Set<Node>) =>\n (node: Node, _: number, parent: Node | null) => {\n if (!isTextNode(node)) {\n return [node];\n }\n\n if (!parent || !isElement(parent)) {\n return [node];\n }\n\n if (parent.tagName !== 'code') {\n return [node];\n }\n\n if (preCodeElements.has(parent)) {\n return [node];\n }\n\n return wrapText(node, types);\n };\n\nexport function wrapText(node: { value: string }, types: string[] = []) {\n return splitTypeString(node.value).map(createNode(types));\n}\n\nconst createNode =\n (types: string[] = []) =>\n (type: string) => {\n if (!types.includes(type)) {\n return createTextNode(type);\n }\n\n return createLinkNode(type);\n };\n\nfunction createTextNode(text: string) {\n return {\n type: 'text',\n value: text,\n };\n}\n\nfunction createLinkNode(type: string) {\n return {\n type: 'element',\n tagName: 'a',\n properties: {\n href: `#/type/${type}`,\n },\n children: [\n {\n type: 'text',\n value: type,\n },\n ],\n };\n}\n\nexport function splitTypeString(typeString: string): string[] {\n const pattern = /(\\b\\w+\\b)+/g;\n const types = typeString.match(pattern);\n const result: string[] = [];\n\n if (!types) {\n return [typeString];\n }\n\n let currentString = typeString;\n types.forEach((type: string) => {\n const index = currentString.indexOf(type);\n if (index > 0) {\n result.push(currentString.substring(0, index));\n }\n\n result.push(type);\n currentString = currentString.substring(index + type.length);\n });\n\n if (currentString.length > 0) {\n result.push(currentString);\n }\n\n return result;\n}\n\nfunction transformChildren(node: Node, fn: MapFn) {\n if (!isParent(node)) {\n return;\n }\n\n node.children = node.children.flatMap((child, i) =>\n transform(child, i, node, fn),\n );\n}\n\nfunction transform(\n node: Node,\n index: number,\n parent: Node | null,\n fn: MapFn,\n): Node[] {\n transformChildren(node, fn);\n\n return fn(node, index, parent);\n}\n\nfunction flatMap(ast: Node, fn: MapFn): Node {\n const result = transform(ast, 0, null, fn);\n\n if (result.length !== 1) {\n throw new Error(\n `flatMap: root must map to exactly one node, got ${result.length}`,\n );\n }\n\n return result[0];\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { unified } from "unified";
|
|
2
|
+
import remarkParse from "remark-parse";
|
|
3
|
+
import remarkFrontmatter from "remark-frontmatter";
|
|
4
|
+
import remarkDirective from "remark-directive";
|
|
5
|
+
import remarkGfm from "remark-gfm";
|
|
6
|
+
import remarkRehype from "remark-rehype";
|
|
7
|
+
import rehypeRaw from "rehype-raw";
|
|
8
|
+
import rehypeSlug from "rehype-slug";
|
|
9
|
+
import rehypeStringify from "rehype-stringify";
|
|
10
|
+
import { saveFrontmatter } from "./markdown-frontmatter";
|
|
11
|
+
import { admonitions, normalizeLegacyAdmonitions, } from "./markdown-admonitions";
|
|
12
|
+
import { kompendiumCode } from "./markdown-code";
|
|
13
|
+
import { typeLinks } from "./markdown-typelinks";
|
|
14
|
+
export async function markdownToHtml(text, types = []) {
|
|
15
|
+
const normalized = normalizeLegacyAdmonitions(text);
|
|
16
|
+
const file = await unified()
|
|
17
|
+
.use(remarkParse)
|
|
18
|
+
.use(remarkGfm)
|
|
19
|
+
.use(remarkFrontmatter)
|
|
20
|
+
.use(saveFrontmatter)
|
|
21
|
+
.use(remarkDirective)
|
|
22
|
+
.use(admonitions)
|
|
23
|
+
.use(remarkRehype, { allowDangerousHtml: true })
|
|
24
|
+
.use(rehypeRaw)
|
|
25
|
+
.use(rehypeSlug)
|
|
26
|
+
.use(typeLinks, { types: types })
|
|
27
|
+
.use(kompendiumCode)
|
|
28
|
+
.use(rehypeStringify)
|
|
29
|
+
.process(normalized);
|
|
30
|
+
return {
|
|
31
|
+
data: file.data,
|
|
32
|
+
toString: () => file.toString(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/kompendium/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACH,WAAW,EACX,0BAA0B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAWjD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,KAAK,GAAG,EAAE;IACzD,MAAM,UAAU,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAEpD,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE;SACvB,GAAG,CAAC,WAAW,CAAC;SAChB,GAAG,CAAC,SAAS,CAAC;SACd,GAAG,CAAC,iBAAiB,CAAC;SACtB,GAAG,CAAC,eAAe,CAAC;SACpB,GAAG,CAAC,eAAe,CAAC;SACpB,GAAG,CAAC,WAAW,CAAC;SAChB,GAAG,CAAC,YAAY,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;SAC/C,GAAG,CAAC,SAAS,CAAC;SACd,GAAG,CAAC,UAAU,CAAC;SACf,GAAG,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;SAChC,GAAG,CAAC,cAAc,CAAC;SACnB,GAAG,CAAC,eAAe,CAAC;SACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzB,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,IAAoB;QAC/B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;KAClC,CAAC;AACN,CAAC","sourcesContent":["import { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport remarkDirective from 'remark-directive';\nimport remarkGfm from 'remark-gfm';\nimport remarkRehype from 'remark-rehype';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeSlug from 'rehype-slug';\nimport rehypeStringify from 'rehype-stringify';\nimport { saveFrontmatter } from './markdown-frontmatter';\nimport {\n admonitions,\n normalizeLegacyAdmonitions,\n} from './markdown-admonitions';\nimport { kompendiumCode } from './markdown-code';\nimport { typeLinks } from './markdown-typelinks';\n\nexport interface File {\n data: {\n frontmatter?: Record<string, any>;\n path?: string;\n };\n\n toString(): string;\n}\n\nexport async function markdownToHtml(text: string, types = []): Promise<File> {\n const normalized = normalizeLegacyAdmonitions(text);\n\n const file = await unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkFrontmatter)\n .use(saveFrontmatter)\n .use(remarkDirective)\n .use(admonitions)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeRaw)\n .use(rehypeSlug)\n .use(typeLinks, { types: types })\n .use(kompendiumCode)\n .use(rehypeStringify)\n .process(normalized);\n\n return {\n data: file.data as File['data'],\n toString: () => file.toString(),\n };\n}\n"]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import startCase from "lodash/startCase";
|
|
2
|
+
export function createMenu(docs, guides, types) {
|
|
3
|
+
let menu = [];
|
|
4
|
+
guides.forEach(addGuide(menu, ''));
|
|
5
|
+
menu = [...menu, createComponentMenu(docs), createTypeMenu(types)];
|
|
6
|
+
return menu;
|
|
7
|
+
}
|
|
8
|
+
export const addGuide = (menu, path) => (guide) => {
|
|
9
|
+
const subPath = guide.data.path.replace(path, '');
|
|
10
|
+
const parts = subPath.split('/');
|
|
11
|
+
const parentPath = `${path}/${parts[1]}`;
|
|
12
|
+
let submenu = menu.find((item) => item.path === parentPath + '/');
|
|
13
|
+
if (!submenu && parts.length === 2) {
|
|
14
|
+
const title = getGuideTitle(guide);
|
|
15
|
+
menu.push({
|
|
16
|
+
path: guide.data.path + '/',
|
|
17
|
+
title: title,
|
|
18
|
+
children: [],
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!submenu) {
|
|
23
|
+
submenu = {
|
|
24
|
+
path: parentPath + '/',
|
|
25
|
+
title: startCase(parts[1]),
|
|
26
|
+
children: [],
|
|
27
|
+
};
|
|
28
|
+
menu.push(submenu);
|
|
29
|
+
}
|
|
30
|
+
addGuide(submenu.children, parentPath)(guide);
|
|
31
|
+
};
|
|
32
|
+
function getGuideTitle(guide) {
|
|
33
|
+
const regex = /^#\s?(.+?)$/m;
|
|
34
|
+
const match = guide.content.match(regex);
|
|
35
|
+
return match === null || match === void 0 ? void 0 : match[1];
|
|
36
|
+
}
|
|
37
|
+
export function createComponentMenu(docs) {
|
|
38
|
+
const components = docs.components || [];
|
|
39
|
+
return {
|
|
40
|
+
path: '/component/',
|
|
41
|
+
title: 'Components',
|
|
42
|
+
children: components
|
|
43
|
+
.filter(isNotExample)
|
|
44
|
+
.filter(isPublic)
|
|
45
|
+
.map(getComponentMenu),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function isExample(component) {
|
|
49
|
+
return !!component.dirPath.match(/\/examples?$/);
|
|
50
|
+
}
|
|
51
|
+
function isNotExample(component) {
|
|
52
|
+
return !isExample(component);
|
|
53
|
+
}
|
|
54
|
+
export function isPublic(component) {
|
|
55
|
+
return !component.docsTags.find((tag) => ['internal', 'private', 'ignore'].includes(tag.name));
|
|
56
|
+
}
|
|
57
|
+
export function getComponentMenu(component) {
|
|
58
|
+
return {
|
|
59
|
+
path: `/component/${component.tag}/`,
|
|
60
|
+
title: getComponentTitle(component.tag),
|
|
61
|
+
children: [
|
|
62
|
+
getComponentPropertyMenu(component),
|
|
63
|
+
getComponentEventMenu(component),
|
|
64
|
+
getComponentMethodMenu(component),
|
|
65
|
+
getComponentSlotMenu(component),
|
|
66
|
+
getComponentStyleMenu(component),
|
|
67
|
+
].filter((item) => !!item),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function getComponentPropertyMenu(component) {
|
|
71
|
+
if (!component.props.length) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
title: 'Properties',
|
|
76
|
+
path: `/component/${component.tag}/properties/`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function getComponentEventMenu(component) {
|
|
80
|
+
if (!component.events.length) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
title: 'Events',
|
|
85
|
+
path: `/component/${component.tag}/events/`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function getComponentMethodMenu(component) {
|
|
89
|
+
if (!component.methods.length) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
title: 'Methods',
|
|
94
|
+
path: `/component/${component.tag}/methods/`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function getComponentSlotMenu(component) {
|
|
98
|
+
if (!component.slots.length) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
title: 'Slots',
|
|
103
|
+
path: `/component/${component.tag}/slots/`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function getComponentStyleMenu(component) {
|
|
107
|
+
if (!component.styles.length) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
title: 'Styles',
|
|
112
|
+
path: `/component/${component.tag}/styles/`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function getComponentTitle(tag) {
|
|
116
|
+
const title = tag.split('-').slice(1).join(' ');
|
|
117
|
+
return title[0].toLocaleUpperCase() + title.slice(1);
|
|
118
|
+
}
|
|
119
|
+
export function createApiMenu() {
|
|
120
|
+
return {
|
|
121
|
+
path: '/api/',
|
|
122
|
+
title: 'API',
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export function createVersionMenu() {
|
|
126
|
+
return {
|
|
127
|
+
path: '/version/',
|
|
128
|
+
title: 'Versions',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function createTypeMenu(types) {
|
|
132
|
+
return {
|
|
133
|
+
path: '/type/',
|
|
134
|
+
title: 'Types',
|
|
135
|
+
// Sort types alphabetically by name
|
|
136
|
+
children: types
|
|
137
|
+
.slice()
|
|
138
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
139
|
+
.map(getTypeMenu),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function getTypeMenu(type) {
|
|
143
|
+
return {
|
|
144
|
+
path: `/type/${type.name}/`,
|
|
145
|
+
title: type.name,
|
|
146
|
+
children: [],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/kompendium/menu.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,k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AE,IAAI,CAAC,IAAI;QAChB,QAAQ,EAAE,EAAE;KACf,CAAC;AACN,CAAC","sourcesContent":["import { JsonDocsComponent, JsonDocs } from '@stencil/core/internal';\nimport startCase from 'lodash/startCase';\nimport { MenuItem, KompendiumGuide, TypeDescription } from '../types';\n\nexport function createMenu(\n docs: JsonDocs,\n guides: KompendiumGuide[],\n types: TypeDescription[],\n): MenuItem[] {\n let menu = [];\n\n guides.forEach(addGuide(menu, ''));\n menu = [...menu, createComponentMenu(docs), createTypeMenu(types)];\n\n return menu;\n}\n\nexport const addGuide =\n (menu: MenuItem[], path: string) => (guide: KompendiumGuide) => {\n const subPath: string = guide.data.path.replace(path, '');\n const parts = subPath.split('/');\n const parentPath = `${path}/${parts[1]}`;\n let submenu = menu.find((item) => item.path === parentPath + '/');\n\n if (!submenu && parts.length === 2) {\n const title = getGuideTitle(guide);\n menu.push({\n path: guide.data.path + '/',\n title: title,\n children: [],\n });\n\n return;\n }\n\n if (!submenu) {\n submenu = {\n path: parentPath + '/',\n title: startCase(parts[1]),\n children: [],\n };\n menu.push(submenu);\n }\n\n addGuide(submenu.children, parentPath)(guide);\n };\n\nfunction getGuideTitle(guide: KompendiumGuide): string {\n const regex = /^#\\s?(.+?)$/m;\n const match = guide.content.match(regex);\n\n return match?.[1];\n}\n\nexport function createComponentMenu(docs: JsonDocs): MenuItem {\n const components = docs.components || [];\n\n return {\n path: '/component/',\n title: 'Components',\n children: components\n .filter(isNotExample)\n .filter(isPublic)\n .map(getComponentMenu),\n };\n}\n\nexport function isExample(component: JsonDocsComponent): boolean {\n return !!component.dirPath.match(/\\/examples?$/);\n}\n\nfunction isNotExample(component: JsonDocsComponent) {\n return !isExample(component);\n}\n\nexport function isPublic(component: JsonDocsComponent): boolean {\n return !component.docsTags.find((tag) =>\n ['internal', 'private', 'ignore'].includes(tag.name),\n );\n}\n\nexport function getComponentMenu(component: JsonDocsComponent): MenuItem {\n return {\n path: `/component/${component.tag}/`,\n title: getComponentTitle(component.tag),\n children: [\n getComponentPropertyMenu(component),\n getComponentEventMenu(component),\n getComponentMethodMenu(component),\n getComponentSlotMenu(component),\n getComponentStyleMenu(component),\n ].filter((item) => !!item),\n };\n}\n\nfunction getComponentPropertyMenu(component: JsonDocsComponent): MenuItem {\n if (!component.props.length) {\n return;\n }\n\n return {\n title: 'Properties',\n path: `/component/${component.tag}/properties/`,\n };\n}\n\nfunction getComponentEventMenu(component: JsonDocsComponent): MenuItem {\n if (!component.events.length) {\n return;\n }\n\n return {\n title: 'Events',\n path: `/component/${component.tag}/events/`,\n };\n}\n\nfunction getComponentMethodMenu(component: JsonDocsComponent): MenuItem {\n if (!component.methods.length) {\n return;\n }\n\n return {\n title: 'Methods',\n path: `/component/${component.tag}/methods/`,\n };\n}\n\nfunction getComponentSlotMenu(component: JsonDocsComponent): MenuItem {\n if (!component.slots.length) {\n return;\n }\n\n return {\n title: 'Slots',\n path: `/component/${component.tag}/slots/`,\n };\n}\n\nfunction getComponentStyleMenu(component: JsonDocsComponent): MenuItem {\n if (!component.styles.length) {\n return;\n }\n\n return {\n title: 'Styles',\n path: `/component/${component.tag}/styles/`,\n };\n}\n\nexport function getComponentTitle(tag: string): string {\n const title = tag.split('-').slice(1).join(' ');\n\n return title[0].toLocaleUpperCase() + title.slice(1);\n}\n\nexport function createApiMenu(): MenuItem {\n return {\n path: '/api/',\n title: 'API',\n };\n}\n\nexport function createVersionMenu(): MenuItem {\n return {\n path: '/version/',\n title: 'Versions',\n };\n}\n\nfunction createTypeMenu(types: TypeDescription[]): MenuItem {\n return {\n path: '/type/',\n title: 'Types',\n // Sort types alphabetically by name\n children: types\n .slice()\n .sort((a, b) => a.name.localeCompare(b.name))\n .map(getTypeMenu),\n };\n}\n\nexport function getTypeMenu(type: TypeDescription): MenuItem {\n return {\n path: `/type/${type.name}/`,\n title: type.name,\n children: [],\n };\n}\n"]}
|