Skip to content

Commit 4f66c6d

Browse files
committed
chore: update package versions and improve code handling for language variants
1 parent 8423a86 commit 4f66c6d

File tree

7 files changed

+422
-27
lines changed

7 files changed

+422
-27
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"katex": ">=0.16.22",
7777
"mermaid": ">=11",
7878
"shiki": "^3.13.0",
79-
"stream-markdown": ">=0.0.5",
79+
"stream-markdown": ">=0.0.6",
8080
"stream-monaco": ">=0.0.2",
8181
"vue": ">=3.0.0",
8282
"vue-i18n": ">=9"
@@ -103,7 +103,7 @@
103103
},
104104
"dependencies": {
105105
"@floating-ui/dom": "^1.7.4",
106-
"stream-markdown-parser": "^0.0.9"
106+
"stream-markdown-parser": "^0.0.10"
107107
},
108108
"devDependencies": {
109109
"@antfu/eslint-config": "^5.4.1",

packages/markdown-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stream-markdown-parser",
33
"type": "module",
4-
"version": "0.0.9",
4+
"version": "0.0.10",
55
"packageManager": "pnpm@10.20.0",
66
"description": "Pure markdown parser and renderer utilities with streaming support - framework agnostic",
77
"author": "Simon He",

packages/markdown-parser/src/plugins/fixLinkTokens.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ function fixLinkTokens2(tokens: MarkdownToken[]): MarkdownToken[] {
8383
return tokens
8484
let length = tokens.length
8585
let last = tokens[length - 1]
86+
if (!last)
87+
return tokens
8688
if (last.type !== 'link_close') {
8789
length--
8890
last = tokens[length - 1]
@@ -130,6 +132,9 @@ function fixLinkToken3(tokens: MarkdownToken[]): MarkdownToken[] {
130132
const last = tokens[tokens.length - 1]
131133
const preLast = tokens[tokens.length - 2]
132134
const fixedTokens = [...tokens]
135+
if (!last)
136+
return tokens
137+
133138
if (last.type !== 'text' || !(last as unknown as { content?: string }).content?.startsWith(')')) {
134139
return tokens
135140
}
@@ -160,11 +165,11 @@ function fixLinkToken4(tokens: MarkdownToken[]): MarkdownToken[] {
160165
const fixedTokens = [...tokens]
161166
for (let i = tokens.length - 1; i >= 3; i--) {
162167
const token = tokens[i]
163-
if (token.type === 'link_close') {
168+
if (token && token.type === 'link_close') {
164169
if (tokens[i - 3]?.content?.endsWith('(')) {
165170
const nextToken = tokens[i + 1]
166-
if (nextToken?.type === 'text') {
167-
if (tokens[i - 1].type === 'text' && tokens[i - 3].type === 'text') {
171+
if (nextToken && nextToken?.type === 'text') {
172+
if (tokens[i - 1].type === 'text' && tokens[i - 3]?.type === 'text') {
168173
const nextTokenContent = String((nextToken as unknown as { content?: string }).content ?? '')
169174
const a = tokensAny[i - 3] as unknown as { content?: string }
170175
const b = tokensAny[i - 1] as unknown as { content?: string }
@@ -178,7 +183,7 @@ function fixLinkToken4(tokens: MarkdownToken[]): MarkdownToken[] {
178183
}
179184
}
180185
else {
181-
if (tokens[i - 1].type === 'text' && tokens[i - 3].type === 'text') {
186+
if (tokens[i - 1].type === 'text' && tokens[i - 3]?.type === 'text') {
182187
const a = tokensAny[i - 3] as unknown as { content?: string }
183188
const b = tokensAny[i - 1] as unknown as { content?: string }
184189
const content = String(a.content ?? '') + String(b.content ?? '')

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@tailwindcss/typography": "^0.5.19",
1616
"@vueuse/core": "^13.9.0",
1717
"katex": "^0.16.25",
18-
"stream-markdown": "^0.0.5",
18+
"stream-markdown": "^0.0.6",
1919
"stream-monaco": "^0.0.2",
2020
"vite": "^7.1.12",
2121
"vue": "^3.5.22",

0 commit comments

Comments
 (0)