-
Notifications
You must be signed in to change notification settings - Fork 963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] about katex #1695
Comments
if there is a cross-platform library sure, see #1073 for a previous try |
yeah, katex-rs crate has supported windows by using wasm js |
Then someone should try to make a PR to integrate it |
In case someone wants to implement this: katex-rs can now also use Duktape for JS execution. It's a single-C-file JS engine which should also build on Windows. So either this or the wasm-based backend should work. |
I would like to give this a shot in the near future. Rendering an equation using katex-rs and pasting it into a page renders correctly in Firefox. So would this task be a preprocessing step each .md files have their latex expressions replaced by MathML by katex-rs? Also MathML is, to my surpirse, not supported by Chrome, i.e. it still needs client side rendering by MathJax or similar. |
I think MathML is coming back to Chrome:
So I think emitting MathML might be the better option compared to emitting hacky HTML+CSS, also in terms of a11y. Note that themes can include a polyfill to render MathML (also partly required for Firefox). |
That's great news! In terms of accessibility, KaTeX actually emits HTML AND MathML by default, see KaTeX Options: With the prospect of MathML support landing in Chrome, I think adding an option to replacing all LaTeX with MathML at server-side would be useful:
There is the ugly detail that MathJax or similar would still be required to achieve support on the current browser landscape. However, I think a page in the docs showing how to embed MathJax in a template would go a long way towards alleviating the confusion on how to render math. I would still like some feedback on the best place to implement this functionality. Are there any caveats to matching on a set of known delimiters like $ and $$ and replacing their contents with MathML using KaTeX-rs? |
This would still be beyond perfect if it was implemented. I'm giving a talk about Zola soon, and this is on top of features that I thought were present already. |
Looks like pulldown-cmark merged support for math expressions, so that be a path forward for zola. |
It looks like this is landing in 0.11: once that's done, merging this would be extremely helpful - right now I am using a workaround which involves writing math inside code blocks (i.e. Ideally, I'd like to render server-side. This can be achieved by either:
It looks like the main bottleneck for (2) above this was some kind of issue with lack of cross-platform JS support at the time, but there appears to be progress here: xu-cheng/katex-rs#6. |
Has anyone tried pulldown-cmark 0.11 with the math support? |
Not yet, but if someone wants to try server-side rendering via a minimal Node script that essentially does a find-replace - not a very smart solution but works great - I have one here: https://github.com/aterenin/academic-paper/blob/4a80380263ff375f7d627f85926c2891489cfa2f/scripts/katex.js. The main thing that would need to change is to replace the regex |
Let me also add one thing: if pulldown-cmark now emits HTML like In particular, it would eliminate the need for weird workarounds like putting math inside code-blocks so that Markdown italics don't interfere with TeX and similar. Without any other changes to Zola (whether direct support for server-side KaTeX, or whatever else) this would already be a big improvement for me. |
Counld you please integrate the KaTeX server side rendering into Zola? That will be a great performance improvement in the browser side
The text was updated successfully, but these errors were encountered: