From 159a6a9ccd24ca5d0dfb78f95ae0e023ade948a7 Mon Sep 17 00:00:00 2001 From: sxjeru Date: Mon, 14 Oct 2024 12:47:15 +0800 Subject: [PATCH 1/5] Update utils.ts --- src/Markdown/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Markdown/utils.ts b/src/Markdown/utils.ts index efa64fba..8ab862fa 100644 --- a/src/Markdown/utils.ts +++ b/src/Markdown/utils.ts @@ -49,9 +49,9 @@ export function fixMarkdownBold(text: string): string { } if (count === 2 && count2 % 2 === 0) { const prevChar = i > 0 ? text[i - 2] : ''; - const isPrevCharAlphanumeric = /[a-zA-Z0-9]/.test(prevChar); + const isPrevCharSymbol = /[\p{P}\p{S}]/u.test(prevChar); - if (i + 1 < text.length && text[i + 1] !== ' ' && !isPrevCharAlphanumeric) { + if (i + 1 < text.length && text[i + 1] !== ' ' && isPrevCharSymbol) { result += '* '; } else { result += '*'; From c23d6da3fceafa4e2e672f1c1f20aa2839efa626 Mon Sep 17 00:00:00 2001 From: sxjeru Date: Mon, 14 Oct 2024 12:58:46 +0800 Subject: [PATCH 2/5] Update utils.test.ts --- src/Markdown/utils.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Markdown/utils.test.ts b/src/Markdown/utils.test.ts index 786b2285..88eeec0d 100644 --- a/src/Markdown/utils.test.ts +++ b/src/Markdown/utils.test.ts @@ -62,4 +62,11 @@ describe('fixMarkdownBold', () => { `; expect(fixMarkdownBold(text)).toBe(expected); }); + + it('should not have a space after a bold character other than symbols', () => { + expect(fixMarkdownBold('你**我**他')).toBe('你**我**他'); + expect(fixMarkdownBold('你**我:**他')).toBe('你**我:** 他'); + expect(fixMarkdownBold('你**我:**他')).toBe('你**我:** 他'); + // expect(fixMarkdownBold('你**我: **他')).toBe('你**我:** 他'); // TODO: 先去掉加粗部分末尾空格,再在**后添加空格 + }); }); From 215ff36747a142bda4793e6a6491dc4bbd1986db Mon Sep 17 00:00:00 2001 From: sxjeru Date: Mon, 14 Oct 2024 14:35:01 +0800 Subject: [PATCH 3/5] Update tsconfig.json --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 4d734bf3..77bc4f50 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,6 +19,7 @@ "resolveJsonModule": true, "skipLibCheck": true, "strict": true, + "target": "es6", "types": ["vitest/globals"] }, "exclude": ["mdx.d.ts", "brand.d.ts"], From e462940cf245af3f0cdef57f3b704b1cf5d583ee Mon Sep 17 00:00:00 2001 From: sxjeru Date: Mon, 14 Oct 2024 14:55:09 +0800 Subject: [PATCH 4/5] Update tsconfig.json --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 77bc4f50..4c8580b8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "esModuleInterop": true, "jsx": "react-jsx", "lib": ["dom", "dom.iterable", "esnext"], + "moduleResolution": "node", "paths": { "@@/*": [".dumi/tmp/*"], "@/*": ["src/*"], From c2887ba2a2a102015fc56feb96a21b92baaff4c7 Mon Sep 17 00:00:00 2001 From: sxjeru Date: Mon, 14 Oct 2024 15:00:17 +0800 Subject: [PATCH 5/5] Update tsconfig.json --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 4c8580b8..25fbee3c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "esModuleInterop": true, "jsx": "react-jsx", "lib": ["dom", "dom.iterable", "esnext"], + "module": "esnext", "moduleResolution": "node", "paths": { "@@/*": [".dumi/tmp/*"],