Skip to content

Commit

Permalink
bugfix: Delete the escapeDollarNumber function, which causes errors i…
Browse files Browse the repository at this point in the history
…n rendering a latex string
  • Loading branch information
butterfly authored and butterfly committed Mar 26, 2024
1 parent a4e4286 commit 4d6b981
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions app/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,6 @@ export function PreCode(props: { children: any }) {
);
}

function escapeDollarNumber(text: string) {
let escapedText = "";

for (let i = 0; i < text.length; i += 1) {
let char = text[i];
const nextChar = text[i + 1] || " ";

if (char === "$" && nextChar >= "0" && nextChar <= "9") {
char = "\\$";
}

escapedText += char;
}

return escapedText;
}

function escapeBrackets(text: string) {
const pattern =
/(```[\s\S]*?```|`.*?`)|\\\[([\s\S]*?[^\\])\\\]|\\\((.*?)\\\)/g;
Expand All @@ -136,7 +119,7 @@ function escapeBrackets(text: string) {

function _MarkDownContent(props: { content: string }) {
const escapedContent = useMemo(
() => escapeBrackets(escapeDollarNumber(props.content)),
() => escapeBrackets(props.content),
[props.content],
);

Expand Down

0 comments on commit 4d6b981

Please sign in to comment.