Support for rendering KaTeX formula?
Closed this issue · 2 comments
aseidma commented
I was wondering if there is a way to output formulas as well? The demo shows an option for formulas in the editor, but the output only displays the content of the <span>
-tag.
I've tried applying renderMathInElement
(provided by KaTeX) to the converted HTML, however it still doesn't render the formula.
volser commented
Did you try renderCustomWith
callback and use katex.renderToString
here?
aseidma commented
Hey,
sorry for the late reply, I was dealing with a few other features first, but your answer brought me to my final solution!
I added this to the quill.on('text-change', callback)
callback:
if (document.querySelectorAll('#converted-view span.ql-formula').length > 0) {
document.querySelectorAll('#converted-view span.ql-formula').forEach(formula => {
katex.render(formula.innerText, formula, {
throwOnError: false
});
})
}
Works like a charm and in real-time now, thank you!