From 3eb9e72db070bbf9c686c626ac5d5ca62932a851 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 4 Sep 2023 19:03:26 +0200 Subject: [PATCH] feat: markdoc --- markdoc.config.json | 12 ++ package.json | 10 +- pnpm-lock.yaml | 87 +++++++++++- src/markdoc/layouts/Tutorial.svelte | 206 ++++++++++++++++++++++++++++ src/markdoc/nodes/Code.svelte | 5 + src/markdoc/nodes/Fence.svelte | 81 +++++++++++ src/markdoc/nodes/Heading.svelte | 34 +++++ src/markdoc/nodes/Image.svelte | 9 ++ src/markdoc/nodes/Link.svelte | 6 + src/markdoc/nodes/List.svelte | 5 + src/markdoc/nodes/Paragraph.svelte | 1 + src/markdoc/nodes/Table.svelte | 7 + src/markdoc/nodes/Tbody.svelte | 3 + src/markdoc/nodes/Td.svelte | 7 + src/markdoc/nodes/Th.svelte | 11 ++ src/markdoc/nodes/Thead.svelte | 3 + src/markdoc/nodes/Tr.svelte | 3 + src/markdoc/nodes/_Module.svelte | 15 ++ src/markdoc/tags/MultiCode.svelte | 55 ++++++++ src/markdoc/tags/Section.svelte | 19 +++ src/markdoc/tags/_Module.svelte | 4 + src/routes/test/+page.markdoc | 168 +++++++++++++++++++++++ svelte.config.js | 24 +++- 23 files changed, 768 insertions(+), 7 deletions(-) create mode 100644 markdoc.config.json create mode 100644 src/markdoc/layouts/Tutorial.svelte create mode 100644 src/markdoc/nodes/Code.svelte create mode 100644 src/markdoc/nodes/Fence.svelte create mode 100644 src/markdoc/nodes/Heading.svelte create mode 100644 src/markdoc/nodes/Image.svelte create mode 100644 src/markdoc/nodes/Link.svelte create mode 100644 src/markdoc/nodes/List.svelte create mode 100644 src/markdoc/nodes/Paragraph.svelte create mode 100644 src/markdoc/nodes/Table.svelte create mode 100644 src/markdoc/nodes/Tbody.svelte create mode 100644 src/markdoc/nodes/Td.svelte create mode 100644 src/markdoc/nodes/Th.svelte create mode 100644 src/markdoc/nodes/Thead.svelte create mode 100644 src/markdoc/nodes/Tr.svelte create mode 100644 src/markdoc/nodes/_Module.svelte create mode 100644 src/markdoc/tags/MultiCode.svelte create mode 100644 src/markdoc/tags/Section.svelte create mode 100644 src/markdoc/tags/_Module.svelte create mode 100644 src/routes/test/+page.markdoc diff --git a/markdoc.config.json b/markdoc.config.json new file mode 100644 index 000000000..45be77be2 --- /dev/null +++ b/markdoc.config.json @@ -0,0 +1,12 @@ +[ + { + "id": "appwrite", + "path": "src/", + "schema": { + "path": ".svelte-kit/markdoc_schema.js", + "type": "esm", + "property": "default", + "watch": true + } + } +] diff --git a/package.json b/package.json index 05cf8a16e..3aca0c96a 100644 --- a/package.json +++ b/package.json @@ -27,21 +27,23 @@ "eslint": "^8.28.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-svelte": "^2.30.0", + "oslllo-svg-fixer": "^2.2.0", "prettier": "^2.8.0", "prettier-plugin-svelte": "^2.10.1", "sass": "^1.65.1", "svelte": "^4.0.5", "svelte-check": "^3.4.3", + "svelte-markdoc-preprocess": "^0.3.0", "svelte-sequential-preprocessor": "^2.0.1", + "svgtofont": "^3.22.0", "tslib": "^2.4.1", "typescript": "^5.0.0", "vite": "^4.4.2", - "vitest": "^0.32.2", - "oslllo-svg-fixer": "^2.2.0", - "svgtofont": "^3.22.0" + "vitest": "^0.32.2" }, "type": "module", "dependencies": { - "@fontsource/inter": "^5.0.8" + "@fontsource/inter": "^5.0.8", + "highlight.js": "^11.8.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5d6a1d69d..6b120dd38 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,12 @@ dependencies: '@fontsource/inter': specifier: ^5.0.8 version: 5.0.8 + highlight.js: + specifier: ^11.8.0 + version: 11.8.0 + shiki: + specifier: ^0.14.4 + version: 0.14.4 devDependencies: '@melt-ui/pp': @@ -58,6 +64,9 @@ devDependencies: svelte-check: specifier: ^3.4.3 version: 3.5.0(postcss@8.4.27)(sass@1.65.1)(svelte@4.2.0) + svelte-markdoc-preprocess: + specifier: ^0.3.0 + version: 0.3.0 svelte-sequential-preprocessor: specifier: ^2.0.1 version: 2.0.1 @@ -799,6 +808,21 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: true + /@markdoc/markdoc@0.3.2: + resolution: {integrity: sha512-D0SaanaSkTIARvQu+zQqPEpKcvYUBR/mfac9e8JzS89P7eXhiNWPonUN7avRS1saZHpIQWIRote97qT+jGk5Gw==} + engines: {node: '>=14.7.0'} + peerDependencies: + '@types/react': '*' + react: '*' + peerDependenciesMeta: + '@types/react': + optional: true + react: + optional: true + optionalDependencies: + '@types/markdown-it': 12.2.3 + dev: true + /@melt-ui/pp@0.1.2(@melt-ui/svelte@0.40.0)(svelte@4.2.0): resolution: {integrity: sha512-GZeqp7UWLNZUC2dJpREnZrWMR88vy27WO7C3cIBz4KW3/CFD19FjNkd3VbSRfcRryrMkdnEs9nu2VUa8/0u58w==} engines: {pnpm: '>=8.6.3'} @@ -1134,6 +1158,25 @@ packages: '@types/node': 20.5.0 dev: true + /@types/linkify-it@3.0.3: + resolution: {integrity: sha512-pTjcqY9E4nOI55Wgpz7eiI8+LzdYnw3qxXCfHyBDdPbYvbyLgWLJGh8EdPvqawwMK1Uo1794AUkkR38Fr0g+2g==} + dev: true + optional: true + + /@types/markdown-it@12.2.3: + resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==} + requiresBuild: true + dependencies: + '@types/linkify-it': 3.0.3 + '@types/mdurl': 1.0.2 + dev: true + optional: true + + /@types/mdurl@1.0.2: + resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==} + dev: true + optional: true + /@types/node@16.9.1: resolution: {integrity: sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==} dev: true @@ -1422,6 +1465,10 @@ packages: engines: {node: '>=12'} dev: true + /ansi-sequence-parser@1.1.1: + resolution: {integrity: sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==} + dev: false + /ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} @@ -2723,6 +2770,15 @@ packages: kind-of: 4.0.0 dev: true + /highlight.js@11.8.0: + resolution: {integrity: sha512-MedQhoqVdr0U6SSnWPzfiadUcDHfN/Wzq25AkXiQv9oiOO/sG0S7XkvpFIqWBl9Yq1UYyYOOVORs5UW2XlPyzg==} + engines: {node: '>=12.0.0'} + dev: false + + /html-escaper@3.0.3: + resolution: {integrity: sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==} + dev: true + /htmlparser2@8.0.2: resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==} dependencies: @@ -3056,7 +3112,6 @@ packages: /jsonc-parser@3.2.0: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} - dev: true /jsonfile@6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} @@ -4155,6 +4210,15 @@ packages: engines: {node: '>=8'} dev: true + /shiki@0.14.4: + resolution: {integrity: sha512-IXCRip2IQzKwxArNNq1S+On4KPML3Yyn8Zzs/xRgcgOWIr8ntIK3IKzjFPfjy/7kt9ZMjc+FItfqHRBg8b6tNQ==} + dependencies: + ansi-sequence-parser: 1.1.1 + jsonc-parser: 3.2.0 + vscode-oniguruma: 1.7.0 + vscode-textmate: 8.0.0 + dev: false + /siginfo@2.0.0: resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} dev: true @@ -4459,6 +4523,19 @@ packages: svelte: 4.2.0 dev: true + /svelte-markdoc-preprocess@0.3.0: + resolution: {integrity: sha512-o1VisVNqRdeCTjYbhxtpsxGquujKT3Ksnk4ttdPxi2dWKFBO1IvtxGKiDudVMMI+s3mcsbu/uA/0bYfeqsf+DQ==} + dependencies: + '@markdoc/markdoc': 0.3.2 + html-escaper: 3.0.3 + js-yaml: 4.1.0 + svelte: 4.2.0 + typescript: 5.1.6 + transitivePeerDependencies: + - '@types/react' + - react + dev: true + /svelte-preprocess@5.0.4(postcss@8.4.27)(sass@1.65.1)(svelte@4.2.0)(typescript@5.1.6): resolution: {integrity: sha512-ABia2QegosxOGsVlsSBJvoWeXy1wUKSfF7SWJdTjLAbx/Y3SrVevvvbFNQqrSJw89+lNSsM58SipmZJ5SRi5iw==} engines: {node: '>= 14.10.0'} @@ -5015,6 +5092,14 @@ packages: - terser dev: true + /vscode-oniguruma@1.7.0: + resolution: {integrity: sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==} + dev: false + + /vscode-textmate@8.0.0: + resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==} + dev: false + /which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} diff --git a/src/markdoc/layouts/Tutorial.svelte b/src/markdoc/layouts/Tutorial.svelte new file mode 100644 index 000000000..d56bd8b33 --- /dev/null +++ b/src/markdoc/layouts/Tutorial.svelte @@ -0,0 +1,206 @@ + + + + + + {title} + + + + +
+
+
+
+ + +
+ +

{title}

+
+
+
+
+
+ + +