Skip to content

Commit

Permalink
Fix #4105 Retry MathJax if failed rendering with newcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Dec 23, 2023
1 parent 4ae0b5c commit bea3b67
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/preview/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ async function onTeX(document: vscode.TextDocument, tex: TeXMathEnv, newCommand:
const md = utils.svgToDataUrl(xml)
return new vscode.Hover(new vscode.MarkdownString(MathPreviewUtils.addDummyCodeBlock(`![equation](${md})`)), tex.range )
} catch(e) {
logger.logError(`Failed rendering MathJax ${typesetArg} .`, e)
throw e
if (newCommand !== '') {
logger.log(`Failed rendering MathJax ${typesetArg} . Try removing new command definitions.`)
return await onTeX(document, tex, '')
} else {
logger.logError(`Failed rendering MathJax ${typesetArg} .`, e)
throw e
}
}
}

Expand Down

0 comments on commit bea3b67

Please sign in to comment.