-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass one shared macros
object into every call to katex renderer
#148006
Conversation
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
macros
object 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.