MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

Using XyJax-v3 with Markdown-It-MathJax3

Open ych817 opened this issue 9 months ago • 3 comments

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 :

  1. npm install git://github.com/sonoisa/XyJax-v3.git to make xyjax folder show up inside my node_modules
  2. import 'xyjax/src/core/XypicConfiguration.js'; in index.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 ...

Image

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 .

ych817 avatar Apr 11 '25 03:04 ych817

how to append import "xyjax" to AllPackages

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.

dpvc avatar Apr 12 '25 21:04 dpvc

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 :

Image

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;

ych817 avatar Apr 13 '25 07:04 ych817

do I need to create an XypicConfiguration.d.ts for 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?

dpvc avatar Apr 23 '25 08:04 dpvc