Add syntax highlighting for pascal and clojure languages.
This commit is contained in:
parent
aa20fde7d9
commit
b4a87a6de3
3 changed files with 39 additions and 31 deletions
56
gui/package-lock.json
generated
56
gui/package-lock.json
generated
|
|
@ -30,6 +30,7 @@
|
|||
"dompurify": "^3.0.6",
|
||||
"downshift": "^7.6.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lowlight": "^3.3.0",
|
||||
"minisearch": "^7.0.2",
|
||||
"mustache": "^4.2.0",
|
||||
"posthog-js": "^1.130.1",
|
||||
|
|
@ -7688,18 +7689,28 @@
|
|||
}
|
||||
},
|
||||
"node_modules/lowlight": {
|
||||
"version": "1.20.0",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.20.0.tgz",
|
||||
"integrity": "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==",
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-3.3.0.tgz",
|
||||
"integrity": "sha512-0JNhgFoPvP6U6lE/UdVsSq99tn6DhjjpAj5MxG49ewd2mOBVtwWYIT8ClyABhq198aXXODMU6Ox8DrGy/CpTZQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fault": "^1.0.0",
|
||||
"highlight.js": "~10.7.0"
|
||||
"@types/hast": "^3.0.0",
|
||||
"devlop": "^1.0.0",
|
||||
"highlight.js": "~11.11.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/lowlight/node_modules/highlight.js": {
|
||||
"version": "11.11.1",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz",
|
||||
"integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "4.1.5",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
|
||||
|
|
@ -10087,6 +10098,19 @@
|
|||
"react": ">= 0.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-syntax-highlighter/node_modules/lowlight": {
|
||||
"version": "1.20.0",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.20.0.tgz",
|
||||
"integrity": "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==",
|
||||
"dependencies": {
|
||||
"fault": "^1.0.0",
|
||||
"highlight.js": "~10.7.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/react-tooltip": {
|
||||
"version": "5.28.0",
|
||||
"resolved": "https://registry.npmjs.org/react-tooltip/-/react-tooltip-5.28.0.tgz",
|
||||
|
|
@ -10371,28 +10395,6 @@
|
|||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/rehype-highlight/node_modules/highlight.js": {
|
||||
"version": "11.9.0",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.9.0.tgz",
|
||||
"integrity": "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rehype-highlight/node_modules/lowlight": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-3.1.0.tgz",
|
||||
"integrity": "sha512-CEbNVoSikAxwDMDPjXlqlFYiZLkDJHwyGu/MfOsJnF3d7f3tds5J3z8s/l9TMXhzfsJCCJEAsD78842mwmg0PQ==",
|
||||
"dependencies": {
|
||||
"@types/hast": "^3.0.0",
|
||||
"devlop": "^1.0.0",
|
||||
"highlight.js": "~11.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/rehype-katex": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.1.tgz",
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
"dompurify": "^3.0.6",
|
||||
"downshift": "^7.6.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lowlight": "^3.3.0",
|
||||
"minisearch": "^7.0.2",
|
||||
"mustache": "^4.2.0",
|
||||
"posthog-js": "^1.130.1",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import { ctxItemToRifWithContents } from "core/commands/util";
|
||||
import clojure from "highlight.js/lib/languages/clojure";
|
||||
import Delphi from "highlight.js/lib/languages/Delphi";
|
||||
import { common } from "lowlight";
|
||||
import { memo, useEffect, useMemo } from "react";
|
||||
import { useRemark } from "react-remark";
|
||||
import rehypeHighlight, { Options } from "rehype-highlight";
|
||||
|
|
@ -234,14 +237,16 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
rehypePlugins: [
|
||||
rehypeKatex as any,
|
||||
{},
|
||||
rehypeHighlight as any,
|
||||
[
|
||||
rehypeHighlight,
|
||||
{
|
||||
languages: { ...common, clojure, Delphi},
|
||||
} as Options,
|
||||
],
|
||||
// Note: An empty obj is the default behavior, but leaving this here for scaffolding to
|
||||
// add unsupported languages in the future. We will need to install the `lowlight` package
|
||||
// to use the `common` language set in addition to unsupported languages.
|
||||
// https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md
|
||||
{
|
||||
// languages: {},
|
||||
} as Options,
|
||||
() => {
|
||||
let codeBlockIndex = 0;
|
||||
return (tree) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue