@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ConfigItem } from './types';
|
|
2
|
+
import { Walked } from './helpers/blockName';
|
|
3
|
+
export declare const isSetTransparent: (node: any) => boolean;
|
|
4
|
+
export declare const isSetTarget: (node: any, holder: Walked | undefined) => boolean;
|
|
5
|
+
export declare const mergeSet: (earlier: ConfigItem[] | undefined, later: ConfigItem[] | undefined) => ConfigItem[];
|
|
6
|
+
type Copied = (from: object, to: object) => void;
|
|
7
|
+
export type SetOutcome = 'block' | 'include' | 'none';
|
|
8
|
+
export declare const applySetToFirst: (nodes: any[], set: ConfigItem[], options: {
|
|
9
|
+
mode: "include" | "carry";
|
|
10
|
+
origin?: WeakMap<object, any>;
|
|
11
|
+
onCopy?: Copied;
|
|
12
|
+
holder?: Walked;
|
|
13
|
+
}) => {
|
|
14
|
+
nodes: any[];
|
|
15
|
+
outcome: SetOutcome;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applySetToFirst = exports.mergeSet = exports.isSetTarget = exports.isSetTransparent = void 0;
|
|
4
|
+
const guard_1 = require("./guard");
|
|
5
|
+
const blockName_1 = require("./helpers/blockName");
|
|
6
|
+
// Directives and =comment blocks pass =set attributes through to the next
|
|
7
|
+
// block instead of consuming them.
|
|
8
|
+
const isSetTransparent = (node) => {
|
|
9
|
+
if (!node || typeof node !== 'object')
|
|
10
|
+
return false;
|
|
11
|
+
if (node.type === 'set' || node.type === 'config' || node.type === 'alias' || node.type === 'blankline')
|
|
12
|
+
return true;
|
|
13
|
+
if (node.type === 'block' && (node.name === 'comment' || node.name === 'boundary' || node.name === 'include'))
|
|
14
|
+
return true;
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
exports.isSetTransparent = isSetTransparent;
|
|
18
|
+
/*
|
|
19
|
+
=begin pod :kind<export>
|
|
20
|
+
|
|
21
|
+
=head2 isSetTarget
|
|
22
|
+
|
|
23
|
+
Whether C<=set> assignments stop at C<node>: a block the rule of blocks names,
|
|
24
|
+
written with a directive or a paragraph or code written without one, that is not
|
|
25
|
+
transparent to them. C<holder> is the block whose content holds the node; none
|
|
26
|
+
means the document. A wrapper the tree adds is not a target: the search goes
|
|
27
|
+
inside it.
|
|
28
|
+
|
|
29
|
+
=end pod
|
|
30
|
+
*/
|
|
31
|
+
const isSetTarget = (node, holder) => Boolean(node) && typeof node === 'object' && (0, blockName_1.blockNameOf)(node, holder) !== undefined && !(0, exports.isSetTransparent)(node);
|
|
32
|
+
exports.isSetTarget = isSetTarget;
|
|
33
|
+
// wrappers the tree adds around written blocks: the search goes inside them
|
|
34
|
+
const isWrapper = (node) => node && typeof node === 'object' && node.type === 'block' && (node.name === 'root' || node.name === '_folded_section');
|
|
35
|
+
const isInclude = (node) => node && typeof node === 'object' && node.type === 'block' && node.name === 'include';
|
|
36
|
+
/*
|
|
37
|
+
=begin pod :kind<export>
|
|
38
|
+
|
|
39
|
+
=head2 mergeSet
|
|
40
|
+
|
|
41
|
+
Joins two lists of assignments of one key-space: an item of C<later> replaces an
|
|
42
|
+
item of the same name in C<earlier>, and the order of first appearance is kept.
|
|
43
|
+
|
|
44
|
+
=end pod
|
|
45
|
+
*/
|
|
46
|
+
const mergeSet = (earlier, later) => {
|
|
47
|
+
const out = [...(earlier || [])];
|
|
48
|
+
for (const item of later || []) {
|
|
49
|
+
const at = out.findIndex(c => c.name === item.name);
|
|
50
|
+
if (at === -1)
|
|
51
|
+
out.push(item);
|
|
52
|
+
else
|
|
53
|
+
out[at] = item;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
};
|
|
57
|
+
exports.mergeSet = mergeSet;
|
|
58
|
+
// What an assignment may replace on the block it reaches: only a =config
|
|
59
|
+
// default. A =set already on the block was written nearer to it, in the file
|
|
60
|
+
// the block comes from or after the include.
|
|
61
|
+
const replaceable = (item) => item && item.from === 'config';
|
|
62
|
+
const assign = (config, set) => {
|
|
63
|
+
const out = [...(config || [])];
|
|
64
|
+
for (const item of set) {
|
|
65
|
+
const at = out.findIndex(c => c && c.name === item.name);
|
|
66
|
+
const marked = { ...item, from: 'set' };
|
|
67
|
+
if (at === -1)
|
|
68
|
+
out.push(marked);
|
|
69
|
+
else if (replaceable(out[at]))
|
|
70
|
+
out[at] = marked;
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
};
|
|
74
|
+
const deepCopy = (node, origin, onCopy) => {
|
|
75
|
+
if (Array.isArray(node))
|
|
76
|
+
return node.map(n => deepCopy(n, origin, onCopy));
|
|
77
|
+
if (!node || typeof node !== 'object')
|
|
78
|
+
return node;
|
|
79
|
+
const copy = { ...node };
|
|
80
|
+
if (node.content !== undefined)
|
|
81
|
+
copy.content = deepCopy(node.content, origin, onCopy);
|
|
82
|
+
if (node.caption !== undefined && typeof node.caption === 'object')
|
|
83
|
+
copy.caption = deepCopy(node.caption, origin, onCopy);
|
|
84
|
+
const known = origin?.get(node);
|
|
85
|
+
if (origin && known)
|
|
86
|
+
origin.set(copy, known);
|
|
87
|
+
onCopy?.(node, copy);
|
|
88
|
+
return copy;
|
|
89
|
+
};
|
|
90
|
+
/*
|
|
91
|
+
=begin pod :kind<export>
|
|
92
|
+
|
|
93
|
+
=head2 applySetToFirst
|
|
94
|
+
|
|
95
|
+
Gives C<set> to the first block of C<nodes> that is not transparent to C<=set>
|
|
96
|
+
targeting, looking inside the wrappers the tree adds (C<root>,
|
|
97
|
+
C<_folded_section>). The nodes given are not changed: the path to the target and
|
|
98
|
+
the target's subtree are copied, C<origin>, when given, is carried to the
|
|
99
|
+
copies, and C<onCopy> is told of each copy in the target's subtree. C<holder>
|
|
100
|
+
is the block whose content C<nodes> are; none means the document. An C<=include> met first, not yet resolved, takes the assignments into its
|
|
101
|
+
own C<set>, where they wait for its content; those of the same name already there
|
|
102
|
+
were written nearer to that content and stay.
|
|
103
|
+
|
|
104
|
+
An item replaces only a C<=config> default: an attribute written on the block
|
|
105
|
+
and a C<=set> already on it are kept. C<mode> names where the nodes come from,
|
|
106
|
+
the content an include brings or the block that follows an include with no
|
|
107
|
+
target; both are treated alike.
|
|
108
|
+
|
|
109
|
+
Returns the nodes and where the assignments went: C<'block'>, C<'include'> or
|
|
110
|
+
C<'none'>.
|
|
111
|
+
|
|
112
|
+
=end pod
|
|
113
|
+
*/
|
|
114
|
+
const applySetToFirst = (nodes, set, options) => {
|
|
115
|
+
const { origin, onCopy, holder } = options;
|
|
116
|
+
const out = [...nodes];
|
|
117
|
+
for (let i = 0; i < out.length; i++) {
|
|
118
|
+
const node = out[i];
|
|
119
|
+
if (!node || typeof node !== 'object')
|
|
120
|
+
continue;
|
|
121
|
+
if (isInclude(node)) {
|
|
122
|
+
out[i] = { ...node, set: (0, exports.mergeSet)(set, node.set) };
|
|
123
|
+
const known = origin?.get(node);
|
|
124
|
+
if (origin && known)
|
|
125
|
+
origin.set(out[i], known);
|
|
126
|
+
return { nodes: out, outcome: 'include' };
|
|
127
|
+
}
|
|
128
|
+
if (isWrapper(node)) {
|
|
129
|
+
const inner = Array.isArray(node.content) ? node.content : node.content ? [node.content] : [];
|
|
130
|
+
const found = (0, exports.applySetToFirst)(inner, set, { ...options, holder: (0, blockName_1.holderInside)(node, holder) });
|
|
131
|
+
if (found.outcome === 'none')
|
|
132
|
+
continue;
|
|
133
|
+
out[i] = { ...node, content: Array.isArray(node.content) ? found.nodes : found.nodes[0] };
|
|
134
|
+
const known = origin?.get(node);
|
|
135
|
+
if (origin && known)
|
|
136
|
+
origin.set(out[i], known);
|
|
137
|
+
return { nodes: out, outcome: found.outcome };
|
|
138
|
+
}
|
|
139
|
+
if (!(0, exports.isSetTarget)(node, holder))
|
|
140
|
+
continue;
|
|
141
|
+
const copy = deepCopy(node, origin, onCopy);
|
|
142
|
+
copy.config = assign(node.config, set);
|
|
143
|
+
(0, guard_1.markGuarded)(copy);
|
|
144
|
+
out[i] = copy;
|
|
145
|
+
return { nodes: out, outcome: 'block' };
|
|
146
|
+
}
|
|
147
|
+
return { nodes: out, outcome: 'none' };
|
|
148
|
+
};
|
|
149
|
+
exports.applySetToFirst = applySetToFirst;
|
|
150
|
+
//# sourceMappingURL=set-assign.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.longestBacktickRun = exports.testFoldedByAuthor = exports.testCaption = void 0;
|
|
7
|
+
const config_1 = __importDefault(require("./helpers/config"));
|
|
8
|
+
const ast_helpers_1 = require("./ast-helpers");
|
|
9
|
+
/*
|
|
10
|
+
=begin pod :kind<module>
|
|
11
|
+
|
|
12
|
+
=head2 How a test is shown
|
|
13
|
+
|
|
14
|
+
A C<=test> is shown where it stands, under the block it checks: a line naming the
|
|
15
|
+
test, and below it the fixture as source, each assertion and each resource. Every
|
|
16
|
+
renderer answers the same two questions about it, and answers them here so that a
|
|
17
|
+
page and an export never disagree.
|
|
18
|
+
|
|
19
|
+
=end pod
|
|
20
|
+
*/
|
|
21
|
+
/*
|
|
22
|
+
=begin pod :kind<export>
|
|
23
|
+
|
|
24
|
+
=head2 testCaption
|
|
25
|
+
|
|
26
|
+
The words shown on the line of a test. The caption the author wrote for the test
|
|
27
|
+
comes first; without one, its C<:id>; without either, the word C<test>, so the line
|
|
28
|
+
is never empty. The caption of an assertion is not borrowed: it says what one check
|
|
29
|
+
is for, not the whole test.
|
|
30
|
+
|
|
31
|
+
=end pod
|
|
32
|
+
*/
|
|
33
|
+
const testCaption = (node, ctx) => {
|
|
34
|
+
const conf = (0, config_1.default)(node, ctx || {});
|
|
35
|
+
if (conf.exists('caption')) {
|
|
36
|
+
const caption = String(conf.getFirstValue('caption') ?? '').trim();
|
|
37
|
+
if (caption)
|
|
38
|
+
return caption;
|
|
39
|
+
}
|
|
40
|
+
const id = (0, ast_helpers_1.getExplicitNodeId)(node, ctx || {});
|
|
41
|
+
return id ? String(id) : 'test';
|
|
42
|
+
};
|
|
43
|
+
exports.testCaption = testCaption;
|
|
44
|
+
/*
|
|
45
|
+
=begin pod :kind<export>
|
|
46
|
+
|
|
47
|
+
=head2 testFoldedByAuthor
|
|
48
|
+
|
|
49
|
+
Whether the author asked for the test to start folded: C<true> for C<:folded> or
|
|
50
|
+
C<:folded(1)>, C<false> for C<:!folded> or C<:folded(0)>, C<undefined> when the
|
|
51
|
+
author said nothing and the renderer decides. A C<=config test> line counts as
|
|
52
|
+
the author's word.
|
|
53
|
+
|
|
54
|
+
=end pod
|
|
55
|
+
*/
|
|
56
|
+
const testFoldedByAuthor = (node, ctx) => {
|
|
57
|
+
const conf = (0, config_1.default)(node, ctx || {});
|
|
58
|
+
if (!conf.exists('folded'))
|
|
59
|
+
return undefined;
|
|
60
|
+
const value = conf.getFirstValue('folded');
|
|
61
|
+
return !(value === false || value === 0 || value === '0');
|
|
62
|
+
};
|
|
63
|
+
exports.testFoldedByAuthor = testFoldedByAuthor;
|
|
64
|
+
// A fence has to be longer than any run of backticks inside what it encloses.
|
|
65
|
+
const longestBacktickRun = (text) => Math.max(0, ...(text.match(/`+/g) || []).map(run => run.length));
|
|
66
|
+
exports.longestBacktickRun = longestBacktickRun;
|
|
67
|
+
//# sourceMappingURL=test-display.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tocTitleText = void 0;
|
|
4
|
+
const guard_1 = require("./guard");
|
|
5
|
+
const handlers_1 = require("./helpers/handlers");
|
|
6
|
+
/*
|
|
7
|
+
=begin pod :kind<export>
|
|
8
|
+
|
|
9
|
+
=head2 tocTitleText
|
|
10
|
+
|
|
11
|
+
The caption of a table of contents that has only its C<title> string and no parsed
|
|
12
|
+
C<caption>: a tree built before the caption was parsed. The string is hidden as a
|
|
13
|
+
whole when the table is hidden, and also outside draft mode when it contains a
|
|
14
|
+
C<G> code, since a string cannot hide one word of itself. Returns C<undefined>
|
|
15
|
+
when the table has no caption.
|
|
16
|
+
|
|
17
|
+
=end pod
|
|
18
|
+
*/
|
|
19
|
+
const tocTitleText = (node, ctx) => {
|
|
20
|
+
if (node.title === undefined || node.title === null || String(node.title) === '')
|
|
21
|
+
return undefined;
|
|
22
|
+
const text = String(node.title);
|
|
23
|
+
const holdsGuard = /G[<«]/.test(text) && ctx?.renderMode !== 'draft';
|
|
24
|
+
return (0, guard_1.isCovered)(node, ctx) || holdsGuard ? (0, handlers_1.maskText)(text) : text;
|
|
25
|
+
};
|
|
26
|
+
exports.tocTitleText = tocTitleText;
|
|
27
|
+
//# sourceMappingURL=toc-caption.js.map
|
package/lib/types.d.ts
CHANGED
|
@@ -110,6 +110,8 @@ export interface Toc {
|
|
|
110
110
|
folded?: boolean;
|
|
111
111
|
foldedLevels?: Record<number, boolean>;
|
|
112
112
|
location?: Location;
|
|
113
|
+
caption?: BlockCaption;
|
|
114
|
+
selector?: string;
|
|
113
115
|
content: TocList;
|
|
114
116
|
}
|
|
115
117
|
export interface TocList {
|
|
@@ -145,10 +147,19 @@ export interface RootBlock extends Omit<Block, 'location'> {
|
|
|
145
147
|
}
|
|
146
148
|
export interface ParseDiagnostic {
|
|
147
149
|
severity: 'warning';
|
|
148
|
-
code: 'value-unreadable' | 'directive-unreadable' | 'table-row-cells' | 'table-cell-outside-row' | 'table-mixed-separators' | 'table-source-unreadable';
|
|
150
|
+
code: 'value-unreadable' | 'directive-unreadable' | 'table-row-cells' | 'table-cell-outside-row' | 'table-mixed-separators' | 'table-source-unreadable' | 'table-source-empty' | 'table-source-deferred';
|
|
149
151
|
message: string;
|
|
150
152
|
location: Location;
|
|
151
153
|
}
|
|
154
|
+
export type RecognitionEvent = {
|
|
155
|
+
kind: 'unknown-directive';
|
|
156
|
+
marker: 'begin' | 'for' | 'end' | 'abbreviated';
|
|
157
|
+
name: string;
|
|
158
|
+
location: Location;
|
|
159
|
+
} | {
|
|
160
|
+
kind: 'unreadable-directive';
|
|
161
|
+
location: Location;
|
|
162
|
+
};
|
|
152
163
|
export interface FormattingCodeB {
|
|
153
164
|
type: 'fcode';
|
|
154
165
|
name: 'B';
|
|
@@ -263,6 +274,7 @@ export interface Para {
|
|
|
263
274
|
text: string;
|
|
264
275
|
margin: string;
|
|
265
276
|
location: Location;
|
|
277
|
+
config?: ConfigItem[];
|
|
266
278
|
content: Array<Node | FormattingCodes>;
|
|
267
279
|
}
|
|
268
280
|
export interface ParaTerm {
|
|
@@ -276,6 +288,7 @@ export interface Code {
|
|
|
276
288
|
text: string;
|
|
277
289
|
margin: string;
|
|
278
290
|
location: Location;
|
|
291
|
+
config?: ConfigItem[];
|
|
279
292
|
content: Array<Verbatim | string>;
|
|
280
293
|
}
|
|
281
294
|
export interface BlankLine {
|
|
@@ -298,6 +311,7 @@ export interface ConfigItem {
|
|
|
298
311
|
value: boolean | string | number | Array<string | number | boolean> | ConfigItemKV;
|
|
299
312
|
type: ConfigItemType;
|
|
300
313
|
isFalse?: boolean;
|
|
314
|
+
from?: 'set' | 'config';
|
|
301
315
|
}
|
|
302
316
|
export interface BlockConfig {
|
|
303
317
|
name: string;
|
|
@@ -323,6 +337,7 @@ export interface Block {
|
|
|
323
337
|
config?: Array<ConfigItem | BrokenConfigItem>;
|
|
324
338
|
id?: string;
|
|
325
339
|
guarded?: boolean;
|
|
340
|
+
set?: ConfigItem[];
|
|
326
341
|
}
|
|
327
342
|
export interface BlockPod extends Block {
|
|
328
343
|
name: 'pod';
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.71";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED