Using XyJax-v3 with Markdown-It-MathJax3
I will post my question in here , As @dpvc said : )
Thank you @dpvc . I have done the following inside my local " markdown-it-mathjax3 " project folder :
-
npm install git://github.com/sonoisa/XyJax-v3.gitto makexyjaxfolder show up inside mynode_modules -
import 'xyjax/src/core/XypicConfiguration.js';inindex.ts
but how to append import "xyjax" to AllPackages ? Here is the relevant code in index.ts of markdown-it-mathjax3 :
import { AllPackages } from "mathjax-full/js/input/tex/AllPackages.js";
...
function plugin(md: MarkdownIt, options: any) {
// Default options
const documentOptions = {
InputJax: new TeX({ packages: AllPackages, ...options?.tex }),
OutputJax: new SVG({ fontCache: 'none', ...options?.svg })
}
const convertOptions = {
display: false
}
....
}
I tried to put import 'xyjax/src/core/XypicConfiguration.js'; inside ./markdown-it-mathjax3/node_modules/mathjax-full/js/input/tex/AllPackages.d.ts and then type npm run build , seems like nothing changed ...
Here is my package.json for my vitepress project :
{
"private": true,
"type": "module",
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"devDependencies": {
"markdown-it-mathjax3": "file:../markdown-it-mathjax3",
"vitepress": "latest"
}
}
not sure if this is the correct way for linking to my local markdown-it-mathjax3 project .
how to append
import "xyjax"toAllPackages
There are two natural ways that could be done. One would be to do
InputJax: new TeX({ packages: [...AllPackages, 'xyjax'], ...options?.tex }),
to make a new array that has everything from AllPackages, plus the 'xyjax' package. Alternatively you could do
AllPackages.push('xyjax');
just after importing AllPackages in order to add 'xyjax' to the end of that array. Either way should work.
Thank you for your immediate reply : ) I tried the second way to append xypic to AllPackages , however after I finish the compilation and run npm run docs:dev in my vitepress project , I got this in my browser :
I run my node.js inside WSL , my markdown-it-mathjax3 clone and my vitepress project are in the Arena folder .
do I need to create an XypicConfiguration.d.ts for xyjax-v3 ? Below is the BussproofsConfiguration.d.ts :
import { Configuration } from '../Configuration.js';
import './BussproofsMappings.js';
export declare const BussproofsConfiguration: Configuration;
do I need to create an
XypicConfiguration.d.tsfor xyjax-v3
If you are getting an error about a missing .d.ts file, then you could create one to avoid the message. You could use the bussproof one as a template and change Bussproofs to Xypic throughout. I haven't tried it, but that should do the trick.
In any case, this is not the source of the error in your image above. That indicates that xyjax is running, since the message comes from within its code. The error message indicates that TexParser is not properly defined at
https://github.com/sonoisa/XyJax-v3/blob/98dce6e8832036b8a3e0d7168522148b219deda5/src/core/XypicConfiguration.js#L46
That probably means that TexParser is null or undefined, which is a bit confusing, as it is imported here:
https://github.com/sonoisa/XyJax-v3/blob/98dce6e8832036b8a3e0d7168522148b219deda5/src/core/XypicConfiguration.js#L33
Can you add
console.log(TexParser);
just before line 46 in XypicConfiguration.js and see what value it has?