NDOJ/resources/katex_config.js

13 lines
568 B
JavaScript
Raw Normal View History

2024-02-05 23:02:49 +00:00
window.renderKatex = (elem=document.body) => {
2024-02-06 00:32:08 +00:00
var maths = document.querySelectorAll('.arithmatex'),
tex;
console.log(maths);
for (var i = 0; i < maths.length; i++) {
tex = maths[i].textContent || maths[i].innerText;
if (tex.startsWith('\\(') && tex.endsWith('\\)')) {
katex.render(tex.slice(2, -2), maths[i], {'displayMode': false, 'throwOnError': false});
} else if (tex.startsWith('\\[') && tex.endsWith('\\]')) {
katex.render(tex.slice(2, -2), maths[i], {'displayMode': true, 'throwOnError': false});
}
}
2024-02-05 23:02:49 +00:00
}