svelte-streamdown 2.4.3 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -153,10 +153,14 @@ class IncompleteMarkdownParser {
153
153
  if (line.trim() === '***') {
154
154
  return line;
155
155
  }
156
+ const isEndingWithTripleAsterisk = line.endsWith('***');
156
157
  const tripleAsterisks = (line.match(/\*\*\*/g) || []).length;
157
158
  if (tripleAsterisks % 2 === 1) {
158
159
  const lastTripleAsteriskIndex = line.lastIndexOf('***');
159
160
  const endOfCellOrLine = findEndOfCellOrLineContaining(line, lastTripleAsteriskIndex);
161
+ if (isEndingWithTripleAsterisk) {
162
+ return line.substring(0, lastTripleAsteriskIndex);
163
+ }
160
164
  return line.substring(0, endOfCellOrLine) + '***' + line.substring(endOfCellOrLine);
161
165
  }
162
166
  return line;
@@ -172,8 +176,12 @@ class IncompleteMarkdownParser {
172
176
  }
173
177
  const doubleAsteriskMatches = (line.match(/\*\*/g) || []).length;
174
178
  if (doubleAsteriskMatches % 2 === 1) {
179
+ const isEndingWithDoubleAsterisk = line.endsWith('**');
175
180
  const lastDoubleAsteriskIndex = line.lastIndexOf('**');
176
181
  const endOfCellOrLine = findEndOfCellOrLineContaining(line, lastDoubleAsteriskIndex);
182
+ if (isEndingWithDoubleAsterisk) {
183
+ return line.substring(0, lastDoubleAsteriskIndex);
184
+ }
177
185
  return line.substring(0, endOfCellOrLine) + '**' + line.substring(endOfCellOrLine);
178
186
  }
179
187
  return line;
@@ -189,8 +197,12 @@ class IncompleteMarkdownParser {
189
197
  }
190
198
  const underscorePairs = (line.match(/__/g) || []).length;
191
199
  if (underscorePairs % 2 === 1) {
200
+ const isEndingWithDoubleUnderscore = line.endsWith('__');
192
201
  const lastDoubleUnderscoreIndex = line.lastIndexOf('__');
193
202
  const endOfCellOrLine = findEndOfCellOrLineContaining(line, lastDoubleUnderscoreIndex);
203
+ if (isEndingWithDoubleUnderscore) {
204
+ return line.substring(0, lastDoubleUnderscoreIndex);
205
+ }
194
206
  return line.substring(0, endOfCellOrLine) + '__' + line.substring(endOfCellOrLine);
195
207
  }
196
208
  return line;
@@ -203,11 +215,15 @@ class IncompleteMarkdownParser {
203
215
  handler: ({ line }) => {
204
216
  const tildePairs = (line.match(/~~/g) || []).length;
205
217
  if (tildePairs % 2 === 1) {
218
+ const isEndingWithDoubleTilde = line.endsWith('~~');
206
219
  const lastDoubleTildeIndex = line.lastIndexOf('~~');
207
220
  const endOfCellOrLine = findEndOfCellOrLineContaining(line, lastDoubleTildeIndex);
208
221
  // Only complete if there's content after the tildes
209
222
  const contentAfterTildes = line.substring(lastDoubleTildeIndex + 2, endOfCellOrLine);
210
223
  if (contentAfterTildes.trim().length > 0) {
224
+ if (isEndingWithDoubleTilde) {
225
+ return line.substring(0, lastDoubleTildeIndex);
226
+ }
211
227
  return line.substring(0, endOfCellOrLine) + '~~' + line.substring(endOfCellOrLine);
212
228
  }
213
229
  }
@@ -482,6 +498,9 @@ class IncompleteMarkdownParser {
482
498
  pattern: /\$\$/,
483
499
  skipInBlockTypes: ['code', 'math'],
484
500
  handler: ({ line }) => {
501
+ // Don't process block boundaries (lines that are just $$)
502
+ if (line.trim() === '$$')
503
+ return line;
485
504
  const dollarPairs = (line.match(/\$\$/g) || []).length;
486
505
  if (dollarPairs % 2 === 0)
487
506
  return line;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-streamdown",
3
- "version": "2.4.3",
3
+ "version": "2.4.5",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",