Improve loading of @mathjax/src by import and require#1304
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1304 +/- ##
========================================
Coverage 86.71% 86.71%
========================================
Files 337 337
Lines 83979 83983 +4
Branches 4750 4750
========================================
+ Hits 72826 72830 +4
- Misses 11130 11153 +23
+ Partials 23 0 -23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I can't get the |
|
Hmmm.. It works for me. Can you be more explicit about what you are trying? I did the following from the MathJax-src directory: git checkout update/node-main
pnpm -s build-all
pnpm pack
mkdir /tmp/mjx
cd /tmp/mjx
pnpm install path-to-MathJax-src/mathjax-src-4.0.0-rc.4.tgz
pnpm install @mathjax/mathjax-newcm-font
cat > test.mjs
import MathJax from '@mathjax/src';
await MathJax.init({
loader: {
load: ['input/tex', 'output/chtml']
}
})
console.log(MathJax.startup.adaptor.outerHTML(MathJax.tex2chtml('x')));
^D
node test.mjsand got as expected. It also worked with |
|
It turns out we cannot bind to |
That only applies to interactive use of MathJax within |
This PR updates
node-main.*to export not justinit()but theMathJaxobject as the default object with theinit()function added to it. This allows for more meaningful imports, particularly for ES6 modules.Now you can do
rather than
(though both will work). It also allows
while still supporting
so this is backward compatible.
This needs to work in several settings:
with each followed by
await MathJax.init({...});orMathJax.init({...}).then(() => {...});as appropriate. Also,should work.
This gives a more natural definition for the
MathJaxvariable to be used later on in the application.