remark-math icon indicating copy to clipboard operation
remark-math copied to clipboard

rehype-mathjax: use `abstractAdopter` instead of `jsdomAdaptor` / `browserAdaptor`

Open wooorm opened this issue 4 years ago • 5 comments

Problem

JsDom is heavy, and an alternative to rehype, which we’re already using. It’s probably better to use AbstractAdopter and map it to hast, instead of using jsdomAdaptor / browserAdaptor to create a DOM and then transform that to hast.

Expected behaviour

Directly do mathjax -> hast, instead of mathjax -> dom -> hast

wooorm avatar Apr 20 '20 08:04 wooorm

lightAaptor is also adaptor for lightDOM. Thus, mathjax -> dom -> hast is not changed. If you want to do that, we should implement AbstractDOMAdopter abstract class to hast instead. https://github.com/mathjax/MathJax-src/blob/5e9a5c66de610dd754a0377b278892ae4f007058/ts/core/DOMAdaptor.ts#L343

tani avatar Apr 20 '20 10:04 tani

Oh great, that looks better! I couldn’t find any docs on these things 🤔 is there some place where you find these things, or is it reading the code too?

wooorm avatar Apr 20 '20 10:04 wooorm

I've just read the code. Currently, the developers guide of MathJax is under construction. https://docs.mathjax.org/en/latest/api/direct.html

tani avatar Apr 20 '20 13:04 tani

Was looking at this some more today, I won’t have a lot of time to work on it, but I think it would be a very valuable feature. @tani, is this something you could take on? Or someone else?

wooorm avatar Jun 25 '20 19:06 wooorm

@tani was that 🚀 a yes? ;)

wooorm avatar Aug 22 '20 18:08 wooorm