Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
"date-fns": "^4.1.0",
"embla-carousel-react": "^8.5.1",
"highlight.js": "^11.9.0",
"highlightjs-structured-text": "^1.7.3",
"i18next": "^23.7.16",
"lodash": "^4.17.21",
"lucide-react": "^0.555.0",
"pdfjs-dist": "5.4.296",
"plotly.js": "^2.27.0",
"react": "^18.3.1",
"react-day-picker": "^9.11.1",
Expand All @@ -53,7 +55,6 @@
"react-hotkeys-hook": "^4.4.1",
"react-i18next": "^14.0.0",
"react-markdown": "^9.0.1",
"pdfjs-dist": "5.4.296",
"react-pdf": "^10.4.1",
"react-player": "^2.16.0",
"react-plotly.js": "^2.6.0",
Expand Down
16 changes: 16 additions & 0 deletions frontend/pnpm-lock.yaml

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

18 changes: 17 additions & 1 deletion frontend/src/components/CodeSnippet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { cn } from '@/lib/utils';
import hljs from 'highlight.js';
import hljs, { LanguageFn } from 'highlight.js';
import iecst from 'highlightjs-structured-text';
import { useEffect, useRef } from 'react';

import { Card, CardContent, CardHeader } from '@/components/ui/card';
Expand All @@ -8,11 +9,26 @@ import 'highlight.js/styles/monokai-sublime.css';

import CopyButton from './CopyButton';

// Append this list with missing languages as needed, ensuring they are registered with hljs
const additionalLanguages: LanguageRegistrations = [['iecst', iecst]];

registerAdditionalLanguages();

type LanguageRegistrations = [string, LanguageFn][];

interface CodeSnippetProps {
language: string;
children: string;
}

function registerAdditionalLanguages() {
for (const [name, lang] of additionalLanguages) {
if (!hljs.getLanguage(name)) {
hljs.registerLanguage(name, lang);
}
}
}

const HighlightedCode = ({ language, children }: CodeSnippetProps) => {
const codeRef = useRef<HTMLElement>(null);

Expand Down
5 changes: 5 additions & 0 deletions frontend/src/types/highlightjs-structured-text.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'highlightjs-structured-text' {
import { LanguageFn } from 'highlight.js';
const iecst: LanguageFn;
export default iecst;
}