@minamorl/markdown-next 2.2.2 → 2.2.3
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/lib/src/parser.js +6 -4
- package/package.json +1 -1
package/lib/src/parser.js
CHANGED
|
@@ -155,19 +155,21 @@ class Parser {
|
|
|
155
155
|
return content.trim();
|
|
156
156
|
};
|
|
157
157
|
// Table parser
|
|
158
|
-
|
|
158
|
+
// Use .chain() for validation instead of returning P.makeFailure from seqMap callback,
|
|
159
|
+
// since seqMap treats the return value as a successful parse result (not a parser control signal).
|
|
160
|
+
const table = P.seq(tableRowLine.skip(linebreak), tableRowLine.skip(linebreak), tableRowLine.skip(linebreak.atMost(1)).atLeast(0)).chain(([headerLine, sepLine, bodyLines]) => {
|
|
159
161
|
// Validate separator row
|
|
160
162
|
if (!isSeparatorRow(sepLine)) {
|
|
161
|
-
return P.
|
|
163
|
+
return P.fail('Not a valid table separator');
|
|
162
164
|
}
|
|
163
165
|
const headerCells = parseTableRow(headerLine);
|
|
164
166
|
const bodyCells = bodyLines.map(parseTableRow);
|
|
165
167
|
if (headerCells.length === 0) {
|
|
166
|
-
return P.
|
|
168
|
+
return P.fail('No header cells');
|
|
167
169
|
}
|
|
168
170
|
const headerRow = mapper('tr')(join(headerCells.map((h) => mapper('th')(parseCellContent(h)))));
|
|
169
171
|
const bodyRows = bodyCells.map((row) => mapper('tr')(join(row.map((cell) => mapper('td')(parseCellContent(cell))))));
|
|
170
|
-
return mapper('table')(join([headerRow, ...bodyRows]));
|
|
172
|
+
return P.succeed(mapper('table')(join([headerRow, ...bodyRows])));
|
|
171
173
|
});
|
|
172
174
|
const inlines = inline.atLeast(1).map(join);
|
|
173
175
|
const paragraphBegin = inlines;
|
package/package.json
CHANGED