shd101wyy / vscode-markdown-preview-enhanced

One of the "BEST" markdown preview extensions for Visual Studio Code
https://shd101wyy.github.io/markdown-preview-enhanced
Other
1.36k stars 169 forks source link

[BUG] gdef macros not persist between math expressions using KaTeX parser #1973

Open AntltNoProb opened 1 month ago

AntltNoProb commented 1 month ago

Describe the bug Global defined macros (by \gdef, \global\def and so on) not persist between math expressions with KaTeX being used. These macros behave like \def , which only works in the same block. Trying to use it in another block causes error.

Environment

Expected behavior macros defined by \gdef should persist globally as katex document describes.

Markdown file

## local -> ok  

$$
\gdef\a{1234567890}
\a
$$

## global -> not work  

$$
\a
$$

Screenshots image

AntltNoProb commented 1 month ago

After testing with some old version of mpe, I found this bug exists since 0.8.9.
I guess this commit in crossnote might be the reason: https://github.com/shd101wyy/crossnote/commit/701ab4f64a196585564102f9a3f2ca67978d2514 . Maybe the strucutredClone prevents the macro to be passed to other math expressions for some reasons.