1
0
mirror of synced 2026-08-05 21:06:55 +00:00

FEATURE: Responsive equations (#16)

* adds class to math containers for styling
* adds responsive styles
This commit is contained in:
Joe
2019-09-09 13:08:01 +08:00
committed by Sam
parent 59123ce98b
commit 9615034d78
4 changed files with 64 additions and 3 deletions
@@ -22,7 +22,7 @@ function decorate(elem) {
if ($elem.hasClass("math")) {
const text = $elem.text();
$elem.text("");
$elem.addClass("math-container").text("");
window.katex.render(text, elem, { displayMode });
}
}
@@ -49,14 +49,14 @@ function decorate(elem, isPreview) {
const tag = elem.tagName === "DIV" ? "div" : "span";
const display = tag === "div" ? "; mode=display" : "";
$mathWrapper = $(
`<${tag} style="display: none;"><script type="math/tex${display}"></script></${tag}>`
`<${tag} class="math-container" style="display: none;"><script type="math/tex${display}"></script></${tag}>`
);
$math = $mathWrapper.children();
$math.text($elem.text());
$elem.after($mathWrapper);
} else if ($elem.hasClass("asciimath")) {
$mathWrapper = $(
`<span style="display: none;"><script type="math/asciimath"></script></span>`
`<span class="math-container" style="display: none;"><script type="math/asciimath"></script></span>`
);
$math = $mathWrapper.children();
$math.text($elem.text());