mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
Added KaTeX plugin
This commit is contained in:
1 parent
c8b9917b11
commit
61010a8a85
1 file changed
+9
-11
@@ -19,18 +19,16 @@
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.js" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
const render = function (text, el) {
|
||||
// Do stuff if text starts with `latex`
|
||||
var renderedKatex = katex.renderToString(
|
||||
text.replace('KaTeX:', ''),
|
||||
{ throwOnError: false }
|
||||
);
|
||||
// Populate katex and additional markup for formatting
|
||||
el.outerHTML = `<span class="katex-wrap">${renderedKatex}</span>`;
|
||||
}
|
||||
document.querySelectorAll('code').forEach(function (el) {
|
||||
if (el.textContent.startsWith('KaTeX:') || el.classList.contains("language-KaTeX")) {
|
||||
render(el.textContent, el)
|
||||
const text = el.textContent;
|
||||
if (text.startsWith('KaTeX:') || el.classList.contains("language-KaTeX")) {
|
||||
// Do stuff if text starts with `latex`
|
||||
const renderedKatex = katex.renderToString(
|
||||
text.replace('KaTeX:', ''),
|
||||
{ throwOnError: false }
|
||||
);
|
||||
// Populate katex and additional markup for formatting
|
||||
el.outerHTML = `<span class="katex-wrap">${renderedKatex}</span>`;
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user