Skip to content

Commit

Permalink
Fix math escaping (#430)
Browse files Browse the repository at this point in the history
Fix #429.
Fix #413.

Signed-off-by: Jonas Dujava <[email protected]>
Co-authored-by: Peter West <[email protected]>
  • Loading branch information
jdujava and FlamingTempura authored Sep 7, 2024
1 parent a7f0c13 commit 0699308
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bibtex-tidy.js

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

4 changes: 2 additions & 2 deletions bin/bibtex-tidy

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

2 changes: 1 addition & 1 deletion docs/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function escapeSpecialCharacters(str: string): string {
let result = str;
const mathExpressions: string[] = [];

result = result.replace(/\$[^$]+\$/, (match) => {
result = result.replace(/\$[^$]+\$/g, (match) => {
mathExpressions.push(match);
return `MATH.EXP.${mathExpressions.length - 1}`;
});
Expand All @@ -30,7 +30,7 @@ export function escapeSpecialCharacters(str: string): string {
newstr += specialCharacters.get(c) ?? result[i];
}
return newstr.replace(
/MATH\.EXP\.(\d+)/,
/MATH\.EXP\.(\d+)/g,
(_, i) => mathExpressions[Number(i)] ?? "",
);
}
Expand Down

0 comments on commit 0699308

Please sign in to comment.