Anki/ts/editable/mathjax.ts
2021-09-15 13:32:32 +02:00

14 lines
514 B
TypeScript

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export function convertMathjax(input: string): string {
const svg = globalThis.MathJax.tex2svg(input).children[0];
const style = document.createElement("style") as HTMLStyleElement;
const styles = `svg { color: white; font-size: 24px; }`;
style.appendChild(document.createTextNode(styles));
svg.insertBefore(style, svg.children[0]);
return svg.outerHTML;
}