From e9df76a681667fe57a320b5d1c5b7c567c78d3f6 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Wed, 11 May 2022 00:38:41 +0200 Subject: [PATCH] syntax hightlighting --- package-lock.json | 32 ++- package.json | 11 +- web/opener/Text.svelte | 37 +-- web/opener/getLangFromShare.ts | 420 +++++++++++++++++++++++++++++++++ 4 files changed, 479 insertions(+), 21 deletions(-) create mode 100644 web/opener/getLangFromShare.ts diff --git a/package-lock.json b/package-lock.json index f30fb3e..1241a15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,8 @@ "name": "s3-share", "version": "1.0.0", "dependencies": { - "sirv-cli": "^2.0.0" + "sirv-cli": "^2.0.0", + "svelte-highlight": "^6.0.1" }, "devDependencies": { "@rollup/plugin-commonjs": "^17.0.0", @@ -587,6 +588,14 @@ "node": ">=4" } }, + "node_modules/highlight.js": { + "version": "11.5.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.5.0.tgz", + "integrity": "sha512-SM6WDj5/C+VfIY8pZ6yW6Xa0Fm1tniYVYWYW1Q/DcMnISZFrC3aQAZZZFAAZtybKNrGId3p/DNbFTtcTXXgYBw==", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -1375,6 +1384,14 @@ "svelte": "^3.24.0" } }, + "node_modules/svelte-highlight": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/svelte-highlight/-/svelte-highlight-6.0.1.tgz", + "integrity": "sha512-FOe0ePVoP59VO7e0cAXZ7OMooXEuC/lh0FK4Zr++3qRzNWm14a/ljICBTGZXqD+/l3mAIB5EzkVu3Nc/TZEyuA==", + "dependencies": { + "highlight.js": "11.5.0" + } + }, "node_modules/svelte-preprocess": { "version": "4.10.6", "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-4.10.6.tgz", @@ -2004,6 +2021,11 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "highlight.js": { + "version": "11.5.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.5.0.tgz", + "integrity": "sha512-SM6WDj5/C+VfIY8pZ6yW6Xa0Fm1tniYVYWYW1Q/DcMnISZFrC3aQAZZZFAAZtybKNrGId3p/DNbFTtcTXXgYBw==" + }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -2585,6 +2607,14 @@ "typescript": "*" } }, + "svelte-highlight": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/svelte-highlight/-/svelte-highlight-6.0.1.tgz", + "integrity": "sha512-FOe0ePVoP59VO7e0cAXZ7OMooXEuC/lh0FK4Zr++3qRzNWm14a/ljICBTGZXqD+/l3mAIB5EzkVu3Nc/TZEyuA==", + "requires": { + "highlight.js": "11.5.0" + } + }, "svelte-preprocess": { "version": "4.10.6", "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-4.10.6.tgz", diff --git a/package.json b/package.json index 9deb191..d181753 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "devDependencies": { "@rollup/plugin-commonjs": "^17.0.0", "@rollup/plugin-node-resolve": "^11.0.0", + "@rollup/plugin-typescript": "^8.0.0", + "@tsconfig/svelte": "^2.0.0", "rollup": "^2.3.4", "rollup-plugin-css-only": "^3.1.0", "rollup-plugin-livereload": "^2.0.0", @@ -19,12 +21,11 @@ "svelte": "^3.0.0", "svelte-check": "^2.0.0", "svelte-preprocess": "^4.0.0", - "@rollup/plugin-typescript": "^8.0.0", - "typescript": "^4.0.0", "tslib": "^2.0.0", - "@tsconfig/svelte": "^2.0.0" + "typescript": "^4.0.0" }, "dependencies": { - "sirv-cli": "^2.0.0" + "sirv-cli": "^2.0.0", + "svelte-highlight": "^6.0.1" } -} \ No newline at end of file +} diff --git a/web/opener/Text.svelte b/web/opener/Text.svelte index eeca54a..7c70414 100644 --- a/web/opener/Text.svelte +++ b/web/opener/Text.svelte @@ -1,31 +1,38 @@ + + + {@html highlightStyle} + +
{filename}
-
{ content }
+ + {#await Promise.all([loadShare(), loadLang()])} + Loading... + {:then v} + + {/await}