katex math rendering; fix broken 2477 delimiter, compatibility with external markdown #2559

This commit is contained in:
hakimel
2021-11-10 10:20:20 +01:00
parent 1ce77db3d0
commit 35b67a9f5b
5 changed files with 32 additions and 7 deletions

View File

@ -11,8 +11,8 @@ export const KaTeX = () => {
let defaultOptions = {
version: 'latest',
delimiters: [
{left: '$$', right: '$$', display: true}, // Note: $$ has to come before $
{left: '$', right: '$', display: false},
{left: '$$', right: '$$', display: true},
{left: '\\(', right: '\\)', display: false},
{left: '\\[', right: '\\]', display: true}
],
@ -73,12 +73,21 @@ export const KaTeX = () => {
}
katexScripts.push(karUrl);
const renderMath = () => {
renderMathInElement(reveal.getSlidesElement(), katexOptions);
deck.layout();
}
loadCss(cssUrl);
// For some reason dynamically loading with defer attribute doesn't result in the expected behavior, the below code does
loadScripts(katexScripts).then(() => {
renderMathInElement(document.body, katexOptions);
deck.layout();
if( deck.isReady() ) {
renderMath();
}
else {
deck.on( 'ready', renderMath.bind( this ) );
}
});
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long