From b5c6f9272164c33dde1ce30d6998f6e59fe1ef5b Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 11 Dec 2022 22:30:10 -0500 Subject: [PATCH] Fix the docgen to use prism as a cjs file instead. --- client/components/CodeFormatter.svelte | 2 +- lib/docgen.js | 10 ++-------- package-lock.json | 14 -------------- package.json | 1 - static/js/{prism.js => prism.cjs} | 0 5 files changed, 3 insertions(+), 24 deletions(-) rename static/js/{prism.js => prism.cjs} (100%) diff --git a/client/components/CodeFormatter.svelte b/client/components/CodeFormatter.svelte index 67b1abc..e2e7821 100644 --- a/client/components/CodeFormatter.svelte +++ b/client/components/CodeFormatter.svelte @@ -6,4 +6,4 @@ }); - + diff --git a/lib/docgen.js b/lib/docgen.js index 235bbde..1660194 100644 --- a/lib/docgen.js +++ b/lib/docgen.js @@ -3,8 +3,7 @@ import assert from "assert"; // Node is absolutely stupid. The remarkable project has an esm setting which // specifies the dist/esm directory, but it completely ignores it and complains. import { linkify } from "remarkable/dist/cjs/linkify.js"; -import Prism from "prismjs"; -import loadLanguages from "prismjs/components/index.js"; +import Prism from "../static/js/prism.cjs"; import _ from "lodash"; import slugify from "slugify"; import fs from "fs"; @@ -52,15 +51,10 @@ const line_number_spans = (str) => { * Runs Prism on the string, defaulting to the "markup" * language which will encode most code correctly even * if you don't specify a language after the ``` - * */ + **/ const run_prism = (str, lang="markup") => { assert(lang !== undefined, "Language can't be undefined."); - if(!Prism.languages[lang]) { - // try to load the language - loadLanguages([lang]); - } - // do the check again since the language might not exist if(Prism.languages[lang]) { return Prism.highlight(str, Prism.languages[lang], lang); diff --git a/package-lock.json b/package-lock.json index 6d09c62..06f40e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,7 +51,6 @@ "pino-pretty": "^4.7.1", "playwright": "^1.23.3", "pm2": "^5.2.0", - "prismjs": "^1.27.0", "random": "3.0.6", "randomcolor": "^0.6.2", "redis": "^3.1.2", @@ -11394,14 +11393,6 @@ "node": ">= 0.8.0" } }, - "node_modules/prismjs": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz", - "integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==", - "engines": { - "node": ">=6" - } - }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -23118,11 +23109,6 @@ "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==" }, - "prismjs": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz", - "integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==" - }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", diff --git a/package.json b/package.json index 1f2f4cb..30c845d 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,6 @@ "pino-pretty": "^4.7.1", "playwright": "^1.23.3", "pm2": "^5.2.0", - "prismjs": "^1.27.0", "random": "3.0.6", "randomcolor": "^0.6.2", "redis": "^3.1.2", diff --git a/static/js/prism.js b/static/js/prism.cjs similarity index 100% rename from static/js/prism.js rename to static/js/prism.cjs