add support for even more languages

This commit is contained in:
Nate 2025-04-23 16:45:37 -07:00
parent b9fbdb23fd
commit e023241635
2 changed files with 37 additions and 10 deletions

View file

@ -1,10 +1,6 @@
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, useRef } from "react";
import { useRemark } from "react-remark";
import rehypeHighlight, { Options } from "rehype-highlight";
import rehypeKatex from "rehype-katex";
import remarkMath from "remark-math";
import styled from "styled-components";
@ -25,6 +21,7 @@ import { ToolTip } from "../gui/Tooltip";
import FilenameLink from "./FilenameLink";
import "./katex.css";
import "./markdown.css";
import { rehypeHighlightPlugin } from "./rehypeHighlightPlugin";
import { StepContainerPreToolbar } from "./StepContainerPreToolbar";
import SymbolLink from "./SymbolLink";
import { SyntaxHighlightedPre } from "./SyntaxHighlightedPre";
@ -257,12 +254,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
rehypePlugins: [
rehypeKatex as any,
{},
[
rehypeHighlight,
{
languages: { ...common, clojure, Delphi },
} as Options,
],
rehypeHighlightPlugin(),
// 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.

View file

@ -0,0 +1,35 @@
// Feel free to add more!
// See gui/node_modules/highlight.js/lib/languages for the full available list
import clojure from "highlight.js/lib/languages/clojure";
import Delphi from "highlight.js/lib/languages/Delphi";
import elixir from "highlight.js/lib/languages/elixir";
import julia from "highlight.js/lib/languages/julia";
import lisp from "highlight.js/lib/languages/lisp";
import matlab from "highlight.js/lib/languages/matlab";
import ocaml from "highlight.js/lib/languages/ocaml";
import powershell from "highlight.js/lib/languages/powershell";
import protobuf from "highlight.js/lib/languages/protobuf";
import verilog from "highlight.js/lib/languages/verilog";
import { common } from "lowlight";
import rehypeHighlight, { Options } from "rehype-highlight";
export function rehypeHighlightPlugin() {
return [
rehypeHighlight,
{
languages: {
...common,
clojure,
Delphi,
elixir,
julia,
protobuf,
verilog,
powershell,
ocaml,
matlab,
lisp,
},
} as Options,
];
}