feat(bot,frontend,backend): add integration with external collaborative solver
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Marked } from 'marked';
|
||||
|
||||
const marked = new Marked({ breaks: true, gfm: true });
|
||||
|
||||
export function processLatex(text: string): string {
|
||||
return text
|
||||
.replace(/\$\$(.*?)\$\$/gs, (_, tex) => {
|
||||
const encoded = encodeURIComponent(tex.trim());
|
||||
return `<img src="/service/latex?tex=${encoded}&display=1" alt="LaTeX" class="block my-1 max-h-12" />`;
|
||||
})
|
||||
.replace(/\$(.+?)\$/g, (_, tex) => {
|
||||
const encoded = encodeURIComponent(tex.trim());
|
||||
return `<img src="/service/latex?tex=${encoded}" alt="LaTeX" class="inline-block align-middle max-h-4" />`;
|
||||
});
|
||||
}
|
||||
|
||||
export function processContent(text: string): string {
|
||||
return marked.parse(processLatex(text)) as string;
|
||||
}
|
||||
Reference in New Issue
Block a user