Browse Source

TeX support, summary

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

37
assets/app.js

@ -54,17 +54,32 @@ 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
renderMathInElement(root, { if (summaries) {
// Delimiters: inline $…$, display $$…$$ and the LaTeX \(…\)/\[…\] forms summaries.forEach((summary) => {
delimiters: [ renderMathInElement(summary, {
{ left: '$$', right: '$$', display: true }, delimiters: [
{ left: '$', right: '$', display: false }, { left: '$$', right: '$$', display: true },
{ left: '\\(', right: '\\)', display: false }, { left: '$', right: '$', display: false },
{ left: '\\[', right: '\\]', display: true }, ],
], throwOnError: false, // don’t explode on unknown commands
throwOnError: false, // don’t explode on unknown commands });
}); });
}
if (root) {
renderMathInElement(root, {
// Delimiters: inline $…$, display $$…$$ and the LaTeX \(…\)/\[…\] forms
delimiters: [
{ left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
{ left: '\\[', right: '\\]', display: true },
],
throwOnError: false, // don’t explode on unknown commands
});
}
}); });

Loading…
Cancel
Save