@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.js CHANGED
@@ -7300,15 +7300,20 @@ function* formatNode(n, o = {}) {
7300
7300
  }
7301
7301
  yield NL;
7302
7302
  } else {
7303
- yield NL;
7303
+ const widths = [];
7304
+ for (const row of table3) {
7305
+ for (let i = 0; i < row.length; i++) {
7306
+ widths[i] = widths[i] ? Math.max(widths[i], row[i].length) : row[i].length;
7307
+ }
7308
+ }
7304
7309
  const [head, ...rows] = table3;
7305
- const ml = table3.map((arr) => arr.map((s2) => s2.length).reduce(max)).reduce(max);
7306
- yield* formatTableRow(head.map((h) => h + SPACE.repeat(ml - h.length)));
7307
7310
  yield NL;
7308
- yield* formatTableRow(head.map(() => "-".repeat(ml)));
7311
+ yield* formatTableRow(head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
7312
+ yield NL;
7313
+ yield* formatTableRow(head.map((cell, i) => "-".repeat(widths[i])));
7309
7314
  yield NL;
7310
7315
  for (const row of rows) {
7311
- yield* formatTableRow(row.map((r) => r + SPACE.repeat(ml - r.length)));
7316
+ yield* formatTableRow(row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
7312
7317
  yield NL;
7313
7318
  }
7314
7319
  }