Ir1d/rehype-mathjax

Package doesn’t seem to work

wooorm opened this issue · 19 comments

Hi! 👋

Seems this package doesn’t work yet, from the code? We made a version here: https://github.com/remarkjs/remark-math/tree/master/packages/rehype-mathjax, and I just found out Ir1d/rehype-mathjax exists when I tried to publish it!

Are you interested in maintaining this & continuing work on it? If not, could we use the name on npm?

@Ir1d Ping! 🔔

Ir1d commented

Hi @wooorm , apologize that I missed this issue due to a large amount of incoming emails.

Seems this package doesn’t work yet, from the code ?

Well actually this package works in the way to expose the mathjax related tags to the frontend and then use the mathjax js and css from the client side.. we're currently using this in oi-wiki-ng

The reason I created this package is that I asked you several months ago about mathjax related issues and there was no related packages yet. I'd be glad to let you use the name since you're now maintaining an official version.

btw, I think your official version here is a server side render solution for mathjax right?

Ir1d commented

btw, I think your official version here is a server side render solution for mathjax right?

If I get this correct.. this make me believe that my client side render solution still makes some sense to exist 😂

Will you consider exposing an option to let your version support client side render?

👋 No problem!

We support MathJax’ SVG and CHTML output and do all the rendering for users, so they don’t need to load MathJax separately. And we do have a DOM adapter. Is there anything different for the way you want to load MathJax?

(If you’re using MathJax yourself, you do have some more options, which we should add to “our” rehype-mathjax of course, but I think that’s a separate issue!)

Ir1d commented

oh I didn't notice there was a browser.js 😂
Does that enable client side render of mathjax? I mean things like this:

<p>$a$</p>
<script src="https://cdn.staticfile.org/mathjax/3.0.1/es5/tex-mml-chtml.js" />

I'm running a large gatsby site and want to use client side render for fast development. So I think it would be nice to provide an option to leave the math formulas untouched.

And how do I transfer the ownership of the package rehype-mathjax? I'm not sure if I should delete it first.

image

I figure out that I can add you to maintainers actually, there's an option in npm package settings.

Does that enable client side render of mathjax? I mean things like this:

<p>$a$</p>
<script src="https://cdn.staticfile.org/mathjax/3.0.1/es5/tex-mml-chtml.js" />

No, that won’t work. It would load MathJax twice. What we’re doing is generating CHTML on the server if you process your markdown orHTML on the server, or on the client if you do it on the client. We’re already loading MathJax!

I figure out that I can add you to maintainers actually, there's an option in npm package settings.

Yup, that would be the solution. And I would publish a new major version so we won’t break people on the current version’s build!

Ir1d commented

Yup, that would be the solution. And I would publish a new major version so we won’t break people on the current version’s build!

Great, I've added you to https://www.npmjs.com/package/rehype-mathjax/access

It would load MathJax twice.

Seems you misunderstood my question. What I'm suggesting is that there's a use case when we want to leave the math formulas untouched during remark and rehype phase, and let the client browser to load mathjax js and css. Is there any solution already for this?

I understand that your implementation currently provides the mathjax generated results of each formula (which I referred to as server-side-render), just wondering if there's a neat solution to escape this stage and call mathjax on client browser.

💙

What I'm suggesting is that there's a use case when we want to leave the math formulas untouched during remark and rehype phase, and let the client browser to load mathjax js and css.

What is the reason for this use case? MathJax is pretty heavy on the browser, so that’s a big pro for doing it first with unified, no?

Ir1d commented

Yes it's indeed a big pro to do it on servers instead of clients, but in my case the whole gatsby site has over 200 pages and mathjax ssr would need over 5 minutes.. We're currently using client side mathjax for faster development, and mathjax ssr for production.

5 minutes! 😨 is MathJax that slow?! Is there so much Math! Wow. 🤔

tani commented

At this time, I added new feature for your problem. Please give me a moment.

Ir1d commented

5 minutes! 😨 is MathJax that slow?! Is there so much Math! Wow. 🤔

It's a site about programming 😂 and there're a lot small formulas in pages.

tani commented

I hope that rehype-mathjax/none help to solve your problem. 😉

tani commented

Shall we resume discussion?

Ir1d commented

Hi @nzt I've already added @wooorm in npm, he'll have the permission to publish new versions of the packages.

tani commented

@Ir1d I respect your previous work. I had never considered the idea to render formulas in client side. I proud to merge your idea to my contribution.
@wooorm Let's upload new version of rehype-mathjax!

Working on it. But want to fix a couple things first, and improve docs. Will send a PR.

Oh btw, @Ir1d time to archive this repo maybe? Going to close this issue as it’s solved!

Ir1d commented

Sure @wooorm.