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;