Skip to content

Commit

Permalink
fix: Fixed a katex rendering bug (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
shd101wyy committed Oct 23, 2023
1 parent 9afc685 commit 701ab4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Please visit https://github.com/shd101wyy/vscode-markdown-preview-enhanced/relea

## [Unreleased]

## [0.9.5] - 2023-10-23

### Bug fixes

- Fixed of bug of rendering the KaTeX math expression: https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1853

## [0.9.4] - 2023-10-21

### New features
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crossnote",
"version": "0.9.4",
"version": "0.9.5",
"description": "A powerful markdown notebook tool",
"keywords": [
"markdown"
Expand Down
9 changes: 8 additions & 1 deletion src/renderers/parse-math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ export default ({
try {
return katex.renderToString(
content,
Object.assign({}, katexConfig, { displayMode }),
Object.assign(
{},
// NOTE: strucutredClone is necessary here: https://github.com/shd101wyy/vscode-markdown-preview-enhanced/issues/1853
// it seems like KaTeX will modify the config object,
// which will cause `JSON.stringify` in `generateHTMLTemplateForPreview` function in `markdown-engine/index.ts` to fail
structuredClone(katexConfig),
{ displayMode },
),
);
} catch (error) {
return `<span style="color: #ee7f49; font-weight: 500;">${error.toString()}</span>`;
Expand Down

0 comments on commit 701ab4f

Please sign in to comment.