@readme/markdown 13.8.2 → 13.8.3

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.
package/dist/main.js CHANGED
@@ -12186,18 +12186,33 @@ function useScrollHighlight(navRef) {
12186
12186
  // Click a ToC link → immediately activate it, suppress the observer
12187
12187
  // until the smooth scroll finishes, then hand control back.
12188
12188
  const onClick = (e) => {
12189
- const anchor = e.target.closest?.('a[href^="#"]');
12190
- if (!anchor)
12189
+ if (!(e.target instanceof Element))
12191
12190
  return;
12192
- const id = decodeURIComponent(anchor.getAttribute('href').slice(1));
12191
+ const anchor = e.target.closest('a[href^="#"]');
12192
+ if (!(anchor instanceof HTMLAnchorElement))
12193
+ return;
12194
+ const id = decodeURIComponent(anchor.hash.slice(1));
12193
12195
  if (!linkMap.has(id))
12194
12196
  return;
12195
- e.preventDefault();
12197
+ if (window.location.hash !== anchor.hash) {
12198
+ window.location.hash = anchor.hash;
12199
+ }
12196
12200
  activate(id);
12197
12201
  clickLocked = true;
12198
- const unlock = () => { clickLocked = false; };
12202
+ let unlockTimer = null;
12203
+ const unlock = () => {
12204
+ clickLocked = false;
12205
+ scrollTarget.removeEventListener('scrollend', unlock);
12206
+ window.removeEventListener('hashchange', unlock);
12207
+ if (unlockTimer !== null) {
12208
+ window.clearTimeout(unlockTimer);
12209
+ unlockTimer = null;
12210
+ }
12211
+ };
12199
12212
  scrollTarget.addEventListener('scrollend', unlock, { once: true });
12200
- document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' });
12213
+ window.addEventListener('hashchange', unlock, { once: true });
12214
+ // Fallback in case scrollend and hashchange don't fire
12215
+ unlockTimer = window.setTimeout(unlock, 500);
12201
12216
  };
12202
12217
  headings.forEach(el => { observer.observe(el); });
12203
12218
  scrollTarget.addEventListener('scroll', onScroll, { passive: true });
@@ -96456,10 +96471,10 @@ const parseTableCell = (text) => {
96456
96471
  node.value = escapeInvalidTags(node.value);
96457
96472
  }
96458
96473
  });
96459
- if (tree.children.length > 1) {
96460
- return tree.children;
96461
- }
96462
- return tree.children.flatMap(n => n.type === 'paragraph' && 'children' in n ? n.children : [n]);
96474
+ const result = tree.children.length > 1
96475
+ ? tree.children
96476
+ : tree.children.flatMap(n => n.type === 'paragraph' && 'children' in n ? n.children : [n]);
96477
+ return result;
96463
96478
  };
96464
96479
  const parseBlock = (text) => {
96465
96480
  if (!text.trim())
@@ -96671,7 +96686,9 @@ function transformMagicBlock(blockType, data, rawValue, options = {}) {
96671
96686
  mapped[rowIndex][colIndex] = v;
96672
96687
  return mapped;
96673
96688
  }, []);
