@markdoc/markdoc 0.3.4 → 0.3.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.
package/dist/index.mjs CHANGED
@@ -7276,15 +7276,20 @@ function* formatNode(n, o = {}) {
7276
7276
  }
7277
7277
  yield NL;
7278
7278
  } else {
7279
- yield NL;
7279
+ const widths = [];
7280
+ for (const row of table3) {
7281
+ for (let i = 0; i < row.length; i++) {
7282
+ widths[i] = widths[i] ? Math.max(widths[i], row[i].length) : row[i].length;
7283
+ }
7284
+ }
7280
7285
  const [head, ...rows] = table3;
7281
- const ml = table3.map((arr) => arr.map((s2) => s2.length).reduce(max)).reduce(max);
7282
- yield* formatTableRow(head.map((h) => h + SPACE.repeat(ml - h.length)));
7283
7286
  yield NL;
7284
- yield* formatTableRow(head.map(() => "-".repeat(ml)));
7287
+ yield* formatTableRow(head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
7288
+ yield NL;
7289
+ yield* formatTableRow(head.map((cell, i) => "-".repeat(widths[i])));
7285
7290
  yield NL;
7286
7291
  for (const row of rows) {
7287
- yield* formatTableRow(row.map((r) => r + SPACE.repeat(ml - r.length)));
7292
+ yield* formatTableRow(row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
7288
7293
  yield NL;
7289
7294
  }
7290
7295
  }