@podlite/schema 0.0.70 → 0.0.71
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 +82 -0
- package/esm/ast-helpers.d.ts +11 -0
- package/esm/ast-helpers.js +277 -25
- package/esm/ast-helpers.js.map +1 -1
- package/esm/block-names.d.ts +2 -2
- package/esm/block-names.js +7 -0
- package/esm/block-names.js.map +1 -1
- package/esm/blocks-helpers.d.ts +1 -1
- package/esm/blocks-helpers.js +3 -1
- package/esm/blocks-helpers.js.map +1 -1
- package/esm/exportHtml.js +85 -28
- package/esm/exportHtml.js.map +1 -1
- package/esm/exportMarkdown.js +112 -27
- package/esm/exportMarkdown.js.map +1 -1
- package/esm/grammar.js +588 -454
- package/esm/grammar.js.map +1 -1
- package/esm/guard.js +11 -1
- package/esm/guard.js.map +1 -1
- package/esm/helpers/blockName.d.ts +8 -0
- package/esm/helpers/blockName.js +60 -0
- package/esm/helpers/blockName.js.map +1 -0
- package/esm/helpers/configPropagation.d.ts +12 -2
- package/esm/helpers/configPropagation.js +51 -13
- package/esm/helpers/configPropagation.js.map +1 -1
- package/esm/helpers/corePlugins.d.ts +1 -1
- package/esm/helpers/corePlugins.js +4 -2
- package/esm/helpers/corePlugins.js.map +1 -1
- package/esm/helpers/makeInterator.js +3 -2
- package/esm/helpers/makeInterator.js.map +1 -1
- package/esm/index.d.ts +13 -3
- package/esm/index.js +15 -5
- package/esm/index.js.map +1 -1
- package/esm/pluggableParser.d.ts +6 -2
- package/esm/pluggableParser.js +5 -5
- package/esm/pluggableParser.js.map +1 -1
- package/esm/plugin-data-table.js +4 -5
- package/esm/plugin-data-table.js.map +1 -1
- package/esm/plugin-formatting-codes.js +65 -24
- package/esm/plugin-formatting-codes.js.map +1 -1
- package/esm/plugin-set.js +15 -18
- package/esm/plugin-set.js.map +1 -1
- package/esm/plugin-tables.js +6 -1
- package/esm/plugin-tables.js.map +1 -1
- package/esm/selectors.d.ts +25 -8
- package/esm/selectors.js +398 -141
- package/esm/selectors.js.map +1 -1
- package/esm/set-assign.d.ts +17 -0
- package/esm/set-assign.js +143 -0
- package/esm/set-assign.js.map +1 -0
- package/esm/test-display.d.ts +3 -0
- package/esm/test-display.js +58 -0
- package/esm/test-display.js.map +1 -0
- package/esm/toc-caption.d.ts +7 -0
- package/esm/toc-caption.js +23 -0
- package/esm/toc-caption.js.map +1 -0
- package/esm/types.d.ts +16 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/ast-helpers.d.ts +11 -0
- package/lib/ast-helpers.js +279 -26
- package/lib/block-names.d.ts +2 -2
- package/lib/block-names.js +7 -0
- package/lib/blocks-helpers.d.ts +1 -1
- package/lib/blocks-helpers.js +3 -1
- package/lib/exportHtml.js +84 -27
- package/lib/exportMarkdown.js +111 -26
- package/lib/grammar.js +588 -454
- package/lib/guard.js +11 -1
- package/lib/helpers/blockName.d.ts +8 -0
- package/lib/helpers/blockName.js +66 -0
- package/lib/helpers/configPropagation.d.ts +12 -2
- package/lib/helpers/configPropagation.js +54 -14
- package/lib/helpers/corePlugins.d.ts +1 -1
- package/lib/helpers/corePlugins.js +4 -2
- package/lib/helpers/makeInterator.js +3 -2
- package/lib/index.d.ts +13 -3
- package/lib/index.js +30 -5
- package/lib/pluggableParser.d.ts +6 -2
- package/lib/pluggableParser.js +5 -5
- package/lib/plugin-data-table.js +4 -5
- package/lib/plugin-formatting-codes.js +65 -24
- package/lib/plugin-set.js +15 -18
- package/lib/plugin-tables.js +6 -1
- package/lib/selectors.d.ts +25 -8
- package/lib/selectors.js +401 -141
- package/lib/set-assign.d.ts +17 -0
- package/lib/set-assign.js +150 -0
- package/lib/test-display.d.ts +3 -0
- package/lib/test-display.js +67 -0
- package/lib/toc-caption.d.ts +7 -0
- package/lib/toc-caption.js +27 -0
- package/lib/types.d.ts +16 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/schema/AstTree.json +160 -0
- package/schema/PodliteDocument.json +160 -0
package/lib/plugin-set.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const isTransparent = (node) => {
|
|
6
|
-
if (!node || typeof node !== 'object')
|
|
7
|
-
return false;
|
|
8
|
-
if (node.type === 'set' || node.type === 'config' || node.type === 'alias' || node.type === 'blankline')
|
|
9
|
-
return true;
|
|
10
|
-
if (node.type === 'block' && (node.name === 'comment' || node.name === 'boundary' || node.name === 'include'))
|
|
11
|
-
return true;
|
|
12
|
-
return false;
|
|
13
|
-
};
|
|
3
|
+
const set_assign_1 = require("./set-assign");
|
|
4
|
+
const blockName_1 = require("./helpers/blockName");
|
|
14
5
|
const isBlock = (node) => node && typeof node === 'object' && node.type === 'block';
|
|
6
|
+
const isInclude = (node) => isBlock(node) && node.name === 'include';
|
|
15
7
|
// Each content array is its own lexical scope: pending attributes never leak
|
|
16
|
-
// into or out of a nested block.
|
|
17
|
-
const applyInScope = (content) => {
|
|
8
|
+
// into or out of a nested block. `holder` is the block the content belongs to.
|
|
9
|
+
const applyInScope = (content, holder) => {
|
|
18
10
|
let pending = [];
|
|
19
11
|
const out = [];
|
|
20
12
|
for (const node of content) {
|
|
@@ -29,11 +21,16 @@ const applyInScope = (content) => {
|
|
|
29
21
|
}
|
|
30
22
|
let next = node;
|
|
31
23
|
if (isBlock(node) && Array.isArray(node.content)) {
|
|
32
|
-
next = { ...node, content: applyInScope(node.content) };
|
|
24
|
+
next = { ...node, content: applyInScope(node.content, (0, blockName_1.holderInside)(node, holder)) };
|
|
25
|
+
}
|
|
26
|
+
// the target is chosen in the content the include resolves to
|
|
27
|
+
if (pending.length && isInclude(next)) {
|
|
28
|
+
next = { ...next, set: pending.map(c => ({ ...c, from: 'set' })) };
|
|
29
|
+
pending = [];
|
|
33
30
|
}
|
|
34
|
-
if (pending.length &&
|
|
31
|
+
if (pending.length && (0, set_assign_1.isSetTarget)(next, holder)) {
|
|
35
32
|
const own = new Set((next.config || []).map((c) => c && c.name));
|
|
36
|
-
const additions = pending.filter(c => !own.has(c.name));
|
|
33
|
+
const additions = pending.filter(c => !own.has(c.name)).map(c => ({ ...c, from: 'set' }));
|
|
37
34
|
if (additions.length)
|
|
38
35
|
next = { ...next, config: [...(next.config || []), ...additions] };
|
|
39
36
|
pending = [];
|
|
@@ -47,9 +44,9 @@ const applyInScope = (content) => {
|
|
|
47
44
|
};
|
|
48
45
|
exports.default = () => (tree) => {
|
|
49
46
|
if (Array.isArray(tree))
|
|
50
|
-
return applyInScope(tree);
|
|
47
|
+
return applyInScope(tree, undefined);
|
|
51
48
|
if (tree && typeof tree === 'object' && Array.isArray(tree.content)) {
|
|
52
|
-
return { ...tree, content: applyInScope(tree.content) };
|
|
49
|
+
return { ...tree, content: applyInScope(tree.content, (0, blockName_1.holderInside)(tree, undefined)) };
|
|
53
50
|
}
|
|
54
51
|
return tree;
|
|
55
52
|
};
|
package/lib/plugin-tables.js
CHANGED
|
@@ -501,6 +501,11 @@ exports.default = (opt = {}) => tree => {
|
|
|
501
501
|
// =table data:<key> → resolve =data block with :key<key>
|
|
502
502
|
// =table file:<path> → defer to host reader (not implemented here)
|
|
503
503
|
const ref = detectSourceReference(node);
|
|
504
|
+
// a file source is read by whoever renders the table; the tree holds
|
|
505
|
+
// only its address, and a reader of the tree is told so
|
|
506
|
+
if (ref && ref.scheme === 'file') {
|
|
507
|
+
report('table-source-deferred', `source file:${ref.target} is left to the renderer, the table holds no rows`, node);
|
|
508
|
+
}
|
|
504
509
|
if (ref && ref.scheme === 'data') {
|
|
505
510
|
const dataBlock = findDataBlockByKey(tree, ref.target);
|
|
506
511
|
if (!dataBlock) {
|
|
@@ -519,7 +524,7 @@ exports.default = (opt = {}) => tree => {
|
|
|
519
524
|
const text = extractDataText(dataBlock);
|
|
520
525
|
const rows = isCsv ? parseCsv(text) : parseTsv(text);
|
|
521
526
|
if (rows.length === 0) {
|
|
522
|
-
report('table-source-
|
|
527
|
+
report('table-source-empty', `${isCsv ? 'CSV' : 'TSV'} source data:${ref.target} has no rows, table rendered as empty`, node);
|
|
523
528
|
return { ...node, content: [] };
|
|
524
529
|
}
|
|
525
530
|
const hasHeader = mimeParams.header === 'present';
|
package/lib/selectors.d.ts
CHANGED
|
@@ -8,13 +8,6 @@ export type SelectorDoc = {
|
|
|
8
8
|
file: string;
|
|
9
9
|
node: PodNode | PodliteDocument;
|
|
10
10
|
};
|
|
11
|
-
export type ValueSpec = {
|
|
12
|
-
kind: 'angle';
|
|
13
|
-
value: string;
|
|
14
|
-
} | {
|
|
15
|
-
kind: 'contains';
|
|
16
|
-
value: string;
|
|
17
|
-
};
|
|
18
11
|
export type Condition = {
|
|
19
12
|
modifier?: '!' | '?' | '!?';
|
|
20
13
|
attrName: string;
|
|
@@ -30,6 +23,30 @@ export type ParsedSelector = {
|
|
|
30
23
|
anchor?: string;
|
|
31
24
|
patterns: Pattern[];
|
|
32
25
|
};
|
|
26
|
+
export type ValueSpec = {
|
|
27
|
+
kind: 'angle';
|
|
28
|
+
value: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'contains';
|
|
31
|
+
value: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'paren';
|
|
34
|
+
value: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'in';
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
33
39
|
export declare const parseSelector: (selector: string) => ParsedSelector | undefined;
|
|
40
|
+
export declare const outermost: (blocks: PodNode[]) => PodNode[];
|
|
34
41
|
export declare const filePathMatches: (docFile: string, target: string) => boolean;
|
|
35
|
-
export declare const
|
|
42
|
+
export declare const getDocIDs: (doc: SelectorDoc) => string[];
|
|
43
|
+
export declare class SelectorError extends Error {
|
|
44
|
+
readonly kind: 'resolution' | 'format' | 'address';
|
|
45
|
+
constructor(kind: 'resolution' | 'format' | 'address', message: string);
|
|
46
|
+
}
|
|
47
|
+
export type SelectorOptions = {
|
|
48
|
+
home?: SelectorDoc[];
|
|
49
|
+
readFile?: (document: string) => SelectorDoc[] | undefined;
|
|
50
|
+
readSource?: (scheme: 'file' | 'doc', document: string) => SelectorDoc[] | undefined;
|
|
51
|
+
};
|
|
52
|
+
export declare const runSelector: <T extends SelectorDoc>(selector: string, docs: T[], options?: SelectorOptions) => T[] | PodNode[];
|