mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-28 20:38:49 +01:00
This commit is contained in:
parent
cd5f93e2d6
commit
8288d484d9
2 changed files with 14 additions and 13 deletions
|
|
@ -234,21 +234,19 @@ export class Preview {
|
|||
}
|
||||
});
|
||||
});
|
||||
if(typeof window.MathJax === "undefined") {
|
||||
window.MathJax = {
|
||||
svg: {
|
||||
fontCache: "none"
|
||||
},
|
||||
};
|
||||
}
|
||||
await addScriptSync(`${Constants.PROTYLE_CDN}/js/mathjax/tex-svg-full.js`, "protyleMathJaxScript");
|
||||
await window.MathJax.startup.promise;
|
||||
copyElement.querySelectorAll('[data-subtype="math"]').forEach(mathElement => {
|
||||
const node = window.MathJax.tex2svg(Lute.UnEscapeHTMLStr(mathElement.getAttribute("data-content")).trim(), {display: mathElement.tagName === "DIV"});
|
||||
node.querySelectorAll("use").forEach(item => {
|
||||
const useTarget = node.querySelector(item.getAttribute("xlink:href"));
|
||||
if (useTarget) {
|
||||
useTarget.setAttribute("transform", item.getAttribute("transform") || "");
|
||||
item.outerHTML = useTarget.outerHTML;
|
||||
}
|
||||
});
|
||||
node.querySelector("mjx-assistive-mml")?.remove();
|
||||
node.querySelector("defs")?.remove();
|
||||
mathElement.innerHTML = "";
|
||||
mathElement.append(node);
|
||||
node.querySelector("mjx-assistive-mml").remove();
|
||||
mathElement.innerHTML= node.outerHTML;
|
||||
});
|
||||
} else if (type === "zhihu") {
|
||||
this.link2online(copyElement);
|
||||
|
|
|
|||
7
app/src/types/index.d.ts
vendored
7
app/src/types/index.d.ts
vendored
|
|
@ -152,10 +152,13 @@ interface Window {
|
|||
}): void;
|
||||
};
|
||||
MathJax: {
|
||||
tex2svg(math: string, options: {display: boolean}): HTMLElement
|
||||
startup: {
|
||||
svg: {
|
||||
fontCache: string
|
||||
}
|
||||
startup?: {
|
||||
promise: Promise<void>
|
||||
}
|
||||
tex2svg?(math: string, options: { display: boolean }): HTMLElement
|
||||
};
|
||||
hljs: {
|
||||
listLanguages(): string[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue