Pass one shared macros object into every call to katex renderer#148006
Pass one shared macros object into every call to katex renderer#148006mjbvz merged 3 commits intomicrosoft:mainfrom
macros object into every call to katex renderer#148006Conversation
|
The issue of katex macros not persisting across math expressions also occurs in Jupyter notebook environment of VSC. Would this PR resolve the macro issue for Jupyter notebooks? |
|
What if you delete a previously declared macro? With this approach won't it (incorrectly) still be defined? |
|
Yes, Indeed. That behavior is certainly incorrect for the markdown file preview. The new version of the patch solves the issue resetting the This approach does not work for notebooks since each markdown cell is a standalone markdown document. However, in this case, I'm not sure the actual behavior is an issue and needs to be corrected. In some sense, it seems to match the way the notebook works. Code cells act similarly. If you set a variable in a cell, execute the cell and then remove it, the variable is still accessible in the rest of the notebook. Maybe we can add a command to reset the markdown engine just like the command to reload the kernel. What do you think? |
|
Thanks. The new behavior sounds reasonable enough for notebooks too so we can merge as-is and wait for feedback |
|
@AlbertHilb I tested this and the issue (#125425) that I reported related to markdown /necommand in Jypitor notebooks is working fine with your fix. Thanks! |


This PR fixes #125425
In order to make macros defined by the author persistent between KaTeX elements, we need to pass one shared
macrosobject into every call to the renderer. KaTeX will insert macros into that object and since it continues to exist between calls, macros will persist. See KaTeX docs.