@podlite/schema 0.0.83 → 0.0.84
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 +16 -0
- package/esm/ast-inerator.js +1 -3
- package/esm/ast-inerator.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/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/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/pluggableParser.js +9 -4
- package/esm/pluggableParser.js.map +1 -1
- package/esm/plugin-group-items.d.ts +4 -1
- package/esm/plugin-group-items.js +41 -7
- package/esm/plugin-group-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/grammar.js +531 -416
- package/lib/helpers/flatten-deep.d.ts +2 -0
- package/lib/helpers/flatten-deep.js +35 -0
- package/lib/helpers/makeInterator.js +3 -6
- package/lib/helpers/makeTransformer.js +2 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -2
- package/lib/pluggableParser.js +9 -4
- package/lib/plugin-group-items.d.ts +4 -1
- package/lib/plugin-group-items.js +42 -7
- 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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenDeep = flattenDeep;
|
|
4
|
+
const isList = (item) => Array.isArray(item);
|
|
5
|
+
/*
|
|
6
|
+
=begin pod :kind<export>
|
|
7
|
+
|
|
8
|
+
=head2 flattenDeep
|
|
9
|
+
|
|
10
|
+
Puts the items of nested lists into one list, in order, in time that grows with
|
|
11
|
+
the number of items. Holes of a list are skipped. A value that is not a list is
|
|
12
|
+
taken the way C<concat> takes it: an object marked with
|
|
13
|
+
C<Symbol.isConcatSpreadable> gives its items one level deep, holes kept.
|
|
14
|
+
|
|
15
|
+
=end pod
|
|
16
|
+
*/
|
|
17
|
+
function flattenDeep(items) {
|
|
18
|
+
const out = [];
|
|
19
|
+
const walk = (list) => list.forEach(item => {
|
|
20
|
+
if (isList(item))
|
|
21
|
+
return walk(item);
|
|
22
|
+
// concat on an empty list spreads what concat spreads, and copies nothing
|
|
23
|
+
const empty = [];
|
|
24
|
+
const parts = empty.concat(item);
|
|
25
|
+
for (let i = 0; i < parts.length; i++) {
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(parts, i))
|
|
27
|
+
out.push(parts[i]);
|
|
28
|
+
else
|
|
29
|
+
out.length++;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
walk(items);
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=flatten-deep.js.map
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
return arr.reduce((acc, val) => (Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val)), []);
|
|
8
|
-
}
|
|
3
|
+
const flatten_deep_1 = require("./flatten-deep");
|
|
4
|
+
// a value that is not a list is passed on as it is
|
|
5
|
+
const flattenDeep = arr => (Array.isArray(arr) ? (0, flatten_deep_1.flattenDeep)(arr) : arr);
|
|
9
6
|
function thisFunc(rules) {
|
|
10
7
|
function interator(node, context) {
|
|
11
8
|
if (node == null) {
|
|
@@ -4,6 +4,7 @@ exports.makeTransformer = void 0;
|
|
|
4
4
|
exports.isNamedBlock = isNamedBlock;
|
|
5
5
|
exports.isSemanticBlock = isSemanticBlock;
|
|
6
6
|
const makeQuery_1 = require("./makeQuery");
|
|
7
|
+
const flatten_deep_1 = require("./flatten-deep");
|
|
7
8
|
// the following names: MyBlock, myBlock are use for extending pod6
|
|
8
9
|
function isNamedBlock(name) {
|
|
9
10
|
return name && name !== name.toLowerCase() && name !== name.toUpperCase();
|
|
@@ -14,9 +15,6 @@ function isSemanticBlock(node) {
|
|
|
14
15
|
const isTypeBlock = (node.type || '') === 'block';
|
|
15
16
|
return isTypeBlock && name === name.toUpperCase();
|
|
16
17
|
}
|
|
17
|
-
function flattenDeep(arr) {
|
|
18
|
-
return arr.reduce((acc, val) => (Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val)), []);
|
|
19
|
-
}
|
|
20
18
|
const makeTransformer = rule => {
|
|
21
19
|
let rules = [];
|
|
22
20
|
function use(key, fn) {
|
|
@@ -38,7 +36,7 @@ const makeTransformer = rule => {
|
|
|
38
36
|
return node;
|
|
39
37
|
}
|
|
40
38
|
if (node instanceof Array) {
|
|
41
|
-
return flattenDeep(node.map(item => visiter(item, context)));
|
|
39
|
+
return (0, flatten_deep_1.flattenDeep)(node.map(item => visiter(item, context)));
|
|
42
40
|
}
|
|
43
41
|
if ('string' === typeof node) {
|
|
44
42
|
// convert string to lex node with type
|
package/lib/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type { LinkConfig } from './helpers/link-config';
|
|
|
25
25
|
export { pluginCleanLocation } from './plugin-clean-location';
|
|
26
26
|
export { toAnyRules } from './helpers/plugins';
|
|
27
27
|
export { podlitePluggable, Podlite, PodliteExport, cleanIds, frozenIds, headingId } from './pluggableParser';
|
|
28
|
+
export { MAX_LIST_LEVEL } from './plugin-group-items';
|
|
28
29
|
import { ConfigScope } from './helpers/configPropagation';
|
|
29
30
|
export { mergeConfigSettings, propagateConfigDefaults, walkConfigScopes } from './helpers/configPropagation';
|
|
30
31
|
export { blockNameOf, holderInside, isDirectiveNode, isWrapper } from './helpers/blockName';
|
package/lib/index.js
CHANGED
|
@@ -39,8 +39,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
43
|
-
exports.version = exports.applyImageBase = exports.tocTitleText = exports.mayHoldTests = exports.canOwnTest = exports.testFoldedByAuthor = exports.testCaption = exports.applyFoldedSections = exports.renderCodeText = exports.getMaskedTextContent = void 0;
|
|
42
|
+
exports.isCovered = exports.markGuarded = exports.isSetTarget = exports.isSetTransparent = exports.mergeSet = exports.applySetToFirst = exports.SelectorError = exports.getDocIDs = exports.filePathMatches = exports.outermost = exports.runSelector = exports.readSelector = exports.parseSelector = exports.Writer = exports.toMarkdown = exports.toHtml = exports.parseFormattingCodes = exports.parse = exports.isWrapper = exports.isDirectiveNode = exports.holderInside = exports.blockNameOf = exports.walkConfigScopes = exports.propagateConfigDefaults = exports.mergeConfigSettings = exports.MAX_LIST_LEVEL = exports.headingId = exports.frozenIds = exports.cleanIds = exports.podlitePluggable = exports.toAnyRules = exports.pluginCleanLocation = exports.quoteAttribute = exports.fingerprint = exports.assignHeadingKeys = exports.readLinkConfig = exports.parseAttributes = exports.codeConfigWithDefaults = exports.makeAttrs = exports.toAny = exports.isSemanticBlock = exports.isNamedBlock = exports.makeTransformer = exports.makeInterator = exports.MARKUP_CODE_DEPTH_LIMIT = exports.ALIAS_EXPANSION_BUDGET = exports.ALIAS_EXPANSION_DEPTH = exports.expandAlias = exports.isTitleBlock = exports.titleParts = void 0;
|
|
43
|
+
exports.version = exports.applyImageBase = exports.tocTitleText = exports.mayHoldTests = exports.canOwnTest = exports.testFoldedByAuthor = exports.testCaption = exports.applyFoldedSections = exports.renderCodeText = exports.getMaskedTextContent = exports.guardedTextLeaves = void 0;
|
|
44
44
|
exports.toAst = toAst;
|
|
45
45
|
exports.getTextContentFromNode = getTextContentFromNode;
|
|
46
46
|
exports.getPodContentFromNode = getPodContentFromNode;
|
|
@@ -108,6 +108,8 @@ const plugin_items_1 = __importDefault(require("./plugin-items"));
|
|
|
108
108
|
const plugin_heading_1 = __importDefault(require("./plugin-heading"));
|
|
109
109
|
const plugin_group_defn_1 = __importDefault(require("./plugin-group-defn"));
|
|
110
110
|
const plugin_group_items_1 = __importDefault(require("./plugin-group-items"));
|
|
111
|
+
var plugin_group_items_2 = require("./plugin-group-items");
|
|
112
|
+
Object.defineProperty(exports, "MAX_LIST_LEVEL", { enumerable: true, get: function () { return plugin_group_items_2.MAX_LIST_LEVEL; } });
|
|
111
113
|
const plugin_defn_fill_term_1 = __importDefault(require("./plugin-defn-fill-term"));
|
|
112
114
|
const plugin_set_1 = __importDefault(require("./plugin-set"));
|
|
113
115
|
const configPropagation_1 = require("./helpers/configPropagation");
|
package/lib/pluggableParser.js
CHANGED
|
@@ -19,6 +19,8 @@ var ids_2 = require("./helpers/ids");
|
|
|
19
19
|
Object.defineProperty(exports, "cleanIds", { enumerable: true, get: function () { return ids_2.cleanIds; } });
|
|
20
20
|
Object.defineProperty(exports, "frozenIds", { enumerable: true, get: function () { return ids_2.frozenIds; } });
|
|
21
21
|
Object.defineProperty(exports, "headingId", { enumerable: true, get: function () { return ids_2.headingId; } });
|
|
22
|
+
// what the parser did to a table; a report that something written is missing is not one of them
|
|
23
|
+
const TABLE_REPAIRS = ['table-row-cells', 'table-mixed-separators', 'table-cell-outside-row'];
|
|
22
24
|
const podlitePluggable = ({ plugins = {} } = {}) => {
|
|
23
25
|
let instance = function () { };
|
|
24
26
|
let _plugins = [];
|
|
@@ -61,11 +63,14 @@ const podlitePluggable = ({ plugins = {} } = {}) => {
|
|
|
61
63
|
// one mistake inside a value reports twice: for the value and for the whole
|
|
62
64
|
// attribute around it. The narrower report names the place to fix. Two reports of
|
|
63
65
|
// one place keep the first; a warning about a markup code is about the code, not
|
|
64
|
-
// a value, and stays
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
// a value, and stays, as do warnings about a row of a table, its source and a list too deep
|
|
67
|
+
const stays = (d) => d.code.startsWith('markup-code-') ||
|
|
68
|
+
d.code.startsWith('table-source-') ||
|
|
69
|
+
d.code === 'list-too-deep' ||
|
|
70
|
+
TABLE_REPAIRS.includes(d.code);
|
|
71
|
+
const innermost = diagnostics.filter((d, k) => stays(d) ||
|
|
67
72
|
!diagnostics.some((other, j) => other !== d &&
|
|
68
|
-
!
|
|
73
|
+
!stays(other) &&
|
|
69
74
|
other.location.start.offset >= d.location.start.offset &&
|
|
70
75
|
other.location.end.offset <= d.location.end.offset &&
|
|
71
76
|
(other.location.start.offset !== d.location.start.offset ||
|
|
@@ -3,8 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MAX_LIST_LEVEL = void 0;
|
|
6
7
|
const config_1 = __importDefault(require("./helpers/config"));
|
|
7
|
-
|
|
8
|
+
// lists nest no deeper than this: deeper trees overflow the stack of the renderers
|
|
9
|
+
exports.MAX_LIST_LEVEL = 50;
|
|
10
|
+
exports.default = (opt = {}) => tree => {
|
|
8
11
|
const isNodesEqual = (n1, n2) =>
|
|
9
12
|
// if nodes items
|
|
10
13
|
(n1.name === 'item' || n1.name === 'defn') &&
|
|
@@ -14,7 +17,37 @@ exports.default = () => tree => {
|
|
|
14
17
|
isChecked(n1) === isChecked(n2);
|
|
15
18
|
const isNumbered = node => Boolean((0, config_1.default)(node, {}).exists('numbered'));
|
|
16
19
|
const isChecked = node => node.checked !== undefined;
|
|
17
|
-
|
|
20
|
+
// the level a list is built at; the level the author wrote stays on the item
|
|
21
|
+
const nestAt = item => Math.min(Number(item.level), exports.MAX_LIST_LEVEL);
|
|
22
|
+
const tooDeep = item => item.name === 'item' && item.type === 'block' && Number(item.level) > exports.MAX_LIST_LEVEL;
|
|
23
|
+
const report = item => {
|
|
24
|
+
if (!Array.isArray(opt.diagnostics))
|
|
25
|
+
return;
|
|
26
|
+
opt.diagnostics.push({
|
|
27
|
+
severity: 'warning',
|
|
28
|
+
code: 'list-too-deep',
|
|
29
|
+
message: `list item at level ${Number(item.level)} is deeper than ${exports.MAX_LIST_LEVEL} levels; it is shown at level ${exports.MAX_LIST_LEVEL}`,
|
|
30
|
+
location: item.location,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
// a list is the items of one content with nothing but blank lines between them
|
|
34
|
+
const reportDeepLists = content => {
|
|
35
|
+
let told = false;
|
|
36
|
+
content.forEach(node => {
|
|
37
|
+
if (node.type === 'blankline')
|
|
38
|
+
return;
|
|
39
|
+
if (node.name !== 'item' || node.type !== 'block')
|
|
40
|
+
told = false;
|
|
41
|
+
else if (!told && tooDeep(node)) {
|
|
42
|
+
report(node);
|
|
43
|
+
told = true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
// the content of a list is grouped again for its next level and is not told twice
|
|
48
|
+
const group = (a, level = 1, ofList = false) => {
|
|
49
|
+
if (!ofList)
|
|
50
|
+
reportDeepLists(a);
|
|
18
51
|
const isInListMode = a => {
|
|
19
52
|
return a.length > 0 && a[a.length - 1].type === 'list';
|
|
20
53
|
};
|
|
@@ -26,21 +59,23 @@ exports.default = () => tree => {
|
|
|
26
59
|
let lastItem = {};
|
|
27
60
|
let result = a.reduce((a, i) => {
|
|
28
61
|
// skip items out of level
|
|
29
|
-
if (i.name === 'item' && i.type === 'block' && i
|
|
30
|
-
|
|
62
|
+
if (i.name === 'item' && i.type === 'block' && nestAt(i) < level) {
|
|
63
|
+
a.push(i);
|
|
64
|
+
return a;
|
|
31
65
|
}
|
|
32
66
|
if (i.name === 'item' &&
|
|
33
67
|
i.type === 'block' &&
|
|
34
68
|
(!isInListMode(a) ||
|
|
35
69
|
// different type of list and item
|
|
36
70
|
// at the same level
|
|
37
|
-
|
|
71
|
+
// and an item past the limit in a list that already stands at the limit
|
|
72
|
+
((nestAt(i) === level || (tooDeep(i) && Number(getList(a).level) === exports.MAX_LIST_LEVEL)) &&
|
|
38
73
|
getList(a).list !== (isNumbered(i) ? 'ordered' : isChecked(i) ? 'task' : 'itemized')))) {
|
|
39
74
|
// create empty list
|
|
40
75
|
// list = ['ordered', 'variable', 'itemized']
|
|
41
76
|
a.push({
|
|
42
77
|
type: 'list',
|
|
43
|
-
level: i.level,
|
|
78
|
+
level: tooDeep(i) ? exports.MAX_LIST_LEVEL : i.level,
|
|
44
79
|
content: [],
|
|
45
80
|
list: isNumbered(i) ? 'ordered' : isChecked(i) ? 'task' : 'itemized',
|
|
46
81
|
});
|
|
@@ -65,7 +100,7 @@ exports.default = () => tree => {
|
|
|
65
100
|
return result.map(item => {
|
|
66
101
|
// process any item with content ( except formatting codes)
|
|
67
102
|
if (item.content && item.type !== 'fcode') {
|
|
68
|
-
item.content = group(item.content, Number(item.level || 0) + 1);
|
|
103
|
+
item.content = group(item.content, Number(item.level || 0) + 1, item.type === 'list');
|
|
69
104
|
}
|
|
70
105
|
return item;
|
|
71
106
|
});
|
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.84";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
package/schema/AstTree.json
CHANGED