@podlite/schema 0.0.75 → 0.0.77
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 +48 -0
- package/esm/ast-helpers.d.ts +2 -1
- package/esm/ast-helpers.js +19 -2
- package/esm/ast-helpers.js.map +1 -1
- package/esm/codes/place.d.ts +13 -0
- package/esm/codes/place.js +105 -0
- package/esm/codes/place.js.map +1 -0
- package/esm/codes/read.d.ts +20 -0
- package/esm/codes/read.js +360 -0
- package/esm/codes/read.js.map +1 -0
- package/esm/codes/scan.d.ts +40 -0
- package/esm/codes/scan.js +324 -0
- package/esm/codes/scan.js.map +1 -0
- package/esm/exportHtml.js +44 -13
- package/esm/exportHtml.js.map +1 -1
- package/esm/exportMarkdown.js +32 -9
- package/esm/exportMarkdown.js.map +1 -1
- package/esm/guard.d.ts +9 -0
- package/esm/guard.js +100 -0
- package/esm/guard.js.map +1 -1
- package/esm/helpers/blockName.d.ts +1 -0
- package/esm/helpers/blockName.js +28 -2
- package/esm/helpers/blockName.js.map +1 -1
- package/esm/helpers/configPropagation.js +3 -1
- package/esm/helpers/configPropagation.js.map +1 -1
- package/esm/helpers/handlers.d.ts +3 -0
- package/esm/helpers/handlers.js +23 -0
- package/esm/helpers/handlers.js.map +1 -1
- package/esm/helpers/headingKeys.d.ts +2 -0
- package/esm/helpers/headingKeys.js +45 -0
- package/esm/helpers/headingKeys.js.map +1 -0
- package/esm/helpers/ids.js +1 -1
- package/esm/helpers/ids.js.map +1 -1
- package/esm/helpers/numberedShorthand.d.ts +1 -0
- package/esm/helpers/numberedShorthand.js +32 -0
- package/esm/helpers/numberedShorthand.js.map +1 -0
- package/esm/helpers/stripMarker.d.ts +1 -0
- package/esm/helpers/stripMarker.js +24 -0
- package/esm/helpers/stripMarker.js.map +1 -0
- package/esm/index.d.ts +5 -4
- package/esm/index.js +6 -5
- package/esm/index.js.map +1 -1
- package/esm/pluggableParser.js +35 -4
- package/esm/pluggableParser.js.map +1 -1
- package/esm/plugin-formatting-codes.js +44 -12
- package/esm/plugin-formatting-codes.js.map +1 -1
- package/esm/plugin-heading.js +3 -11
- package/esm/plugin-heading.js.map +1 -1
- package/esm/plugin-items.js +3 -32
- package/esm/plugin-items.js.map +1 -1
- package/esm/plugin-vmargin.js +16 -3
- package/esm/plugin-vmargin.js.map +1 -1
- package/esm/selectors.d.ts +3 -2
- package/esm/selectors.js +35 -4
- package/esm/selectors.js.map +1 -1
- package/esm/types.d.ts +30 -6
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/ast-helpers.d.ts +2 -1
- package/lib/ast-helpers.js +19 -2
- package/lib/codes/place.d.ts +13 -0
- package/lib/codes/place.js +111 -0
- package/lib/codes/read.d.ts +20 -0
- package/lib/codes/read.js +364 -0
- package/lib/codes/scan.d.ts +40 -0
- package/lib/codes/scan.js +328 -0
- package/lib/exportHtml.js +43 -12
- package/lib/exportMarkdown.js +31 -8
- package/lib/guard.d.ts +9 -0
- package/lib/guard.js +104 -1
- package/lib/helpers/blockName.d.ts +1 -0
- package/lib/helpers/blockName.js +30 -3
- package/lib/helpers/configPropagation.js +3 -1
- package/lib/helpers/handlers.d.ts +3 -0
- package/lib/helpers/handlers.js +25 -1
- package/lib/helpers/headingKeys.d.ts +2 -0
- package/lib/helpers/headingKeys.js +50 -0
- package/lib/helpers/ids.js +1 -1
- package/lib/helpers/numberedShorthand.d.ts +1 -0
- package/lib/helpers/numberedShorthand.js +36 -0
- package/lib/helpers/stripMarker.d.ts +1 -0
- package/lib/helpers/stripMarker.js +28 -0
- package/lib/index.d.ts +5 -4
- package/lib/index.js +13 -3
- package/lib/pluggableParser.js +35 -4
- package/lib/plugin-formatting-codes.js +44 -45
- package/lib/plugin-heading.js +3 -11
- package/lib/plugin-items.js +4 -33
- package/lib/plugin-vmargin.js +16 -3
- package/lib/selectors.d.ts +3 -2
- package/lib/selectors.js +37 -5
- package/lib/types.d.ts +30 -6
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/schema/AstTree.json +173 -27
- package/schema/PodliteDocument.json +173 -27
- package/esm/grammarfc.d.ts +0 -14
- package/esm/grammarfc.js +0 -9824
- package/esm/grammarfc.js.map +0 -1
- package/lib/grammarfc.d.ts +0 -14
- package/lib/grammarfc.js +0 -9824
package/lib/helpers/blockName.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.holderInside = exports.blockNameOf = exports.isWrapper = void 0;
|
|
3
|
+
exports.holderInside = exports.blockNameOf = exports.isDirectiveNode = exports.isWrapper = void 0;
|
|
4
4
|
/*
|
|
5
5
|
=begin pod :kind<module>
|
|
6
6
|
|
|
@@ -24,8 +24,34 @@ const holdsImplicit = (holder) => holder === undefined ||
|
|
|
24
24
|
// Markdown section, a heading folded together with its text. No author writes
|
|
25
25
|
// them, so no pattern finds them; the walk goes through.
|
|
26
26
|
const WRAPPERS = new Set(['root', '_folded_section']);
|
|
27
|
+
/*
|
|
28
|
+
=begin pod :kind<export>
|
|
29
|
+
|
|
30
|
+
=head2 isWrapper
|
|
31
|
+
|
|
32
|
+
Whether a node is a block the tree adds around written blocks, such as the
|
|
33
|
+
document or a heading folded together with its text, rather than one an author
|
|
34
|
+
wrote.
|
|
35
|
+
|
|
36
|
+
=end pod
|
|
37
|
+
*/
|
|
27
38
|
const isWrapper = (node) => node.type === 'block' && WRAPPERS.has(node.name ?? '');
|
|
28
39
|
exports.isWrapper = isWrapper;
|
|
40
|
+
const DIRECTIVES = new Set(['boundary', 'include']);
|
|
41
|
+
/*
|
|
42
|
+
=begin pod :kind<export>
|
|
43
|
+
|
|
44
|
+
=head2 isDirectiveNode
|
|
45
|
+
|
|
46
|
+
Whether a node is a directive the tree keeps as a node of type C<block>: a
|
|
47
|
+
C<=boundary>, or an C<=include> left in a tree that was not assembled or that
|
|
48
|
+
could not be read. A directive stands between blocks and is not one, so no
|
|
49
|
+
pattern finds it.
|
|
50
|
+
|
|
51
|
+
=end pod
|
|
52
|
+
*/
|
|
53
|
+
const isDirectiveNode = (node) => node.type === 'block' && DIRECTIVES.has(node.name ?? '');
|
|
54
|
+
exports.isDirectiveNode = isDirectiveNode;
|
|
29
55
|
/*
|
|
30
56
|
=begin pod :kind<export>
|
|
31
57
|
|
|
@@ -33,7 +59,8 @@ exports.isWrapper = isWrapper;
|
|
|
33
59
|
|
|
34
60
|
The name of the block a node stands for: the name of a block written with a
|
|
35
61
|
directive, C<para> or C<code> for one written without, C<ambient> for text
|
|
36
|
-
outside any block in the default mode, none for anything
|
|
62
|
+
outside any block in the default mode, none for a directive and for anything
|
|
63
|
+
else.
|
|
37
64
|
C<holder> is the block whose content holds the node; none means the document.
|
|
38
65
|
A paragraph node is a block only where text without a marker is a paragraph:
|
|
39
66
|
inside an explicit C<=para> or a heading it is that block's own text. The term
|
|
@@ -43,7 +70,7 @@ of a C<=defn> is its heading, not a paragraph.
|
|
|
43
70
|
*/
|
|
44
71
|
const blockNameOf = (node, holder) => {
|
|
45
72
|
if (node.type === 'block')
|
|
46
|
-
return (0, exports.isWrapper)(node) ? undefined : node.name;
|
|
73
|
+
return (0, exports.isWrapper)(node) || (0, exports.isDirectiveNode)(node) ? undefined : node.name;
|
|
47
74
|
if (node.type === 'code')
|
|
48
75
|
return 'code';
|
|
49
76
|
// blank lines outside any block are not material
|
|
@@ -45,7 +45,9 @@ const walk = (node, config, holder, visit, implicit) => {
|
|
|
45
45
|
config[anyNode.name] = (0, exports.mergeConfigSettings)(anyNode.config, config[anyNode.name]);
|
|
46
46
|
}
|
|
47
47
|
else if (anyNode.type === 'block') {
|
|
48
|
-
|
|
48
|
+
// a =boundary keeps only what is written on it
|
|
49
|
+
if (anyNode.name !== 'boundary')
|
|
50
|
+
visit(anyNode, config);
|
|
49
51
|
}
|
|
50
52
|
else if (implicit) {
|
|
51
53
|
const name = (0, blockName_1.blockNameOf)(anyNode, holder);
|
|
@@ -56,3 +56,6 @@ export declare const subUse: (rules: RuleObject | Array<RuleObject>, processNode
|
|
|
56
56
|
*
|
|
57
57
|
*/
|
|
58
58
|
export declare const handleNested: (defaultHandler: RuleHandler, implicitLevel?: number) => RuleHandler;
|
|
59
|
+
export declare const expandTabs: (text: string, state?: {
|
|
60
|
+
column: number;
|
|
61
|
+
}) => string;
|
package/lib/helpers/handlers.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.handleNested = exports.subUse = exports.setContext = exports.setFn = exports.content = exports.collectText = exports.maskText = exports.emptyContent = exports.wrapContent = void 0;
|
|
6
|
+
exports.expandTabs = exports.handleNested = exports.subUse = exports.setContext = exports.setFn = exports.content = exports.collectText = exports.maskText = exports.emptyContent = exports.wrapContent = void 0;
|
|
7
7
|
const makeQuery_1 = require("./makeQuery");
|
|
8
8
|
const makeInterator_1 = __importDefault(require("./makeInterator"));
|
|
9
9
|
const config_1 = __importDefault(require("./config"));
|
|
@@ -144,4 +144,28 @@ const handleNested = (defaultHandler, implicitLevel) => {
|
|
|
144
144
|
};
|
|
145
145
|
};
|
|
146
146
|
exports.handleNested = handleNested;
|
|
147
|
+
// Inside S<> every whitespace character stays and does not break: a tab becomes the
|
|
148
|
+
// spaces up to the next tab stop, every eighth column of its line, as a code block counts
|
|
149
|
+
// them. The column is carried from one piece of text of S<> to the next by `state`, so a
|
|
150
|
+
// code inside does not move the stops after it.
|
|
151
|
+
const expandTabs = (text, state = { column: 0 }) => {
|
|
152
|
+
let out = '';
|
|
153
|
+
for (const ch of text) {
|
|
154
|
+
if (ch === '\n') {
|
|
155
|
+
state.column = 0;
|
|
156
|
+
out += ch;
|
|
157
|
+
}
|
|
158
|
+
else if (ch === '\t') {
|
|
159
|
+
const n = 8 - (state.column % 8);
|
|
160
|
+
out += ' '.repeat(n);
|
|
161
|
+
state.column += n;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
out += ch;
|
|
165
|
+
state.column++;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
};
|
|
170
|
+
exports.expandTabs = expandTabs;
|
|
147
171
|
//# sourceMappingURL=handlers.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// A heading's key is how a generated link, such as a table of contents entry, finds
|
|
3
|
+
// it again after the tree has been copied, assembled or sent through JSON. It is not
|
|
4
|
+
// taken from the heading's text: the text may hide words, and two headings may say
|
|
5
|
+
// the same thing. The key is the heading's place in the tree a parse made, with a
|
|
6
|
+
// fingerprint of the text that parse read, so trees parsed apart keep apart keys.
|
|
7
|
+
// Two parses of the same text give the same keys.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.assignHeadingKeys = exports.fingerprint = void 0;
|
|
10
|
+
// cyrb53 (bryc), seed 0, over the UTF-16 code units of the string
|
|
11
|
+
const fingerprint = (text) => {
|
|
12
|
+
let h1 = 0xdeadbeef;
|
|
13
|
+
let h2 = 0x41c6ce57;
|
|
14
|
+
for (let i = 0; i < text.length; i++) {
|
|
15
|
+
const ch = text.charCodeAt(i);
|
|
16
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
17
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
18
|
+
}
|
|
19
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
|
|
20
|
+
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
21
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
|
|
22
|
+
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
23
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16).padStart(14, '0');
|
|
24
|
+
};
|
|
25
|
+
exports.fingerprint = fingerprint;
|
|
26
|
+
// Every heading of the tree without a key gets one, in document order. A heading
|
|
27
|
+
// that already has a key keeps it, so a second call changes nothing.
|
|
28
|
+
const assignHeadingKeys = (tree, text) => {
|
|
29
|
+
const print = (0, exports.fingerprint)(text);
|
|
30
|
+
let n = 0;
|
|
31
|
+
const walk = (node) => {
|
|
32
|
+
if (Array.isArray(node)) {
|
|
33
|
+
node.forEach(walk);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!node || typeof node !== 'object')
|
|
37
|
+
return;
|
|
38
|
+
const block = node;
|
|
39
|
+
if (block.type === 'block' && block.name === 'head') {
|
|
40
|
+
n++;
|
|
41
|
+
if (typeof block.headingKey !== 'string')
|
|
42
|
+
block.headingKey = `h${n}.${print}`;
|
|
43
|
+
}
|
|
44
|
+
walk(block.content);
|
|
45
|
+
};
|
|
46
|
+
walk(tree);
|
|
47
|
+
return tree;
|
|
48
|
+
};
|
|
49
|
+
exports.assignHeadingKeys = assignHeadingKeys;
|
|
50
|
+
//# sourceMappingURL=headingKeys.js.map
|
package/lib/helpers/ids.js
CHANGED
|
@@ -65,7 +65,7 @@ const setAllLinksToAnchor = (src = { skipChain: 0, podMode: 1 }) => tree => {
|
|
|
65
65
|
if ('content' in node) {
|
|
66
66
|
node.content = visiter(node.content, ctx);
|
|
67
67
|
}
|
|
68
|
-
const { id, ...rest } = node;
|
|
68
|
+
const { id, headingRef, ...rest } = node;
|
|
69
69
|
return { ...rest, meta: '#' };
|
|
70
70
|
}
|
|
71
71
|
return node;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const applyNumberedShorthand: (node: any) => void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyNumberedShorthand = void 0;
|
|
4
|
+
const stripMarker_1 = require("./stripMarker");
|
|
5
|
+
// a single # as the whole first word asks for a numbered heading or item
|
|
6
|
+
const SHORTHAND = /^\s*#(?=\s|$)\s*/;
|
|
7
|
+
const firstText = para => {
|
|
8
|
+
if (typeof para?.text === 'string')
|
|
9
|
+
return para.text;
|
|
10
|
+
const first = Array.isArray(para?.content) ? para.content[0] : undefined;
|
|
11
|
+
if (typeof first === 'string')
|
|
12
|
+
return first;
|
|
13
|
+
return typeof first?.value === 'string' ? first.value : undefined;
|
|
14
|
+
};
|
|
15
|
+
// The shorthand counts as an option written on the block: one written there
|
|
16
|
+
// decides, one given by =set gives way, and =config comes later and skips a
|
|
17
|
+
// name the block already has.
|
|
18
|
+
const applyNumberedShorthand = node => {
|
|
19
|
+
const para = node.content[0];
|
|
20
|
+
const text = para && firstText(para);
|
|
21
|
+
if (text === undefined || !SHORTHAND.test(text))
|
|
22
|
+
return;
|
|
23
|
+
const config = Array.isArray(node.config) ? node.config : [];
|
|
24
|
+
const written = config.find(c => c && c.name === 'numbered' && c.from === undefined);
|
|
25
|
+
if (written && [false, 0, '0', 'false'].includes(written.value))
|
|
26
|
+
return;
|
|
27
|
+
(0, stripMarker_1.stripMarker)(para, SHORTHAND);
|
|
28
|
+
if (written)
|
|
29
|
+
return;
|
|
30
|
+
node.config = [
|
|
31
|
+
...config.filter(c => !(c && c.name === 'numbered')),
|
|
32
|
+
{ name: 'numbered', value: true, type: 'boolean' },
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
exports.applyNumberedShorthand = applyNumberedShorthand;
|
|
36
|
+
//# sourceMappingURL=numberedShorthand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const stripMarker: (para: any, re: RegExp) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripMarker = void 0;
|
|
4
|
+
// At this point the leading content element is still an unparsed text node;
|
|
5
|
+
// formatting codes are built from its value further down the pipeline. Cut the
|
|
6
|
+
// marker out of that value and leave the node in place: replacing the array
|
|
7
|
+
// with a plain string ends the chain early and drops every L<>, C<> and B< >
|
|
8
|
+
// written on the same line. Only a paragraph has its content cut; code keeps it.
|
|
9
|
+
const stripMarker = (para, re) => {
|
|
10
|
+
if (typeof para.text === 'string')
|
|
11
|
+
para.text = para.text.replace(re, '');
|
|
12
|
+
if (para.type !== 'para')
|
|
13
|
+
return;
|
|
14
|
+
if (!Array.isArray(para.content)) {
|
|
15
|
+
if (typeof para.text === 'string')
|
|
16
|
+
para.content = [para.text];
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const first = para.content[0];
|
|
20
|
+
if (typeof first === 'string') {
|
|
21
|
+
para.content[0] = first.replace(re, '');
|
|
22
|
+
}
|
|
23
|
+
else if (first && typeof first.value === 'string') {
|
|
24
|
+
first.value = first.value.replace(re, '');
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.stripMarker = stripMarker;
|
|
28
|
+
//# sourceMappingURL=stripMarker.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { toAny } from './exportAny';
|
|
|
15
15
|
export { makeAttrs, codeConfigWithDefaults } from './helpers/config';
|
|
16
16
|
export { parseAttributes } from './helpers/parseAttributes';
|
|
17
17
|
export { readLinkConfig } from './helpers/link-config';
|
|
18
|
+
export { assignHeadingKeys, fingerprint } from './helpers/headingKeys';
|
|
18
19
|
export { quoteAttribute } from './helpers/html-attr';
|
|
19
20
|
export type { LinkConfig } from './helpers/link-config';
|
|
20
21
|
export { pluginCleanLocation } from './plugin-clean-location';
|
|
@@ -22,7 +23,7 @@ export { toAnyRules } from './helpers/plugins';
|
|
|
22
23
|
export { podlitePluggable, Podlite, PodliteExport, cleanIds, frozenIds, headingId } from './pluggableParser';
|
|
23
24
|
import { ConfigScope } from './helpers/configPropagation';
|
|
24
25
|
export { mergeConfigSettings, propagateConfigDefaults, walkConfigScopes } from './helpers/configPropagation';
|
|
25
|
-
export { blockNameOf, holderInside } from './helpers/blockName';
|
|
26
|
+
export { blockNameOf, holderInside, isDirectiveNode, isWrapper } from './helpers/blockName';
|
|
26
27
|
export type { ConfigScope, ScopedBlock } from './helpers/configPropagation';
|
|
27
28
|
export declare function toAst(): {};
|
|
28
29
|
export type SchemaValidationError = ErrorObject<string, Record<string, any>>;
|
|
@@ -91,14 +92,14 @@ declare const parse: Function;
|
|
|
91
92
|
export { parse as parse };
|
|
92
93
|
export declare const parseFormattingCodes: (text: string, options?: {
|
|
93
94
|
[key: string]: any;
|
|
94
|
-
}) => any
|
|
95
|
+
}) => any;
|
|
95
96
|
export { default as toHtml } from './exportHtml';
|
|
96
97
|
export { default as toMarkdown } from './exportMarkdown';
|
|
97
98
|
export { default as Writer } from './writer';
|
|
98
|
-
export { parseSelector, runSelector, outermost, filePathMatches, getDocIDs, SelectorError } from './selectors';
|
|
99
|
+
export { parseSelector, readSelector, runSelector, outermost, filePathMatches, getDocIDs, SelectorError, } from './selectors';
|
|
99
100
|
export { applySetToFirst, mergeSet, isSetTransparent, isSetTarget } from './set-assign';
|
|
100
101
|
export type { SetOutcome } from './set-assign';
|
|
101
|
-
export { markGuarded, isCovered } from './guard';
|
|
102
|
+
export { markGuarded, isCovered, guardedTextLeaves, getMaskedTextContent, renderCodeText } from './guard';
|
|
102
103
|
export { applyFoldedSections } from './folded-sections';
|
|
103
104
|
export { testCaption, testFoldedByAuthor } from './test-display';
|
|
104
105
|
export { tocTitleText } from './toc-caption';
|
package/lib/index.js
CHANGED
|
@@ -39,7 +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.
|
|
42
|
+
exports.tocTitleText = exports.testFoldedByAuthor = exports.testCaption = exports.applyFoldedSections = exports.renderCodeText = exports.getMaskedTextContent = exports.guardedTextLeaves = 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.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 = void 0;
|
|
43
|
+
exports.version = exports.applyImageBase = void 0;
|
|
43
44
|
exports.toAst = toAst;
|
|
44
45
|
exports.getTextContentFromNode = getTextContentFromNode;
|
|
45
46
|
exports.getPodContentFromNode = getPodContentFromNode;
|
|
@@ -75,6 +76,9 @@ var parseAttributes_1 = require("./helpers/parseAttributes");
|
|
|
75
76
|
Object.defineProperty(exports, "parseAttributes", { enumerable: true, get: function () { return parseAttributes_1.parseAttributes; } });
|
|
76
77
|
var link_config_1 = require("./helpers/link-config");
|
|
77
78
|
Object.defineProperty(exports, "readLinkConfig", { enumerable: true, get: function () { return link_config_1.readLinkConfig; } });
|
|
79
|
+
var headingKeys_1 = require("./helpers/headingKeys");
|
|
80
|
+
Object.defineProperty(exports, "assignHeadingKeys", { enumerable: true, get: function () { return headingKeys_1.assignHeadingKeys; } });
|
|
81
|
+
Object.defineProperty(exports, "fingerprint", { enumerable: true, get: function () { return headingKeys_1.fingerprint; } });
|
|
78
82
|
var html_attr_1 = require("./helpers/html-attr");
|
|
79
83
|
Object.defineProperty(exports, "quoteAttribute", { enumerable: true, get: function () { return html_attr_1.quoteAttribute; } });
|
|
80
84
|
var plugin_clean_location_1 = require("./plugin-clean-location");
|
|
@@ -87,7 +91,7 @@ Object.defineProperty(exports, "cleanIds", { enumerable: true, get: function ()
|
|
|
87
91
|
Object.defineProperty(exports, "frozenIds", { enumerable: true, get: function () { return pluggableParser_1.frozenIds; } });
|
|
88
92
|
Object.defineProperty(exports, "headingId", { enumerable: true, get: function () { return pluggableParser_1.headingId; } });
|
|
89
93
|
const parser = __importStar(require("./grammar"));
|
|
90
|
-
const
|
|
94
|
+
const read_1 = require("./codes/read");
|
|
91
95
|
const parseAttributes_2 = require("./helpers/parseAttributes");
|
|
92
96
|
const plugin_vmargin_1 = __importDefault(require("./plugin-vmargin"));
|
|
93
97
|
const plugin_formatting_codes_1 = __importDefault(require("./plugin-formatting-codes"));
|
|
@@ -105,6 +109,8 @@ Object.defineProperty(exports, "walkConfigScopes", { enumerable: true, get: func
|
|
|
105
109
|
var blockName_1 = require("./helpers/blockName");
|
|
106
110
|
Object.defineProperty(exports, "blockNameOf", { enumerable: true, get: function () { return blockName_1.blockNameOf; } });
|
|
107
111
|
Object.defineProperty(exports, "holderInside", { enumerable: true, get: function () { return blockName_1.holderInside; } });
|
|
112
|
+
Object.defineProperty(exports, "isDirectiveNode", { enumerable: true, get: function () { return blockName_1.isDirectiveNode; } });
|
|
113
|
+
Object.defineProperty(exports, "isWrapper", { enumerable: true, get: function () { return blockName_1.isWrapper; } });
|
|
108
114
|
const plugin_tables_1 = __importDefault(require("./plugin-tables"));
|
|
109
115
|
const plugin_data_table_1 = __importDefault(require("./plugin-data-table"));
|
|
110
116
|
function toAst() {
|
|
@@ -233,7 +239,7 @@ function makeTree() {
|
|
|
233
239
|
}
|
|
234
240
|
const parse = makeTree().parse;
|
|
235
241
|
exports.parse = parse;
|
|
236
|
-
const parseFormattingCodes = (text, options = {}) => (0,
|
|
242
|
+
const parseFormattingCodes = (text, options = {}) => (0, read_1.readCodes)(text, { parseAttributes: parseAttributes_2.parseAttributes, ...options });
|
|
237
243
|
exports.parseFormattingCodes = parseFormattingCodes;
|
|
238
244
|
var exportHtml_1 = require("./exportHtml");
|
|
239
245
|
Object.defineProperty(exports, "toHtml", { enumerable: true, get: function () { return __importDefault(exportHtml_1).default; } });
|
|
@@ -243,6 +249,7 @@ var writer_1 = require("./writer");
|
|
|
243
249
|
Object.defineProperty(exports, "Writer", { enumerable: true, get: function () { return __importDefault(writer_1).default; } });
|
|
244
250
|
var selectors_1 = require("./selectors");
|
|
245
251
|
Object.defineProperty(exports, "parseSelector", { enumerable: true, get: function () { return selectors_1.parseSelector; } });
|
|
252
|
+
Object.defineProperty(exports, "readSelector", { enumerable: true, get: function () { return selectors_1.readSelector; } });
|
|
246
253
|
Object.defineProperty(exports, "runSelector", { enumerable: true, get: function () { return selectors_1.runSelector; } });
|
|
247
254
|
Object.defineProperty(exports, "outermost", { enumerable: true, get: function () { return selectors_1.outermost; } });
|
|
248
255
|
Object.defineProperty(exports, "filePathMatches", { enumerable: true, get: function () { return selectors_1.filePathMatches; } });
|
|
@@ -256,6 +263,9 @@ Object.defineProperty(exports, "isSetTarget", { enumerable: true, get: function
|
|
|
256
263
|
var guard_1 = require("./guard");
|
|
257
264
|
Object.defineProperty(exports, "markGuarded", { enumerable: true, get: function () { return guard_1.markGuarded; } });
|
|
258
265
|
Object.defineProperty(exports, "isCovered", { enumerable: true, get: function () { return guard_1.isCovered; } });
|
|
266
|
+
Object.defineProperty(exports, "guardedTextLeaves", { enumerable: true, get: function () { return guard_1.guardedTextLeaves; } });
|
|
267
|
+
Object.defineProperty(exports, "getMaskedTextContent", { enumerable: true, get: function () { return guard_1.getMaskedTextContent; } });
|
|
268
|
+
Object.defineProperty(exports, "renderCodeText", { enumerable: true, get: function () { return guard_1.renderCodeText; } });
|
|
259
269
|
var folded_sections_1 = require("./folded-sections");
|
|
260
270
|
Object.defineProperty(exports, "applyFoldedSections", { enumerable: true, get: function () { return folded_sections_1.applyFoldedSections; } });
|
|
261
271
|
var test_display_1 = require("./test-display");
|
package/lib/pluggableParser.js
CHANGED
|
@@ -13,6 +13,8 @@ const headingNumbering_1 = require("./helpers/headingNumbering");
|
|
|
13
13
|
const itemNumbering_1 = require("./helpers/itemNumbering");
|
|
14
14
|
const guard_1 = require("./guard");
|
|
15
15
|
const folded_sections_1 = require("./folded-sections");
|
|
16
|
+
const headingKeys_1 = require("./helpers/headingKeys");
|
|
17
|
+
const place_1 = require("./codes/place");
|
|
16
18
|
var ids_2 = require("./helpers/ids");
|
|
17
19
|
Object.defineProperty(exports, "cleanIds", { enumerable: true, get: function () { return ids_2.cleanIds; } });
|
|
18
20
|
Object.defineProperty(exports, "frozenIds", { enumerable: true, get: function () { return ids_2.frozenIds; } });
|
|
@@ -37,13 +39,42 @@ const podlitePluggable = ({ plugins = {} } = {}) => {
|
|
|
37
39
|
const rawTree = (0, _1.toTree)()
|
|
38
40
|
.use(ids_1.default)
|
|
39
41
|
.parse(text, { ...opt, diagnostics });
|
|
42
|
+
// a warning about a markup code knows its place in the text it was read from;
|
|
43
|
+
// the source turns that into a place a reader can go to
|
|
44
|
+
const placed = new Set();
|
|
45
|
+
let starts = null;
|
|
46
|
+
for (let k = 0; k < diagnostics.length; k++) {
|
|
47
|
+
const d = diagnostics[k];
|
|
48
|
+
if (!d.pending)
|
|
49
|
+
continue;
|
|
50
|
+
starts = starts || (0, place_1.lineStarts)(text);
|
|
51
|
+
d.location = (0, place_1.placeInSource)(text, d.location, d.pending, starts);
|
|
52
|
+
// the same text read twice reports one warning for one place; two pieces of text
|
|
53
|
+
// placed at the same point, such as cells of one row, keep their warnings apart
|
|
54
|
+
const key = `${d.code}@${d.location.start.offset}@${d.pending.start}@${d.pending.fragment.text}`;
|
|
55
|
+
delete d.pending;
|
|
56
|
+
if (placed.has(key))
|
|
57
|
+
diagnostics.splice(k--, 1);
|
|
58
|
+
else
|
|
59
|
+
placed.add(key);
|
|
60
|
+
}
|
|
40
61
|
// one mistake inside a value reports twice: for the value and for the whole
|
|
41
|
-
// attribute around it. The narrower report names the place to fix
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
// attribute around it. The narrower report names the place to fix. Two reports of
|
|
63
|
+
// one place keep the first; a warning about a markup code is about the code, not
|
|
64
|
+
// a value, and stays
|
|
65
|
+
const isCodeWarning = (d) => d.code.startsWith('markup-code-');
|
|
66
|
+
const innermost = diagnostics.filter((d, k) => isCodeWarning(d) ||
|
|
67
|
+
!diagnostics.some((other, j) => other !== d &&
|
|
68
|
+
!isCodeWarning(other) &&
|
|
69
|
+
other.location.start.offset >= d.location.start.offset &&
|
|
70
|
+
other.location.end.offset <= d.location.end.offset &&
|
|
71
|
+
(other.location.start.offset !== d.location.start.offset ||
|
|
72
|
+
other.location.end.offset !== d.location.end.offset ||
|
|
73
|
+
j < k)));
|
|
45
74
|
diagnostics.splice(0, diagnostics.length, ...innermost);
|
|
46
75
|
const root = (0, _1.mkRootBlock)({ margin: '' }, rawTree);
|
|
76
|
+
// the parse is the one place that has the text the keys are fingerprinted from
|
|
77
|
+
(0, headingKeys_1.assignHeadingKeys)(root, text);
|
|
47
78
|
return diagnostics.length ? { ...root, diagnostics } : root;
|
|
48
79
|
};
|
|
49
80
|
instance.toAst = (ast, opt) => {
|
|
@@ -1,42 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const
|
|
6
|
+
const read_1 = require("./codes/read");
|
|
7
|
+
const place_1 = require("./codes/place");
|
|
40
8
|
const makeTransformer_1 = __importDefault(require("./helpers/makeTransformer"));
|
|
41
9
|
const makeTransformer_2 = require("./helpers/makeTransformer");
|
|
42
10
|
const config_1 = __importDefault(require("./helpers/config"));
|
|
@@ -70,17 +38,33 @@ const allowOf = (node) => {
|
|
|
70
38
|
return conf.exists('allow') ? conf.getAllValues('allow') : undefined;
|
|
71
39
|
};
|
|
72
40
|
const middle = opt => tree => {
|
|
41
|
+
// the codes of one piece of text; a warning keeps the block it came from and its
|
|
42
|
+
// place in the text, and the parser turns that into a place in the source
|
|
43
|
+
const read = (text, allowed, allowedIn, block, inline = false) => {
|
|
44
|
+
const issues = [];
|
|
45
|
+
const content = (0, read_1.readCodes)(text, { allowed, allowedIn, parseAttributes: parseAttributes_1.parseAttributes, issues });
|
|
46
|
+
const location = block && block.location;
|
|
47
|
+
const fragment = { text, inline };
|
|
48
|
+
if (inline && block && block.location)
|
|
49
|
+
(0, place_1.registerInline)(block.location, fragment);
|
|
50
|
+
if (Array.isArray(opt.diagnostics) && location)
|
|
51
|
+
for (const issue of issues)
|
|
52
|
+
opt.diagnostics.push({
|
|
53
|
+
severity: 'warning',
|
|
54
|
+
code: issue.code,
|
|
55
|
+
message: issue.message,
|
|
56
|
+
location,
|
|
57
|
+
pending: { fragment, start: issue.start, end: issue.end },
|
|
58
|
+
});
|
|
59
|
+
return content;
|
|
60
|
+
};
|
|
73
61
|
const transformerBlocks = (0, makeTransformer_1.default)({
|
|
74
62
|
':para': (n, ctx, visiter) => {
|
|
75
63
|
const allowedIn = ctx.allowedIn;
|
|
76
64
|
const allowed = allowOf(n);
|
|
77
65
|
return (0, makeTransformer_1.default)({
|
|
78
|
-
':text': (
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
':verbatim': (n, ctx) => {
|
|
82
|
-
return fcparser.parse(n.value, { allowed, allowedIn, parseAttributes: parseAttributes_1.parseAttributes });
|
|
83
|
-
},
|
|
66
|
+
':text': (node, ctx) => read(node.value, allowed, allowedIn, n),
|
|
67
|
+
':verbatim': (node, ctx) => read(node.value, allowed, allowedIn, n),
|
|
84
68
|
})(n, { ...ctx });
|
|
85
69
|
return n;
|
|
86
70
|
},
|
|
@@ -91,7 +75,7 @@ const middle = opt => tree => {
|
|
|
91
75
|
return n;
|
|
92
76
|
const allowedIn = ctx.allowedIn;
|
|
93
77
|
return (0, makeTransformer_1.default)({
|
|
94
|
-
':verbatim': (node) =>
|
|
78
|
+
':verbatim': (node) => read(node.value, allowed, allowedIn, n),
|
|
95
79
|
})(n, { ...ctx });
|
|
96
80
|
},
|
|
97
81
|
':config': (n, ctx) => {
|
|
@@ -136,18 +120,33 @@ const middle = opt => tree => {
|
|
|
136
120
|
// their turn, since a cell may declare a set of its own
|
|
137
121
|
const literal = inheritsAllow && declared !== undefined && declared.length === 0;
|
|
138
122
|
const allowed = [...allowValues].sort();
|
|
139
|
-
|
|
123
|
+
// a warning about text with no place of its own, such as a table cell, points at this block
|
|
124
|
+
const inner = {
|
|
125
|
+
...ctx,
|
|
126
|
+
allowedIn,
|
|
127
|
+
allowFromTable: passesAllow,
|
|
128
|
+
block: n.location ? n : ctx.block,
|
|
129
|
+
inline: !n.location,
|
|
130
|
+
};
|
|
140
131
|
// code written without a marker is verbatim unless its own :allow names codes
|
|
141
132
|
const ownCode = (node, ctx) => transformerBlocks(node, { ...ctx, allowedIn });
|
|
142
133
|
// a paragraph written without a marker reads codes as an explicit =para does;
|
|
143
134
|
// the own text of a block, a term among them, and the text of a cell read the
|
|
144
135
|
// codes of the block they belong to
|
|
145
136
|
const ownPara = (node, ctx) => (0, blockName_1.blockNameOf)(node, n) !== 'para' || (inheritsAllow && allowOf(node) === undefined)
|
|
146
|
-
? {
|
|
137
|
+
? {
|
|
138
|
+
...node,
|
|
139
|
+
// text held by a node with no place of its own, such as a cell, stands inside a line
|
|
140
|
+
content: transformer(node.content, {
|
|
141
|
+
...ctx,
|
|
142
|
+
block: node.location ? node : ctx.block,
|
|
143
|
+
inline: !node.location,
|
|
144
|
+
}),
|
|
145
|
+
}
|
|
147
146
|
: transformerBlocks(node, { ...ctx, allowedIn });
|
|
148
147
|
const transformer = (0, makeTransformer_1.default)({
|
|
149
|
-
':verbatim': (node, ctx) => literal ? node :
|
|
150
|
-
':text': (node, ctx) => literal ? node :
|
|
148
|
+
':verbatim': (node, ctx) => literal ? node : read(node.value, allowed, allowedIn, ctx.block || n, Boolean(ctx.inline)),
|
|
149
|
+
':text': (node, ctx) => literal ? node : read(node.value, allowed, allowedIn, ctx.block || n, Boolean(ctx.inline)),
|
|
151
150
|
':para': ownPara,
|
|
152
151
|
':code': ownCode,
|
|
153
152
|
':config': (node, ctx) => {
|
package/lib/plugin-heading.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const numberedShorthand_1 = require("./helpers/numberedShorthand");
|
|
3
4
|
exports.default = () => tree => {
|
|
4
5
|
const visit = node => {
|
|
5
6
|
if (Array.isArray(node)) {
|
|
@@ -13,17 +14,8 @@ exports.default = () => tree => {
|
|
|
13
14
|
if (matchHead) {
|
|
14
15
|
node.name = 'head';
|
|
15
16
|
node.level = matchHead[1] || 1;
|
|
16
|
-
if (node.content[0])
|
|
17
|
-
|
|
18
|
-
if (startText.text) {
|
|
19
|
-
let re = /(\s*#\s*)/;
|
|
20
|
-
const match = re.exec(startText.text);
|
|
21
|
-
if (match) {
|
|
22
|
-
startText.text = startText.text.replace(re, '');
|
|
23
|
-
node.config = { ...node.config, ...{ numbered: true } };
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
17
|
+
if (node.content[0])
|
|
18
|
+
(0, numberedShorthand_1.applyNumberedShorthand)(node);
|
|
27
19
|
}
|
|
28
20
|
visit(node.content);
|
|
29
21
|
}
|
package/lib/plugin-items.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// marker out of that value and leave the node in place — replacing the array
|
|
6
|
-
// with a plain string ends the chain early and drops every L<>, C<> and B< >
|
|
7
|
-
// written on the same line.
|
|
8
|
-
const stripMarker = (para, re) => {
|
|
9
|
-
para.text = para.text.replace(re, '');
|
|
10
|
-
if (para.type !== 'para')
|
|
11
|
-
return;
|
|
12
|
-
if (!Array.isArray(para.content)) {
|
|
13
|
-
para.content = [para.text];
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const first = para.content[0];
|
|
17
|
-
if (typeof first === 'string') {
|
|
18
|
-
para.content[0] = first.replace(re, '');
|
|
19
|
-
}
|
|
20
|
-
else if (first && typeof first.value === 'string') {
|
|
21
|
-
first.value = first.value.replace(re, '');
|
|
22
|
-
}
|
|
23
|
-
};
|
|
3
|
+
const numberedShorthand_1 = require("./helpers/numberedShorthand");
|
|
4
|
+
const stripMarker_1 = require("./helpers/stripMarker");
|
|
24
5
|
exports.default = () => tree => {
|
|
25
6
|
const visit = node => {
|
|
26
7
|
if (Array.isArray(node)) {
|
|
@@ -48,7 +29,7 @@ exports.default = () => tree => {
|
|
|
48
29
|
const checkboxMatch = checkboxRe.exec(startText.text);
|
|
49
30
|
if (checkboxMatch) {
|
|
50
31
|
node.checked = checkboxMatch[1] === 'x';
|
|
51
|
-
stripMarker(startText, checkboxRe);
|
|
32
|
+
(0, stripMarker_1.stripMarker)(startText, checkboxRe);
|
|
52
33
|
node.config = node.config || [];
|
|
53
34
|
node.config.push({
|
|
54
35
|
name: 'checked',
|
|
@@ -57,17 +38,7 @@ exports.default = () => tree => {
|
|
|
57
38
|
});
|
|
58
39
|
}
|
|
59
40
|
}
|
|
60
|
-
|
|
61
|
-
const match = re.exec(startText.text);
|
|
62
|
-
if (match) {
|
|
63
|
-
stripMarker(startText, re);
|
|
64
|
-
node.config = node.config || [];
|
|
65
|
-
node.config.push({
|
|
66
|
-
name: 'numbered',
|
|
67
|
-
value: true,
|
|
68
|
-
type: 'boolean',
|
|
69
|
-
});
|
|
70
|
-
}
|
|
41
|
+
(0, numberedShorthand_1.applyNumberedShorthand)(node);
|
|
71
42
|
}
|
|
72
43
|
}
|
|
73
44
|
}
|