Skip to content

Commit c53ef23

Browse files
换行符也被渲染成空格,但没有被高亮
1 parent 7214fe6 commit c53ef23

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/app/features/article/articleViewer/getProcessor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ function hastHighlightSpace() {
5050
)
5151
.flatMap<Exclude<ElementContent, Text> | string>((child, idx, arr) => {
5252
if (typeof child !== 'string') return child;
53-
if (child === ' ') return HighlightElement.Space;
53+
if (
54+
child === ' ' ||
55+
child === '\n' // \n is render as space
56+
)
57+
return HighlightElement.Space;
5458
const prevElement = idx !== 0 ? arr[idx - 1] : undefined;
5559
if (
5660
typeof prevElement === 'string' &&

test/articleViewer/testcase/format.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
中文English 中文 English
2+
中文English 中文 English
3+
中文English 中文 English

0 commit comments

Comments
 (0)