Elffuss BraidHub

kikocis/continue public

dfc814e4318e · 477 BRawPermalink
1/*
2Currently double dollar latext with new lines causes truncation error
3So this pseudo-remark plugin removes internal newlines with double dollar signs
4*/
5export function fixDoubleDollarNewLineLatex(text: string): string {
6 // Match LaTeX blocks delimited by $$ with newlines
7 const pattern = /\$\$(?:\r?\n)(.*?)(?:\r?\n)\$\$/gms;
8
9 // Replace each matched block with $$ without newline
10 const replacedText = text.replace(pattern, "$$$$$1$$$$");
11
12 return replacedText;
13}