96674
- const tokenizeCell = compatibilityMode ? textToBlock : parseTableCell;
96689
+ const tokenizeCell = compatibilityMode
96690
+ ? textToBlock
96691
+ : parseTableCell;
96675
96692
  const tableChildren = Array.from({ length: rows + 1 }, (_, y) => ({
96676
96693
  children: Array.from({ length: cols }, (__, x) => ({
96677
96694
  children: sparseData[y]?.[x] ? tokenizeCell(preprocessBody(sparseData[y][x])) : [{ type: 'text', value: '' }],
@@ -98364,6 +98381,7 @@ function restoreSnakeCase(placeholderName, mapping) {
98364
98381
  ;// ./processor/transform/mdxish/mdxish-tables-to-jsx.ts
98365
98382
 
98366
98383
 
98384
+
98367
98385
  const SELF_CLOSING_JSX_REGEX = /^\s*<[A-Z][^>]*\/>\s*$/;
98368
98386
  const mdxish_tables_to_jsx_alignToStyle = (align) => {
98369
98387
  if (!align || align === 'left')
@@ -98393,22 +98411,27 @@ const mdxishTablesToJsx = () => tree => {
98393
98411
  visit(table, mdxish_tables_to_jsx_isTableCell, (cell) => {
98394
98412
  if (hasFlowContent || cell.children.length === 0)
98395
98413
  return;
98396
- const content = cell.children.length === 1 && cell.children[0].type === 'paragraph'
98397
- ? cell.children[0].children[0]
98398
- : cell.children[0];
98399
- if (!content)
98400
- return;
98401
98414
  visit(cell, 'break', (_, breakIndex, breakParent) => {
98402
98415
  breakParent.children.splice(breakIndex, 1, { type: 'text', value: '\n' });
98403
98416
  });
98404
- if (!(phrasing(content) || content.type === 'plain') && content.type !== 'escape') {
98405
- // Plain HTML (e.g. <div>Hello</div>) is skipped here — it stays in GFM cells fine.
98406
- // But self-closing JSX components (e.g. <Image src="..." caption="..." />) serialize
98407
- // with newlines that break GFM cells, so they must trigger JSX <Table> serialization.
98408
- const isPlainHtml = content.type === 'html' && !SELF_CLOSING_JSX_REGEX.test(content.value);
98409
- if (!isPlainHtml) {
98410
- hasFlowContent = true;
98417
+ // Check if any child is "flow" content (block-level) that requires JSX <Table>
98418
+ // serialization instead of GFM. `phrasing()` from mdast-util-phrasing returns
98419
+ // true for inline node types (text, emphasis, strong, link, etc.) which are
98420
+ // safe to keep in GFM cells.
98421
+ const hasFlowChild = cell.children.some(child => {
98422
+ if (child.type === 'paragraph' || child.type === 'plain' || child.type === 'escape')
98423
+ return false;
98424
+ if (child.type === NodeTypes.variable)
98425
+ return false;
98426
+ if (phrasing(child))
98427
+ return false;
98428
+ if (child.type === 'html') {
98429
+ return SELF_CLOSING_JSX_REGEX.test(child.value);
98411
98430
  }
98431
+ return true;
98432
+ });
98433
+ if (hasFlowChild) {
98434
+ hasFlowContent = true;
98412
98435
  }
98413
98436
  if (!hasFlowContent) {
98414
98437
  visit(cell, mdxish_tables_to_jsx_isLiteral, (node) => {
package/dist/main.node.js CHANGED
@@ -24782,18 +24782,33 @@ function useScrollHighlight(navRef) {
24782
24782
  // Click a ToC link → immediately activate it, suppress the observer
24783
24783
  // until the smooth scroll finishes, then hand control back.
24784
24784
  const onClick = (e) => {
24785
- const anchor = e.target.closest?.('a[href^="#"]');
24786
- if (!anchor)
24785
+ if (!(e.target instanceof Element))
24787
24786
  return;
24788
- const id = decodeURIComponent(anchor.getAttribute('href').slice(1));
24787
+ const anchor = e.target.closest('a[href^="#"]');
24788
+ if (!(anchor instanceof HTMLAnchorElement))
24789
+ return;
24790
+ const id = decodeURIComponent(anchor.hash.slice(1));
24789
24791
  if (!linkMap.has(id))
24790
24792
  return;
24791
- e.preventDefault();
24793
+ if (window.location.hash !== anchor.hash) {
24794
+ window.location.hash = anchor.hash;
24795
+ }
24792
24796
  activate(id);
24793
24797
  clickLocked = true;
24794
- const unlock = () => { clickLocked = false; };
24798
+ let unlockTimer = null;
24799
+ const unlock = () => {
24800
+ clickLocked = false;
24801
+ scrollTarget.removeEventListener('scrollend', unlock);
24802
+ window.removeEventListener('hashchange', unlock);
24803
+ if (unlockTimer !== null) {
24804
+ window.clearTimeout(unlockTimer);
24805
+ unlockTimer = null;
24806
+ }
24807
+ };
24795
24808
  scrollTarget.addEventListener('scrollend', unlock, { once: true });
24796
- document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' });
24809
+ window.addEventListener('hashchange', unlock, { once: true });
24810
+ // Fallback in case scrollend and hashchange don't fire
24811
+ unlockTimer = window.setTimeout(unlock, 500);
24797
24812
  };
24798
24813
  headings.forEach(el => { observer.observe(el); });
24799
24814
  scrollTarget.addEventListener('scroll', onScroll, { passive: true });
@@ -116650,10 +116665,10 @@ const parseTableCell = (text) => {
116650
116665
  node.value = escapeInvalidTags(node.value);
116651
116666
  }
116652
116667
  });
116653
- if (tree.children.length > 1) {
116654
- return tree.children;
116655
- }
116656
- return tree.children.flatMap(n => n.type === 'paragraph' && 'children' in n ? n.children : [n]);
116668
+ const result = tree.children.length > 1
116669
+ ? tree.children
116670
+ : tree.children.flatMap(n => n.type === 'paragraph' && 'children' in n ? n.children : [n]);
116671
+ return result;
116657
116672
  };
116658
116673
  const parseBlock = (text) => {
116659
116674
  if (!text.trim())
@@ -116865,7 +116880,9 @@ function transformMagicBlock(blockType, data, rawValue, options = {}) {
116865
116880
  mapped[rowIndex][colIndex] = v;
116866
116881
  return mapped;
116867
116882
  }, []);
116868
- const tokenizeCell = compatibilityMode ? textToBlock : parseTableCell;
116883
+ const tokenizeCell = compatibilityMode
116884
+ ? textToBlock
116885
+ : parseTableCell;
116869
116886
  const tableChildren = Array.from({ length: rows + 1 }, (_, y) => ({
116870
116887
  children: Array.from({ length: cols }, (__, x) => ({
116871
116888
  children: sparseData[y]?.[x] ? tokenizeCell(preprocessBody(sparseData[y][x])) : [{ type: 'text', value: '' }],
@@ -118558,6 +118575,7 @@ function restoreSnakeCase(placeholderName, mapping) {
118558
118575
  ;// ./processor/transform/mdxish/mdxish-tables-to-jsx.ts
118559
118576
 
118560
118577
 
118578
+
118561
118579
  const SELF_CLOSING_JSX_REGEX = /^\s*<[A-Z][^>]*\/>\s*$/;
118562
118580
  const mdxish_tables_to_jsx_alignToStyle = (align) => {
118563
118581
  if (!align || align === 'left')
@@ -118587,22 +118605,27 @@ const mdxishTablesToJsx = () => tree => {
118587
118605
  visit(table, mdxish_tables_to_jsx_isTableCell, (cell) => {
118588
118606
  if (hasFlowContent || cell.children.length === 0)
118589
118607
  return;
118590
- const content = cell.children.length === 1 && cell.children[0].type === 'paragraph'
118591
- ? cell.children[0].children[0]
118592
- : cell.children[0];
118593
- if (!content)
118594
- return;
118595
118608
  visit(cell, 'break', (_, breakIndex, breakParent) => {
118596
118609
  breakParent.children.splice(breakIndex, 1, { type: 'text', value: '\n' });
118597
118610
  });
118598
- if (!(phrasing(content) || content.type === 'plain') && content.type !== 'escape') {
118599
- // Plain HTML (e.g. <div>Hello</div>) is skipped here — it stays in GFM cells fine.
118600
- // But self-closing JSX components (e.g. <Image src="..." caption="..." />) serialize
118601
- // with newlines that break GFM cells, so they must trigger JSX <Table> serialization.
118602
- const isPlainHtml = content.type === 'html' && !SELF_CLOSING_JSX_REGEX.test(content.value);
118603
- if (!isPlainHtml) {
118604
- hasFlowContent = true;
118611
+ // Check if any child is "flow" content (block-level) that requires JSX <Table>
118612
+ // serialization instead of GFM. `phrasing()` from mdast-util-phrasing returns
118613
+ // true for inline node types (text, emphasis, strong, link, etc.) which are
118614
+ // safe to keep in GFM cells.
118615
+ const hasFlowChild = cell.children.some(child => {
118616
+ if (child.type === 'paragraph' || child.type === 'plain' || child.type === 'escape')
118617
+ return false;
118618
+ if (child.type === NodeTypes.variable)
118619
+ return false;
118620
+ if (phrasing(child))
118621
+ return false;
118622
+ if (child.type === 'html') {
118623
+ return SELF_CLOSING_JSX_REGEX.test(child.value);
118605
118624
  }
118625
+ return true;
118626
+ });
118627
+ if (hasFlowChild) {
118628
+ hasFlowContent = true;
118606
118629
  }
118607
118630
  if (!hasFlowContent) {
118608
118631
  visit(cell, mdxish_tables_to_jsx_isLiteral, (node) => {