Skip to content
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

MathJax.startup.getComponents() does not remove macros in Mathjax 3 #2301

Closed
jano-m opened this issue Jan 22, 2020 · 3 comments
Closed

MathJax.startup.getComponents() does not remove macros in Mathjax 3 #2301

jano-m opened this issue Jan 22, 2020 · 3 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3.0

Comments

@jano-m
Copy link

jano-m commented Jan 22, 2020

when macros are added or modified in Mathjax.config.tex.macros, then MathJax.startup.getComponents() will update MathJax to use these new macros or new definitions, however, if macros are removed from Mathjax.config.tex.macros, getComponents() will remove them from internal state and they are still applied

@dpvc
Copy link
Member

dpvc commented Jan 22, 2020

Thanks for the report. The startup module is not really intended to be used in this way (modifying the configuration after the fact), but I'll look into it to see if it can be made to work.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Investigate labels Jan 22, 2020
@jano-m
Copy link
Author

jano-m commented Jan 23, 2020

Thanks! For my application, I would like to either modify settings on fly, or create a multiple number of MathJax instances each configured with different settings. Would the second be possible?

@dpvc
Copy link
Member

dpvc commented Jan 23, 2020

OK, I found the problem, and it was a bit subtle. In fact, there are two separate issues involved. The first is that the configMacros extension was using a common macro map, so that all instances of the TeX input jax would be using the same set of macros (clearly not correct). But the other issue was that there was a bug in the code that handles default options and user options so that the user-supplied macros were being copied into the original configMacros package definition, so that, even if a separate macros map was used for each TeX jax, the previous macros would still be added into it, because they had been (incorrectly) added to the definition of configMacros itself.

I have made a PR that fixes both problems. Once that is merged, your original getComponents() will do what you originally intended.

I would like to either modify settings on fly, or create a multiple number of MathJax instances each configured with different settings. Would the second be possible?

Yes, either as you did, by using getComponents() again (you could save MathJax.startup.document if you need to keep both forms active at once), or by creating the various components yourself by hand, passing them the settings you want. There are examples in the MathJax node demos repository (in the direct directory. These include lines like

const tex = new TeX({packages: ['base', 'ams', 'newcommand', 'autoload', 'require', 'configMacros']});

and you can add whatever the configuration you want to the object used to configure the TeX input jax, and could make tex1 and tex2 with different configurations.

Note, however, that the errors that I describe will cause the same problems as you have reported here, so this will not help until the next release of MathJax.

@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Feb 5, 2020
@dpvc dpvc added this to the MathJax v3.0.1 milestone Feb 7, 2020
@dpvc dpvc added Fixed v3.0 and removed Merged Merged into develop branch labels Feb 10, 2020
@dpvc dpvc closed this as completed Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3.0
Projects
None yet
Development

No branches or pull requests

2 participants