@readme/markdown 14.7.0 → 14.7.1
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 +26 -6
- package/dist/main.node.js +26 -6
- package/dist/main.node.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -76355,13 +76355,32 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
76355
76355
|
// remarkMdx wraps inline `<tr>`s in a paragraph; unwrap one level so the
|
|
76356
76356
|
// hasRow check below sees them.
|
|
76357
76357
|
const flattenSectionChildren = (nodes) => nodes.flatMap(n => n.type === 'paragraph' && 'children' in n && Array.isArray(n.children) ? n.children : [n]);
|
|
76358
|
-
|
|
76359
|
-
|
|
76358
|
+
// Iterate the table's direct children in document order. Rows may live
|
|
76359
|
+
// inside a `<thead>`/`<tbody>` section, or sit bare directly under the table
|
|
76360
|
+
// with no section wrapper — both are collected here so the first row becomes
|
|
76361
|
+
// the markdown table header.
|
|
76362
|
+
const tableChildren = flattenSectionChildren(node.children);
|
|
76363
|
+
tableChildren.forEach(child => {
|
|
76364
|
+
if (!isMDXElement(child))
|
|
76365
|
+
return;
|
|
76366
|
+
const childElement = child;
|
|
76367
|
+
// Path for a `<tr>` directly under the table, without a `<thead>`/`<tbody>` wrapper.
|
|
76368
|
+
if (childElement.name === 'tr') {
|
|
76369
|
+
children.push({
|
|
76370
|
+
type: 'tableRow',
|
|
76371
|
+
children: collectCells(childElement),
|
|
76372
|
+
position: childElement.position,
|
|
76373
|
+
});
|
|
76374
|
+
return;
|
|
76375
|
+
}
|
|
76376
|
+
// Path for when the rows are wrapped in a `<thead>`/`<tbody>`
|
|
76377
|
+
// We visit & collect the entire rows under them directly here
|
|
76378
|
+
if (childElement.name !== 'thead' && childElement.name !== 'tbody')
|
|
76360
76379
|
return;
|
|
76361
|
-
const sectionChildren = flattenSectionChildren(
|
|
76380
|
+
const sectionChildren = flattenSectionChildren(childElement.children);
|
|
76362
76381
|
const hasRow = sectionChildren.some(c => isMDXElement(c) && c.name === 'tr');
|
|
76363
76382
|
if (hasRow) {
|
|
76364
|
-
visit(
|
|
76383
|
+
visit(childElement, isMDXElement, (row) => {
|
|
76365
76384
|
if (row.name !== 'tr')
|
|
76366
76385
|
return;
|
|
76367
76386
|
children.push({
|
|
@@ -76375,7 +76394,7 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
76375
76394
|
// No `<tr>`, chunk bare cells into rows using the prior row's column
|
|
76376
76395
|
// count (e.g. from `<thead>`), so 4 bare `<td>`s under a 2-col header
|
|
76377
76396
|
// become 2 rows of 2.
|
|
76378
|
-
const cells = collectCells(
|
|
76397
|
+
const cells = collectCells(childElement);
|
|
76379
76398
|
if (cells.length === 0)
|
|
76380
76399
|
return;
|
|
76381
76400
|
const cols = children[0]?.children?.length || cells.length;
|
|
@@ -76383,11 +76402,12 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
76383
76402
|
children.push({
|
|
76384
76403
|
type: 'tableRow',
|
|
76385
76404
|
children: cells.slice(i, i + cols),
|
|
76386
|
-
position:
|
|
76405
|
+
position: childElement.position,
|
|
76387
76406
|
});
|
|
76388
76407
|
}
|
|
76389
76408
|
}
|
|
76390
76409
|
});
|
|
76410
|
+
// Output the markdown table node
|
|
76391
76411
|
const firstRow = children[0];
|
|
76392
76412
|
const columnCount = firstRow?.children?.length || 0;
|
|
76393
76413
|
const alignArray = align && columnCount > 0
|
package/dist/main.node.js
CHANGED
|
@@ -96579,13 +96579,32 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96579
96579
|
// remarkMdx wraps inline `<tr>`s in a paragraph; unwrap one level so the
|
|
96580
96580
|
// hasRow check below sees them.
|
|
96581
96581
|
const flattenSectionChildren = (nodes) => nodes.flatMap(n => n.type === 'paragraph' && 'children' in n && Array.isArray(n.children) ? n.children : [n]);
|
|
96582
|
-
|
|
96583
|
-
|
|
96582
|
+
// Iterate the table's direct children in document order. Rows may live
|
|
96583
|
+
// inside a `<thead>`/`<tbody>` section, or sit bare directly under the table
|
|
96584
|
+
// with no section wrapper — both are collected here so the first row becomes
|
|
96585
|
+
// the markdown table header.
|
|
96586
|
+
const tableChildren = flattenSectionChildren(node.children);
|
|
96587
|
+
tableChildren.forEach(child => {
|
|
96588
|
+
if (!isMDXElement(child))
|
|
96589
|
+
return;
|
|
96590
|
+
const childElement = child;
|
|
96591
|
+
// Path for a `<tr>` directly under the table, without a `<thead>`/`<tbody>` wrapper.
|
|
96592
|
+
if (childElement.name === 'tr') {
|
|
96593
|
+
children.push({
|
|
96594
|
+
type: 'tableRow',
|
|
96595
|
+
children: collectCells(childElement),
|
|
96596
|
+
position: childElement.position,
|
|
96597
|
+
});
|
|
96598
|
+
return;
|
|
96599
|
+
}
|
|
96600
|
+
// Path for when the rows are wrapped in a `<thead>`/`<tbody>`
|
|
96601
|
+
// We visit & collect the entire rows under them directly here
|
|
96602
|
+
if (childElement.name !== 'thead' && childElement.name !== 'tbody')
|
|
96584
96603
|
return;
|
|
96585
|
-
const sectionChildren = flattenSectionChildren(
|
|
96604
|
+
const sectionChildren = flattenSectionChildren(childElement.children);
|
|
96586
96605
|
const hasRow = sectionChildren.some(c => isMDXElement(c) && c.name === 'tr');
|
|
96587
96606
|
if (hasRow) {
|
|
96588
|
-
visit(
|
|
96607
|
+
visit(childElement, isMDXElement, (row) => {
|
|
96589
96608
|
if (row.name !== 'tr')
|
|
96590
96609
|
return;
|
|
96591
96610
|
children.push({
|
|
@@ -96599,7 +96618,7 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96599
96618
|
// No `<tr>`, chunk bare cells into rows using the prior row's column
|
|
96600
96619
|
// count (e.g. from `<thead>`), so 4 bare `<td>`s under a 2-col header
|
|
96601
96620
|
// become 2 rows of 2.
|
|
96602
|
-
const cells = collectCells(
|
|
96621
|
+
const cells = collectCells(childElement);
|
|
96603
96622
|
if (cells.length === 0)
|
|
96604
96623
|
return;
|
|
96605
96624
|
const cols = children[0]?.children?.length || cells.length;
|
|
@@ -96607,11 +96626,12 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96607
96626
|
children.push({
|
|
96608
96627
|
type: 'tableRow',
|
|
96609
96628
|
children: cells.slice(i, i + cols),
|
|
96610
|
-
position:
|
|
96629
|
+
position: childElement.position,
|
|
96611
96630
|
});
|
|
96612
96631
|
}
|
|
96613
96632
|
}
|
|
96614
96633
|
});
|
|
96634
|
+
// Output the markdown table node
|
|
96615
96635
|
const firstRow = children[0];
|
|
96616
96636
|
const columnCount = firstRow?.children?.length || 0;
|
|
96617
96637
|
const alignArray = align && columnCount > 0
|