Skip to content

Commit

Permalink
refactor: Use prism as a project dependency (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian authored Dec 12, 2024
1 parent c6ad01d commit fe35f68
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 791 deletions.
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
}
},
"eslintIgnore": [
"prism.js",
"**/*.d.ts"
],
"prettier": {
Expand Down Expand Up @@ -88,6 +87,7 @@
"preact-iso": "^2.6.3",
"preact-markup": "^2.1.1",
"preact-render-to-string": "^6.4.1",
"prismjs": "^1.29.0",
"rollup": "^2.79.1",
"sucrase": "^3.32.0",
"yaml": "^2.6.1"
Expand Down
8 changes: 6 additions & 2 deletions plugins/precompile-markdown/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import yaml from 'yaml';
import { marked } from 'marked';
import Prism from 'prismjs';
import loadLanguages from 'prismjs/components/';
import { parse } from 'node-html-parser';
import { replace } from './gh-emoji/index.js';
import { Prism } from './prism.js';
import { textToBase64 } from '../../src/components/controllers/repl/query-encode.js';

// Prism will always load `markup`, `css`, `clike` and `javascript` by default.
// Any additional languages we need should be loaded here
loadLanguages(['typescript', 'tsx', 'json', 'bash', 'diff']);

/**
* @param {string} content
* @param {string} path
Expand Down Expand Up @@ -101,7 +106,6 @@ marked.use({
const [code, source, runInRepl] = processRepl(rawCodeBlockText);

Prism.languages[lang] == null
// TODO: Bash is the only missing one at the moment
? console.warn(`No Prism highlighter for language: ${lang}`)
: text = Prism.highlight(code, Prism.languages[lang], lang);

Expand Down
Loading

0 comments on commit fe35f68

Please sign in to comment.