@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.js
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;
|
|
@@ -7300,15 +7354,20 @@ function* formatNode(n, o = {}) {
|
|
|
7300
7354
|
}
|
|
7301
7355
|
yield NL;
|
|
7302
7356
|
} else {
|
|
7303
|
-
|
|
7357
|
+
const widths = [];
|
|
7358
|
+
for (const row of table3) {
|
|
7359
|
+
for (let i = 0; i < row.length; i++) {
|
|
7360
|
+
widths[i] = widths[i] ? Math.max(widths[i], row[i].length) : row[i].length;
|
|
7361
|
+
}
|
|
7362
|
+
}
|
|
7304
7363
|
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
7364
|
yield NL;
|
|
7308
|
-
yield* formatTableRow(head.map(() =>
|
|
7365
|
+
yield* formatTableRow(head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
|
|
7366
|
+
yield NL;
|
|
7367
|
+
yield* formatTableRow(head.map((cell, i) => "-".repeat(widths[i])));
|
|
7309
7368
|
yield NL;
|
|
7310
7369
|
for (const row of rows) {
|
|
7311
|
-
yield* formatTableRow(row.map((
|
|
7370
|
+
yield* formatTableRow(row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)));
|
|
7312
7371
|
yield NL;
|
|
7313
7372
|
}
|
|
7314
7373
|
}
|
|
@@ -7839,7 +7898,7 @@ var td = {
|
|
|
7839
7898
|
var th = {
|
|
7840
7899
|
render: "th",
|
|
7841
7900
|
attributes: {
|
|
7842
|
-
width: { type:
|
|
7901
|
+
width: { type: String },
|
|
7843
7902
|
align: { type: String },
|
|
7844
7903
|
colspan: { type: Number, render: "colSpan" },
|
|
7845
7904
|
rowspan: { type: Number, render: "rowSpan" }
|