rapier-markdown-kit 1.2.27 → 1.2.28

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.
@@ -505,13 +505,20 @@ export function retireDeletedImageDefinitions(before, after, splices, factory) {
505
505
  let remaining = '', at = 0;
506
506
  for (const row of current.blocks) { remaining += after.slice(at, row.start); at = row.end; }
507
507
  remaining = normalizeLabel(remaining + after.slice(at)).replace(/\[\s+/g, '[');
508
- return current.blocks.filter(row => {
508
+ const retired = current.blocks.filter(row => {
509
509
  const old = prior.assets.get(row.id);
510
510
  return deleted.has(row.id) && row.active && row.topLevel && old?.topLevel &&
511
511
  row.status === 'unverified' && old.source === row.source && !now.urls.has(row.url) &&
512
512
  !prior.duplicateLabels.has(row.id) && !current.duplicateLabels.has(row.id) &&
513
513
  !remaining.includes('[' + row.id) && !now.html.includes(row.id) && !now.html.includes(row.url.toUpperCase());
514
- }).sort((a, b) => b.start - a.start).map(row => ({pos: row.start, removed: row.source, inserted: ''}));
514
+ });
515
+ return retired.sort((a, b) => b.start - a.start).map(row => {
516
+ const gap = /(?:\r\n\r\n|\n\n|\r\r)$/.exec(after.slice(Math.max(0, row.start - 4), row.start));
517
+ let tail = after.slice(row.end);
518
+ for (const other of retired) if (other.start >= row.end) tail = tail.replace(other.source, '');
519
+ const whole = gap && !/\S/.test(tail) && row.start - gap[0].length > markdownBodyOffset(after);
520
+ return whole ? {pos: row.start - gap[0].length, removed: gap[0] + row.source, inserted: ''} : {pos: row.start, removed: row.source, inserted: ''};
521
+ });
515
522
  } catch (_) { return []; }
516
523
  }
517
524
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapier-markdown-kit",
3
- "version": "1.2.27",
3
+ "version": "1.2.28",
4
4
  "description": "Read, render and write Self-contained Markdown: one .md file that carries its pictures, drawings and layout, and that any Markdown app can read. HTML renderer, stylesheet, text layout, Will/1 agent permissions, and an edit history with authorship and offline merge. MIT, no dependencies.",
5
5
  "keywords": [
6
6
  "markdown",