Skip to content
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

Reconsinder using KaTeX autorenderer #4946

Closed
W4RH4WK opened this issue Oct 4, 2018 · 1 comment
Closed

Reconsinder using KaTeX autorenderer #4946

W4RH4WK opened this issue Oct 4, 2018 · 1 comment

Comments

@W4RH4WK
Copy link

W4RH4WK commented Oct 4, 2018

23eaf2a introduced the use of KaTeX autorenderer and started surrounding math with \( \) and \[ \]. It seems like these markers are needed for the autorenderer, however the KaTeX parser fails when manually invoked on such a marked math element.

My suggestions is that, rather than surrounding math elements and using the autorenderer: do not surround them since there is already a span tag around the elements and invoke the KaTeX render function on them directly.

For clarification, here the span tags:

$ echo '$x^2 + y^2 = z^2$' | pandoc -t html5 --katex
<p><span class="math inline">\(x^2 + y^2 = z^2\)</span></p>

And this is how I invoke KaTeX (at the bottom of my HTML document):

<!-- KaTeX -->
<script src="$TP_DIR$/katex/katex.min.js"></script>
<script>
    var mathElements = document.getElementsByClassName("math");
    for (var i = 0; i < mathElements.length; i++) {
        var texText = mathElements[i].firstChild;
        katex.render(texText.data, mathElements[i]);
    }
</script>

This invocation might not be bullet proof, yet I think it is better than relying on the autorenderer. Typically Pandoc already knows which elements should be rendered using KaTeX, and which should not.

@jgm
Copy link
Owner

jgm commented Oct 4, 2018

I don't know much about KaTeX, but I agree with the idea here. We've already identified the math, so why let an error-prone script do the parsing?

@jgm jgm closed this as completed in f766348 Oct 4, 2018
poor-a added a commit to poor-a/bead that referenced this issue Feb 8, 2019
Also, enable copy-text extension to katex, which
allows one to copy latex source of rendered formula.

Pandoc 2.5 includes a fix for rendering math formulas
using katex. See:

  jgm/pandoc#4946

Remove some unused dependencies picked up by weeder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants