@markdoc/markdoc 0.3.4 → 0.4.0
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 +68 -9
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +68 -9
- 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/src/grammar/tag.js +57 -3
- package/src/grammar/tag.pegjs +7 -1
- package/src/schema.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -141,6 +141,9 @@ var require_tag = __commonJS({
|
|
|
141
141
|
var peg$c15 = "-";
|
|
142
142
|
var peg$c16 = '"';
|
|
143
143
|
var peg$c17 = "\\";
|
|
144
|
+
var peg$c18 = "n";
|
|
145
|
+
var peg$c19 = "r";
|
|
146
|
+
var peg$c20 = "t";
|
|
144
147
|
var peg$r0 = /^[$@]/;
|
|
145
148
|
var peg$r1 = /^[0-9]/;
|
|
146
149
|
var peg$r2 = /^[^\0-\x1F"\\]/;
|
|
@@ -267,7 +270,16 @@ var require_tag = __commonJS({
|
|
|
267
270
|
var peg$f28 = function(value) {
|
|
268
271
|
return value.join("");
|
|
269
272
|
};
|
|
270
|
-
var peg$f29 = function(
|
|
273
|
+
var peg$f29 = function() {
|
|
274
|
+
return "\n";
|
|
275
|
+
};
|
|
276
|
+
var peg$f30 = function() {
|
|
277
|
+
return "\r";
|
|
278
|
+
};
|
|
279
|
+
var peg$f31 = function() {
|
|
280
|
+
return " ";
|
|
281
|
+
};
|
|
282
|
+
var peg$f32 = function(sequence) {
|
|
271
283
|
return sequence;
|
|
272
284
|
};
|
|
273
285
|
var peg$currPos = 0;
|
|
@@ -1525,7 +1537,7 @@ var require_tag = __commonJS({
|
|
|
1525
1537
|
return s0;
|
|
1526
1538
|
}
|
|
1527
1539
|
function peg$parseValueStringEscapes() {
|
|
1528
|
-
var s0, s1, s2;
|
|
1540
|
+
var s0, s1, s2, s3;
|
|
1529
1541
|
var rule$expects = function(expected2) {
|
|
1530
1542
|
if (peg$silentFails === 0)
|
|
1531
1543
|
peg$expect(expected2);
|
|
@@ -1551,10 +1563,52 @@ var require_tag = __commonJS({
|
|
|
1551
1563
|
} else {
|
|
1552
1564
|
s2 = peg$FAILED;
|
|
1553
1565
|
}
|
|
1566
|
+
if (s2 === peg$FAILED) {
|
|
1567
|
+
s2 = peg$currPos;
|
|
1568
|
+
if (input.charCodeAt(peg$currPos) === 110) {
|
|
1569
|
+
s3 = peg$c18;
|
|
1570
|
+
peg$currPos++;
|
|
1571
|
+
} else {
|
|
1572
|
+
s3 = peg$FAILED;
|
|
1573
|
+
}
|
|
1574
|
+
if (s3 !== peg$FAILED) {
|
|
1575
|
+
peg$savedPos = s2;
|
|
1576
|
+
s3 = peg$f29();
|
|
1577
|
+
}
|
|
1578
|
+
s2 = s3;
|
|
1579
|
+
if (s2 === peg$FAILED) {
|
|
1580
|
+
s2 = peg$currPos;
|
|
1581
|
+
if (input.charCodeAt(peg$currPos) === 114) {
|
|
1582
|
+
s3 = peg$c19;
|
|
1583
|
+
peg$currPos++;
|
|
1584
|
+
} else {
|
|
1585
|
+
s3 = peg$FAILED;
|
|
1586
|
+
}
|
|
1587
|
+
if (s3 !== peg$FAILED) {
|
|
1588
|
+
peg$savedPos = s2;
|
|
1589
|
+
s3 = peg$f30();
|
|
1590
|
+
}
|
|
1591
|
+
s2 = s3;
|
|
1592
|
+
if (s2 === peg$FAILED) {
|
|
1593
|
+
s2 = peg$currPos;
|
|
1594
|
+
if (input.charCodeAt(peg$currPos) === 116) {
|
|
1595
|
+
s3 = peg$c20;
|
|
1596
|
+
peg$currPos++;
|
|
1597
|
+
} else {
|
|
1598
|
+
s3 = peg$FAILED;
|
|
1599
|
+
}
|
|
1600
|
+
if (s3 !== peg$FAILED) {
|
|
1601
|
+
peg$savedPos = s2;
|
|
1602
|
+
s3 = peg$f31();
|
|
1603
|
+
}
|
|
1604
|
+
s2 = s3;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1554
1608
|
}
|
|
1555
1609
|
if (s2 !== peg$FAILED) {
|
|
1556
1610
|
peg$savedPos = s0;
|
|
1557
|
-
s0 = peg$
|
|
1611
|
+
s0 = peg$f32(s2);
|
|
1558
1612
|
} else {
|
|
1559
1613
|
peg$currPos = s0;
|
|
1560
1614
|
s0 = peg$FAILED;
|
|
@@ -7276,15 +7330,20 @@ function* formatNode(n, o = {}) {
|
|
|
7276
7330
|
}
|
|
7277
7331
|
yield NL;
|
|
7278
7332
|
} else {
|
|
7279
|
-
|
|
7333
|
+
const widths = [];
|
|
7334
|
+
for (const row of table3) {
|
|
7335
|
+
for (let i = 0; i < row.length; i++) {
|
|
7336
|
+
widths[i] = widths[i] ? Math.max(widths[i], row[i].length) : row[i].length;
|
|
7337
|
+
}
|
|
7338
|
+
}
|
|
7280
7339
|
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
7340
|
yield NL;
|
|
7284
|
-
yield* formatTableRow(head.map(() =>
|
|
7341
|
+
yield* formatTableRow(head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
|
|
7342
|
+
yield NL;
|
|
7343
|
+
yield* formatTableRow(head.map((cell, i) => "-".repeat(widths[i])));
|
|
7285
7344
|
yield NL;
|
|
7286
7345
|
for (const row of rows) {
|
|
7287
|
-
yield* formatTableRow(row.map((
|
|
7346
|
+
yield* formatTableRow(row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
|
|
7288
7347
|
yield NL;
|
|
7289
7348
|
}
|
|
7290
7349
|
}
|
|
@@ -7815,7 +7874,7 @@ var td = {
|
|
|
7815
7874
|
var th = {
|
|
7816
7875
|
render: "th",
|
|
7817
7876
|
attributes: {
|
|
7818
|
-
width: { type:
|
|
7877
|
+
width: { type: String },
|
|
7819
7878
|
align: { type: String },
|
|
7820
7879
|
colspan: { type: Number, render: "colSpan" },
|
|
7821
7880
|
rowspan: { type: Number, render: "rowSpan" }
|