Browse Source

TeX support, summary

imwald
Nuša Pukšič 2 months ago
parent
commit
b8b15b07eb
  1. 17
      assets/app.js

17
assets/app.js

@ -54,9 +54,23 @@ import 'katex/dist/katex.min.css';
import renderMathInElement from 'katex/dist/contrib/auto-render.mjs'; import renderMathInElement from 'katex/dist/contrib/auto-render.mjs';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
// multiple possible containers for math rendering; loop over options
const root = document.querySelector('.article-main'); // the container you render $html into const root = document.querySelector('.article-main'); // the container you render $html into
if (!root) return; const summaries = document.querySelectorAll('.lede'); // article summaries
if (summaries) {
summaries.forEach((summary) => {
renderMathInElement(summary, {
delimiters: [
{ left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false },
],
throwOnError: false, // don’t explode on unknown commands
});
});
}
if (root) {
renderMathInElement(root, { renderMathInElement(root, {
// Delimiters: inline $…$, display $$…$$ and the LaTeX \(…\)/\[…\] forms // Delimiters: inline $…$, display $$…$$ and the LaTeX \(…\)/\[…\] forms
delimiters: [ delimiters: [
@ -67,4 +81,5 @@ document.addEventListener('DOMContentLoaded', () => {
], ],
throwOnError: false, // don’t explode on unknown commands throwOnError: false, // don’t explode on unknown commands
}); });
}
}); });

Loading…
Cancel
Save