mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-26 17:04:07 +01:00
Refactor code language and ts types (#9300)
* 🎨 Code block language list adds custom languages * Update index.d.ts * 🎨 Improve global variable type definition * 🎨 Improve global variable type definition * 🎨 Add constant `EXTRA_CODE_LANGUAGES`
This commit is contained in:
parent
17d2a16a94
commit
b2a27bb54c
16 changed files with 86 additions and 72 deletions
|
|
@ -4,16 +4,6 @@ import {Constants} from "../../constants";
|
|||
import {hasNextSibling, hasPreviousSibling} from "../wysiwyg/getBlock";
|
||||
import {hasClosestBlock} from "../util/hasClosest";
|
||||
|
||||
declare const katex: {
|
||||
renderToString(math: string, option: {
|
||||
displayMode: boolean;
|
||||
output: string;
|
||||
macros: IObject;
|
||||
trust: boolean;
|
||||
strict: (errorCode:string) => "ignore" | "warn";
|
||||
}): string;
|
||||
};
|
||||
|
||||
export const mathRender = (element: Element, cdn = Constants.PROTYLE_CDN, maxWidth = false) => {
|
||||
let mathElements: Element[] = [];
|
||||
if (element.getAttribute("data-subtype") === "math") {
|
||||
|
|
@ -44,7 +34,7 @@ export const mathRender = (element: Element, cdn = Constants.PROTYLE_CDN, maxWid
|
|||
console.warn("KaTex macros is not JSON", e);
|
||||
}
|
||||
try {
|
||||
renderElement.innerHTML = katex.renderToString(Lute.UnEscapeHTMLStr(mathElement.getAttribute("data-content")), {
|
||||
renderElement.innerHTML = window.katex.renderToString(Lute.UnEscapeHTMLStr(mathElement.getAttribute("data-content")), {
|
||||
displayMode: mathElement.tagName === "DIV",
|
||||
output: "html",
|
||||
macros,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue