@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 +10 -5
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +10 -5
- package/dist/index.mjs.map +2 -2
- package/dist/src/formatter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/formatter.test.ts +4 -4
- package/src/formatter.ts +16 -8
package/dist/index.mjs
CHANGED
|
@@ -7276,15 +7276,20 @@ function* formatNode(n, o = {}) {
|
|
|
7276
7276
|
}
|
|
7277
7277
|
yield NL;
|
|
7278
7278
|
} else {
|
|
7279
|
-
|
|
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(() =>
|
|
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((
|
|
7292
|
+
yield* formatTableRow(row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
|
|
7288
7293
|
yield NL;
|
|
7289
7294
|
}
|
|
7290
7295
|
}
|