Standalone math rendering for web?

This might be a bit of a long shot, but I thought I’d ask anyway. I’m thinking about how to display interactive, semantic math on the web or in a web environment (in particular, in a VS code webview) I’d like to be able to (programmatically) attach javascript event listeners to individual pieces of the math.

I initially looked into MathJax and KaTeX, but it doesn’t seem like this is possible with those (or, if it is, I couldn’t find any documentation). As a long-time TeXmacs user, I thought TeXmacs’ expression tree transparency (as opposed to LaTeX’s macros) seemed perfect for preserving annotations which could govern interactive behavior like that.

If possible, I’d like to try “factoring out” some stage of the math/text rendering from the rest of TeXmacs in such a way that I can translate the result to a format appropriate for web—either HTML with fonts or SVG. But I’m totally unfamiliar with the TeXmacs source code. I realize there would be some (a lot of?) work to be done in translating the raw data to the relevant HTML or SVG, but I’m willing to try to do so if I can find my way into the source code’s overall layout. That is, if the necessary data (positions, bounding boxes, sizes, etc.) is even produced at any stage by TeXmacs. Is this kind of thing even feasible given how TeXmacs is structured? Which folders/files of source would be relevant here?

And, would doing this kind of thing be welcome? (Of course, if anything comes out of this, it would necessarily be open-source and refer directly to TeXmacs.)

Note: I’m aware that Mogan provides an experimental wasm version of TeXmacs, which looks very cool! But I need none of the “rest” of TeXmacs (I don’t need user input, for one, and I need quicker load times), and it seems to be taking a different tack in terms of rendering in a browser-like environment than what’s suitable for my application.

Even if it’s not obvious where to start, I’d appreciate any ideas or advice (even if it’s not TeXmacs-related—maybe there’s a more appropriate solution out there for this specific problem?). I’m not sure if this will go anywhere, and it might be a long shot, but I thought it might be worth trying. :slight_smile:

Vau is the related work:

And we (XmacsLabs) are working on to modularize GNU TeXmacs, so that project like Vau inside Mogan Editor will not be outdated.

1 Like

Vau is the work of “factoring out”. Modularization is the finally solution. Factoring out means we need to factor out it again and again.

Welcome to become one of the Mogan Developers. Recently, I’m trying to get new Developers (Summer of Code students) onboarded. And I learned a lot on how to let other developers get involved in.

@darcy Ah, it’s great to see that this effort is already underway! :slight_smile: Where do I start looking to understand how the code is structured?

What os you are using? You can start from build mogan by yourself and then launch mogan: