Skip to content

Commit

Permalink
优化Markdown解析器,增加对可选链的支持以防止空值错误
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Oct 29, 2024
1 parent 4cc0cd4 commit 5757ab9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/MarkdownEditor/editor/parser/parserMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const parseTableOrChart = (
?.replace(/\n/g, '')
.trim(),
)
.map((title) => title.replaceAll('\\', '') || ' ')
.map((title) => title?.replaceAll('\\', '') || ' ')
.map((title, index) => {
if (keyMap.has(title)) {
keyMap.set(title, keyMap.get(title) + '_' + index);
Expand Down Expand Up @@ -685,7 +685,7 @@ const parserBlock = (
if (currentNode.type === 'delete') leaf.strikethrough = true;
if (currentNode.type === 'link') {
leaf.url = decodeURIComponent(
currentNode.url.replaceAll(/%([^\d].)/, '%25$1'),
currentNode?.url?.replaceAll(/%([^\d].)/, '%25$1'),
);
}
el = parseText(
Expand Down

1 comment on commit 5757ab9

@vercel
Copy link

@vercel vercel bot commented on 5757ab9 Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.