From 4378d3b74328929890007ded5f6e0c24197e7af9 Mon Sep 17 00:00:00 2001 From: RiseForever Date: Sat, 12 Sep 2026 07:42:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E4=B8=AA=E6=B3=A2?= =?UTF-8?q?=E6=B5=AA=E5=8F=B7=E8=A2=AB=E8=AF=86=E5=88=AB=E4=B8=BA=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=BA=BF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astro.config.mjs | 4 +++- package-lock.json | 1 + package.json | 1 + pnpm-lock.yaml | 3 +++ src/lib/shortcodes.ts | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 9bb0b54..b964352 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -2,6 +2,7 @@ import { defineConfig } from 'astro/config'; import { unified } from '@astrojs/markdown-remark'; import sitemap from '@astrojs/sitemap'; import tailwindcss from '@tailwindcss/vite'; +import remarkGfm from 'remark-gfm'; import remarkMath from 'remark-math'; import rehypeKatex from 'rehype-katex'; import shortcodes from './src/lib/shortcodes.ts'; @@ -47,7 +48,8 @@ export default defineConfig({ defaultColor: false }, processor: unified({ - remarkPlugins: [remarkMath, [shortcodes, { githubData, siteUrl: siteConfig.site.url }]], + gfm: false, + remarkPlugins: [[remarkGfm, { singleTilde: false }], remarkMath, [shortcodes, { githubData, siteUrl: siteConfig.site.url }]], rehypePlugins: [rehypeKatex, noticeShortcode, responsiveTables, [externalLinks, { siteUrl: siteConfig.site.url }]] }) } diff --git a/package-lock.json b/package-lock.json index e823e4d..fb81824 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "pangu": "^9.1.0", "photoswipe": "^5.4.4", "rehype-katex": "^7.0.1", + "remark-gfm": "^4.0.1", "remark-math": "^6.0.0", "twikoo": "1.7.15", "unist-util-visit": "^5.0.0" diff --git a/package.json b/package.json index 8935881..673dc13 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "pangu": "^9.1.0", "photoswipe": "^5.4.4", "rehype-katex": "^7.0.1", + "remark-gfm": "^4.0.1", "remark-math": "^6.0.0", "twikoo": "1.7.15", "unist-util-visit": "^5.0.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 447c783..81c5ef2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,6 +56,9 @@ importers: rehype-katex: specifier: ^7.0.1 version: 7.0.1 + remark-gfm: + specifier: ^4.0.1 + version: 4.0.1 remark-math: specifier: ^6.0.0 version: 6.0.0 diff --git a/src/lib/shortcodes.ts b/src/lib/shortcodes.ts index dcf60c1..120341a 100644 --- a/src/lib/shortcodes.ts +++ b/src/lib/shortcodes.ts @@ -71,7 +71,7 @@ function normalizeMarkdownHeadings(source: string): string { function markdown(source: string, preserveHtml = true, lineNumbers = true): string { const normalized = normalizeMarkdownHeadings(source); - const tree = fromMarkdown(normalized, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] }); + const tree = fromMarkdown(normalized, { extensions: [gfm({ singleTilde: false })], mdastExtensions: [gfmFromMarkdown()] }); transform(tree, normalized); if (!preserveHtml) visit(tree, 'html', (node: any) => { if (!node.data?.shortcode) node.value = ''; }); const hast = toHast(tree, { allowDangerousHtml: true }) as any;