修复单个波浪号被识别为删除线的问题

This commit is contained in:
2026-09-12 07:42:22 +08:00
parent 2e472c4dd4
commit 4378d3b743
5 changed files with 9 additions and 2 deletions
+3 -1
View File
@@ -2,6 +2,7 @@ import { defineConfig } from 'astro/config';
import { unified } from '@astrojs/markdown-remark'; import { unified } from '@astrojs/markdown-remark';
import sitemap from '@astrojs/sitemap'; import sitemap from '@astrojs/sitemap';
import tailwindcss from '@tailwindcss/vite'; import tailwindcss from '@tailwindcss/vite';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math'; import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex'; import rehypeKatex from 'rehype-katex';
import shortcodes from './src/lib/shortcodes.ts'; import shortcodes from './src/lib/shortcodes.ts';
@@ -47,7 +48,8 @@ export default defineConfig({
defaultColor: false defaultColor: false
}, },
processor: unified({ 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 }]] rehypePlugins: [rehypeKatex, noticeShortcode, responsiveTables, [externalLinks, { siteUrl: siteConfig.site.url }]]
}) })
} }
+1
View File
@@ -22,6 +22,7 @@
"pangu": "^9.1.0", "pangu": "^9.1.0",
"photoswipe": "^5.4.4", "photoswipe": "^5.4.4",
"rehype-katex": "^7.0.1", "rehype-katex": "^7.0.1",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0", "remark-math": "^6.0.0",
"twikoo": "1.7.15", "twikoo": "1.7.15",
"unist-util-visit": "^5.0.0" "unist-util-visit": "^5.0.0"
+1
View File
@@ -27,6 +27,7 @@
"pangu": "^9.1.0", "pangu": "^9.1.0",
"photoswipe": "^5.4.4", "photoswipe": "^5.4.4",
"rehype-katex": "^7.0.1", "rehype-katex": "^7.0.1",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0", "remark-math": "^6.0.0",
"twikoo": "1.7.15", "twikoo": "1.7.15",
"unist-util-visit": "^5.0.0" "unist-util-visit": "^5.0.0"
+3
View File
@@ -56,6 +56,9 @@ importers:
rehype-katex: rehype-katex:
specifier: ^7.0.1 specifier: ^7.0.1
version: 7.0.1 version: 7.0.1
remark-gfm:
specifier: ^4.0.1
version: 4.0.1
remark-math: remark-math:
specifier: ^6.0.0 specifier: ^6.0.0
version: 6.0.0 version: 6.0.0
+1 -1
View File
@@ -71,7 +71,7 @@ function normalizeMarkdownHeadings(source: string): string {
function markdown(source: string, preserveHtml = true, lineNumbers = true): string { function markdown(source: string, preserveHtml = true, lineNumbers = true): string {
const normalized = normalizeMarkdownHeadings(source); 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); transform(tree, normalized);
if (!preserveHtml) visit(tree, 'html', (node: any) => { if (!node.data?.shortcode) node.value = ''; }); if (!preserveHtml) visit(tree, 'html', (node: any) => { if (!node.data?.shortcode) node.value = ''; });
const hast = toHast(tree, { allowDangerousHtml: true }) as any; const hast = toHast(tree, { allowDangerousHtml: true }) as any;