Skip to content

Commit

Permalink
Fix #4127 Remove macro star when rendering MathJax
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Jan 6, 2024
1 parent d60203c commit 058af44
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/preview/math/mathpreviewlib/newcommandfinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ function parseAst(content: string, node: Ast.Node): string[] {
lastContent = lastArg.content[lastArg.content.length - 1]
}
const end = (lastArg.content[lastArg.content.length - 1].position?.end.offset ?? -1 - closeBraceOffset) + closeBraceOffset
macros.push(content.slice(start, end + 1).replaceAll(/\\providecommand([^a-zA-Z])/g, '\\newcommand$1'))
macros.push(
content.slice(start, end + 1)
// Change providecommand to newcommand
.replaceAll(/^\\providecommand([^a-zA-Z])/g, '\\newcommand$1')
// Remove the star as MathJax does not support #4127
.replaceAll(/^\\([a-zA-Z]+)\*/g, '\\$1')
)
}

if ('content' in node && typeof node.content !== 'string') {
Expand Down

0 comments on commit 058af44

Please sign in to comment.