Skip to content

Commit d835dcf

Browse files
authored
Merge branch 'main' into fix/profile-caching
2 parents f18fc76 + 21d63da commit d835dcf

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

front_end/src/components/markdown_editor/initialized_editor.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,22 @@ const PrismCodeBlock: FC<{ code?: string; language?: string }> = ({
7373
theme === "dark" ? prismThemes.dracula : prismThemes.github;
7474

7575
const raw = (language as string | undefined) ?? "ts";
76-
const prismLang = CANONICAL_TO_PRISM[normalizeLang(raw)] ?? "tsx";
76+
const normalizedLang = normalizeLang(raw);
7777
const codeTrimmed = (code ?? "").replace(/^\n+|\n+$/g, "");
7878

79+
// Handle plain text without syntax highlighting
80+
if (normalizedLang === "text") {
81+
return (
82+
<div className="my-4">
83+
<pre className="overflow-x-auto rounded border border-gray-300 bg-gray-100 p-3 dark:border-gray-300-dark dark:bg-gray-100-dark">
84+
{codeTrimmed}
85+
</pre>
86+
</div>
87+
);
88+
}
89+
90+
const prismLang = CANONICAL_TO_PRISM[normalizedLang] ?? "tsx";
91+
7992
return (
8093
<div className="my-4">
8194
<Highlight
@@ -256,7 +269,7 @@ const InitializedMarkdownEditor: FC<
256269
}
257270
return [
258271
...common,
259-
codeBlockPlugin({ defaultCodeBlockLanguage: "ts" }),
272+
codeBlockPlugin({ defaultCodeBlockLanguage: "text" }),
260273
codeMirrorPlugin({
261274
codeBlockLanguages: CANONICAL_TO_LABEL,
262275
}),

front_end/src/components/markdown_editor/plugins/code/languages.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Language } from "prism-react-renderer";
22

33
export const CANONICAL_TO_LABEL = {
4+
text: "Plain text",
45
ts: "TypeScript",
56
tsx: "TSX",
67
js: "JavaScript",
@@ -14,6 +15,10 @@ export const CANONICAL_TO_LABEL = {
1415
export type CanonicalLang = keyof typeof CANONICAL_TO_LABEL;
1516

1617
const ALIAS_TO_CANONICAL: Record<string, CanonicalLang> = {
18+
text: "text",
19+
plaintext: "text",
20+
plain: "text",
21+
1722
typescript: "ts",
1823
ts: "ts",
1924
tsx: "tsx",
@@ -42,6 +47,7 @@ export function normalizeLang(
4247
}
4348

4449
export const CANONICAL_TO_PRISM: Record<CanonicalLang, Language> = {
50+
text: "text" as Language,
4551
ts: "typescript",
4652
tsx: "tsx",
4753
js: "javascript",

screenshot/poetry.lock

Lines changed: 4 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)