Skip to content

Commit 2511a32

Browse files
committed
fix: enhance reference token handling in parseInlineTokens function
1 parent c7bfc8c commit 2511a32

File tree

1 file changed

+4
-1
lines changed
  • packages/markdown-parser/src/parser/inline-parsers

1 file changed

+4
-1
lines changed

packages/markdown-parser/src/parser/inline-parsers/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,12 @@ export function parseInlineTokens(tokens: MarkdownToken[], raw?: string, pPreTok
611611
case 'reference': {
612612
currentTextNode = null // Reset current text node
613613
const nextToken = tokens[i + 1]
614-
if (!nextToken?.content?.startsWith('(')) {
614+
if ((nextToken?.type === 'text' && !nextToken.content?.startsWith('(')) || (tokens[i - 1].type === 'text' && !tokens[i - 1].content?.endsWith('('))) {
615615
result.push(parseReferenceToken(token))
616616
}
617+
else if (nextToken && nextToken.type === 'text') {
618+
nextToken.content = token.markup + nextToken.content
619+
}
617620
i++
618621
break
619622
}

0 commit comments

Comments
 (0)