Fix some cases where Mathjax whitespace formatting is destroyed

This commit is contained in:
Henrik Giesel 2021-08-06 18:39:08 +02:00
parent 0a003c7856
commit 35098d0f40
2 changed files with 6 additions and 1 deletions

View file

@ -19,6 +19,10 @@ anki-editable {
}
}
anki-mathjax {
white-space: pre;
}
p {
margin-top: 0;
margin-bottom: 1rem;

View file

@ -39,9 +39,10 @@ const codeMirrorOptions = {
};
const parser = new DOMParser();
const parseStyle = "<style>anki-mathjax { white-space: pre; }</style>";
function parseHTML(html: string): string {
const doc = parser.parseFromString(html, "text/html");
const doc = parser.parseFromString(`${parseStyle}${html}`, "text/html");
return doc.body.innerHTML;
}