@podlite/schema 0.0.83 → 0.0.85
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/CHANGELOG.podlite +30 -0
- package/esm/ast-inerator.js +1 -3
- package/esm/ast-inerator.js.map +1 -1
- package/esm/codes/scan.js +26 -22
- package/esm/codes/scan.js.map +1 -1
- package/esm/grammar.js +531 -416
- package/esm/grammar.js.map +1 -1
- package/esm/helpers/flatten-deep.d.ts +2 -0
- package/esm/helpers/flatten-deep.js +32 -0
- package/esm/helpers/flatten-deep.js.map +1 -0
- package/esm/helpers/itemNumbering.d.ts +2 -1
- package/esm/helpers/itemNumbering.js +3 -2
- package/esm/helpers/itemNumbering.js.map +1 -1
- package/esm/helpers/makeInterator.js +3 -6
- package/esm/helpers/makeInterator.js.map +1 -1
- package/esm/helpers/makeTransformer.js +1 -3
- package/esm/helpers/makeTransformer.js.map +1 -1
- package/esm/helpers/numberedShorthand.d.ts +2 -1
- package/esm/helpers/numberedShorthand.js +24 -4
- package/esm/helpers/numberedShorthand.js.map +1 -1
- package/esm/index.d.ts +3 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -1
- package/esm/markup-code-letters.d.ts +2 -0
- package/esm/markup-code-letters.js +65 -0
- package/esm/markup-code-letters.js.map +1 -0
- package/esm/pluggableParser.js +13 -5
- package/esm/pluggableParser.js.map +1 -1
- package/esm/plugin-defn-fill-term.js +7 -0
- package/esm/plugin-defn-fill-term.js.map +1 -1
- package/esm/plugin-group-defn.js +6 -8
- package/esm/plugin-group-defn.js.map +1 -1
- package/esm/plugin-group-items.d.ts +4 -1
- package/esm/plugin-group-items.js +43 -9
- package/esm/plugin-group-items.js.map +1 -1
- package/esm/plugin-items.js +6 -5
- package/esm/plugin-items.js.map +1 -1
- package/esm/plugin-tables.js +33 -10
- package/esm/plugin-tables.js.map +1 -1
- package/esm/types.d.ts +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/ast-inerator.js +2 -4
- package/lib/codes/scan.js +26 -22
- package/lib/grammar.js +531 -416
- package/lib/helpers/flatten-deep.d.ts +2 -0
- package/lib/helpers/flatten-deep.js +35 -0
- package/lib/helpers/itemNumbering.d.ts +2 -1
- package/lib/helpers/itemNumbering.js +5 -3
- package/lib/helpers/makeInterator.js +3 -6
- package/lib/helpers/makeTransformer.js +2 -4
- package/lib/helpers/numberedShorthand.d.ts +2 -1
- package/lib/helpers/numberedShorthand.js +26 -5
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/markup-code-letters.d.ts +2 -0
- package/lib/markup-code-letters.js +69 -0
- package/lib/pluggableParser.js +13 -5
- package/lib/plugin-defn-fill-term.js +7 -0
- package/lib/plugin-group-defn.js +6 -8
- package/lib/plugin-group-items.d.ts +4 -1
- package/lib/plugin-group-items.js +44 -12
- package/lib/plugin-items.js +5 -4
- package/lib/plugin-tables.js +37 -14
- package/lib/types.d.ts +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/schema/AstTree.json +1 -0
- package/schema/PodliteDocument.json +1 -0
package/lib/plugin-tables.js
CHANGED
|
@@ -21,9 +21,7 @@ const config_1 = __importDefault(require("./helpers/config"));
|
|
|
21
21
|
const scan_1 = require("./codes/scan");
|
|
22
22
|
const configPropagation_1 = require("./helpers/configPropagation");
|
|
23
23
|
const code_config_1 = require("./helpers/code-config");
|
|
24
|
-
|
|
25
|
-
return arr.reduce((acc, val) => (Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val)), []);
|
|
26
|
-
}
|
|
24
|
+
const flatten_deep_1 = require("./helpers/flatten-deep");
|
|
27
25
|
// ─── CSV source for =table (spec §1672) ────────────────────────────────────
|
|
28
26
|
// Parse CSV content per RFC 4180: comma delimiter, `"`-quoted fields with
|
|
29
27
|
// `""` as embedded-quote escape. Supports LF or CRLF line endings. Leading
|
|
@@ -257,9 +255,12 @@ function normalizeCellCounts(tableNode, source = 'table', report = noReport) {
|
|
|
257
255
|
if (expected === 0)
|
|
258
256
|
return tableNode;
|
|
259
257
|
let mutated = false;
|
|
258
|
+
// a report names its row by its place among the rows, the header and even rows counted
|
|
259
|
+
let rowNumber = 0;
|
|
260
260
|
const newContent = tableNode.content.map(child => {
|
|
261
261
|
if (!child || child.type !== 'block' || child.name !== 'row')
|
|
262
262
|
return child;
|
|
263
|
+
rowNumber++;
|
|
263
264
|
const cells = cellsOf(child);
|
|
264
265
|
if (cells.length === expected)
|
|
265
266
|
return child;
|
|
@@ -267,13 +268,13 @@ function normalizeCellCounts(tableNode, source = 'table', report = noReport) {
|
|
|
267
268
|
const padding = [];
|
|
268
269
|
for (let i = cells.length; i < expected; i++)
|
|
269
270
|
padding.push(buildCellBlock(''));
|
|
270
|
-
report('table-row-cells', `${source} row has ${cells.length} of ${expected} cells, padded with ${padding.length} empty. A row continued on the next line needs a blank line before the next row`, tableNode);
|
|
271
|
+
report('table-row-cells', `${source} row ${rowNumber} has ${cells.length} of ${expected} cells, padded with ${padding.length} empty. A row continued on the next line needs a blank line before the next row`, tableNode);
|
|
271
272
|
mutated = true;
|
|
272
273
|
return { ...child, content: [...child.content, ...padding] };
|
|
273
274
|
}
|
|
274
275
|
// cells.length > expected → truncate
|
|
275
276
|
const dropped = cells.length - expected;
|
|
276
|
-
report('table-row-cells', `${source} row has ${cells.length} of ${expected} cells, dropped ${dropped}`, tableNode);
|
|
277
|
+
report('table-row-cells', `${source} row ${rowNumber} has ${cells.length} of ${expected} cells, dropped ${dropped}`, tableNode);
|
|
277
278
|
mutated = true;
|
|
278
279
|
// Keep non-cell entries (e.g. blanklines) and the first `expected` cells
|
|
279
280
|
let keepCells = expected;
|
|
@@ -392,10 +393,30 @@ const strbin = (str1, str2, cb) => {
|
|
|
392
393
|
}
|
|
393
394
|
return res.join('');
|
|
394
395
|
};
|
|
395
|
-
//
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
// the norm puts a separator between every row on several lines, so the lines after the last one are a row too
|
|
397
|
+
const groupRows = (content) => {
|
|
398
|
+
const isTextRow = (c) => Boolean(c) && c.name === 'row' && c.type === 'text';
|
|
399
|
+
const groups = [[]];
|
|
400
|
+
content.forEach((c, i) => {
|
|
401
|
+
if (isTextRow(c))
|
|
402
|
+
groups[groups.length - 1].push(i);
|
|
403
|
+
else if (c && c.type === 'separator' && groups[groups.length - 1].length)
|
|
404
|
+
groups.push([]);
|
|
405
|
+
});
|
|
406
|
+
const filled = groups.filter(g => g.length);
|
|
407
|
+
if (filled.length < 2)
|
|
408
|
+
return content;
|
|
409
|
+
const firstOf = new Map(filled.map(g => [g[0], g]));
|
|
410
|
+
const merged = new Set(filled.flatMap(g => g.slice(1)));
|
|
411
|
+
return content.flatMap((c, i) => {
|
|
412
|
+
if (merged.has(i))
|
|
413
|
+
return [];
|
|
414
|
+
const group = firstOf.get(i);
|
|
415
|
+
if (!group || group.length === 1)
|
|
416
|
+
return [c];
|
|
417
|
+
return [{ ...c, value: group.map(k => content[k].value ?? '').join('') }];
|
|
418
|
+
});
|
|
419
|
+
};
|
|
399
420
|
const makeMask = (lines, separators) => {
|
|
400
421
|
const tmplLength = Math.max(...[...lines, ...separators].map(s => s.length));
|
|
401
422
|
// a table held apart by spaces alone splits on two of them, as a row on one line
|
|
@@ -419,7 +440,7 @@ const makeMask = (lines, separators) => {
|
|
|
419
440
|
// per-column substrings and aggregating across lines (continuation lines
|
|
420
441
|
// append to the cell at the same column position).
|
|
421
442
|
const extractColumnsByTemplate = (text, template) => {
|
|
422
|
-
const lines = flattenDeep(text.split(/\n/).filter(s => s.length > 0));
|
|
443
|
+
const lines = (0, flatten_deep_1.flattenDeep)(text.split(/\n/).filter(s => s.length > 0));
|
|
423
444
|
const cols = lines.map(line => {
|
|
424
445
|
const re = /((1+|0+))/g;
|
|
425
446
|
const columns = [];
|
|
@@ -621,6 +642,8 @@ exports.default = (opt = {}) => tree => {
|
|
|
621
642
|
const recursed = visiter ? visiter(transformedContent, ctx) : transformedContent;
|
|
622
643
|
return normalizeCellCounts({ ...attached, content: recursed }, 'table', report);
|
|
623
644
|
}
|
|
645
|
+
const ownScope = scopes.get(node) || {};
|
|
646
|
+
node = { ...node, content: groupRows(node.content || []) };
|
|
624
647
|
let rows = [];
|
|
625
648
|
const collectValues = row => {
|
|
626
649
|
rows.push(row.value);
|
|
@@ -642,9 +665,9 @@ exports.default = (opt = {}) => tree => {
|
|
|
642
665
|
.split(/\n/) // split each row by eol
|
|
643
666
|
.filter(str => str.length > 0); // filter empty strings ( after slit )
|
|
644
667
|
// split each row into lines
|
|
645
|
-
const lines = flattenDeep(rows.map(splitToLines));
|
|
646
|
-
const separators = flattenDeep(seps.map(splitToLines));
|
|
647
|
-
const codeScope = codeScopeOf(node,
|
|
668
|
+
const lines = (0, flatten_deep_1.flattenDeep)(rows.map(splitToLines));
|
|
669
|
+
const separators = (0, flatten_deep_1.flattenDeep)(seps.map(splitToLines));
|
|
670
|
+
const codeScope = codeScopeOf(node, ownScope);
|
|
648
671
|
const protect = (line) => protectCodes(line, codeScope);
|
|
649
672
|
const masks = lines.map(protect);
|
|
650
673
|
// Rule 3: warn on mixed separator types within a single table
|
|
@@ -697,7 +720,7 @@ exports.default = (opt = {}) => tree => {
|
|
|
697
720
|
'row:text': row => {
|
|
698
721
|
if (textRows.length == 1) {
|
|
699
722
|
// the only text row of the table: each of its lines becomes its own row
|
|
700
|
-
const textRowsLines = flattenDeep([row.value].map(splitToLines));
|
|
723
|
+
const textRowsLines = (0, flatten_deep_1.flattenDeep)([row.value].map(splitToLines));
|
|
701
724
|
return textRowsLines.map(line => makeRow((byLines
|
|
702
725
|
? splitVisibleLine(line, protect(line))
|
|
703
726
|
: splitsItself(line)
|
package/lib/types.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ export interface RootBlock extends Omit<Block, 'location'> {
|
|
|
148
148
|
}
|
|
149
149
|
export interface ParseDiagnostic {
|
|
150
150
|
severity: 'warning';
|
|
151
|
-
code: 'value-unreadable' | 'directive-unreadable' | 'table-row-cells' | 'table-cell-outside-row' | 'table-mixed-separators' | 'table-source-unreadable' | 'table-source-empty' | 'table-source-deferred' | 'markup-code-unclosed' | 'markup-code-longer-run' | 'markup-code-foreign-closer' | 'markup-code-reserved' | 'markup-code-unsupported' | 'markup-code-unreadable' | 'markup-code-too-deep';
|
|
151
|
+
code: 'value-unreadable' | 'directive-unreadable' | 'table-row-cells' | 'table-cell-outside-row' | 'table-mixed-separators' | 'table-source-unreadable' | 'table-source-empty' | 'table-source-deferred' | 'markup-code-unclosed' | 'markup-code-longer-run' | 'markup-code-foreign-closer' | 'markup-code-reserved' | 'markup-code-unsupported' | 'markup-code-unreadable' | 'markup-code-too-deep' | 'list-too-deep';
|
|
152
152
|
message: string;
|
|
153
153
|
location: Location;
|
|
154
154
|
}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.85";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
package/schema/AstTree.json
CHANGED