|
|
@ -3,8 +3,7 @@ import assert from "assert"; |
|
|
|
// Node is absolutely stupid. The remarkable project has an esm setting which
|
|
|
|
// Node is absolutely stupid. The remarkable project has an esm setting which
|
|
|
|
// specifies the dist/esm directory, but it completely ignores it and complains.
|
|
|
|
// specifies the dist/esm directory, but it completely ignores it and complains.
|
|
|
|
import { linkify } from "remarkable/dist/cjs/linkify.js"; |
|
|
|
import { linkify } from "remarkable/dist/cjs/linkify.js"; |
|
|
|
import Prism from "prismjs"; |
|
|
|
import Prism from "../static/js/prism.cjs"; |
|
|
|
import loadLanguages from "prismjs/components/index.js"; |
|
|
|
|
|
|
|
import _ from "lodash"; |
|
|
|
import _ from "lodash"; |
|
|
|
import slugify from "slugify"; |
|
|
|
import slugify from "slugify"; |
|
|
|
import fs from "fs"; |
|
|
|
import fs from "fs"; |
|
|
@ -52,15 +51,10 @@ const line_number_spans = (str) => { |
|
|
|
* Runs Prism on the string, defaulting to the "markup" |
|
|
|
* Runs Prism on the string, defaulting to the "markup" |
|
|
|
* language which will encode most code correctly even |
|
|
|
* language which will encode most code correctly even |
|
|
|
* if you don't specify a language after the ``` |
|
|
|
* if you don't specify a language after the ``` |
|
|
|
* */ |
|
|
|
**/ |
|
|
|
const run_prism = (str, lang="markup") => { |
|
|
|
const run_prism = (str, lang="markup") => { |
|
|
|
assert(lang !== undefined, "Language can't be undefined."); |
|
|
|
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
|
|
|
|
// do the check again since the language might not exist
|
|
|
|
if(Prism.languages[lang]) { |
|
|
|
if(Prism.languages[lang]) { |
|
|
|
return Prism.highlight(str, Prism.languages[lang], lang); |
|
|
|
return Prism.highlight(str, Prism.languages[lang], lang); |
|
|
|