fix: render equations in markdown preview (#5745)

This commit is contained in:
NN708
2026-02-15 20:53:36 +08:00
committed by GitHub
parent 63a76ef18c
commit 0467326d5c
3 changed files with 35 additions and 0 deletions

View File

@@ -94,6 +94,7 @@ import { useFileStore } from "@/stores/file";
import { useLayoutStore } from "@/stores/layout";
import { getEditorTheme } from "@/utils/theme";
import { marked } from "marked";
import markedKatex from "marked-katex-extension";
import { inject, onBeforeUnmount, onMounted, ref, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
import { onBeforeRouteUpdate, useRoute, useRouter } from "vue-router";
@@ -118,6 +119,11 @@ const previewContent = ref("");
const isMarkdownFile =
fileStore.req?.name.endsWith(".md") ||
fileStore.req?.name.endsWith(".markdown");
const katexOptions = {
output: "mathml" as const,
throwOnError: false
};
marked.use(markedKatex(katexOptions));
const isSelectionEmpty = ref(true);