autorender a list of elements by a custom CSS selector / custom HTML tag type #3946
Unanswered
vadimkantorov
asked this question in
General
Replies: 1 comment 1 reply
-
Yes, your hack sounds like what you want. Some similar code is in https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type, which is quite short, so could be the basis for what you want. I could see adding an API for this, though I'm not sure exactly where... Perhaps this contrib module or a new one. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
Is it possible to pass a custom CSS selector / array of HTML elements produced by
document.querySelectorAll('code.my-math-block')
ordocument.querySelectorAll('code.my-math-inline')
torenderMathInElement(...)
?Currently even
<code class="my-math-block">$$2+\frac{1}{x}$$</code>
does not get rendered (only works if I change the tag name fromcode
tospan
)Or is there an alternative API to achieve this nicely? (i.e. I have
code
tags with some classes for inline-style and block-style math expressions)Should I use some hacks like:
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.js" integrity="sha384-hIoBPJpTUs74ddyc4bFZSM1TVlQDA60VBbJS0oA934VSz82sBx1X7kSx2ATBDIyd" crossorigin="anonymous" onload="document.querySelectorAll('code.my-math-block').forEach(elem=>katex.render(elem.innerText,elem,{displayMode:true,throwOnError:false}));"></script>
to render<code class="my-math-block">2+\frac{1}{x}</code>
somewhere in my HTML?Beta Was this translation helpful? Give feedback.
All reactions