@podlite/schema 0.0.83 → 0.0.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.podlite +30 -0
- package/esm/ast-inerator.js +1 -3
- package/esm/ast-inerator.js.map +1 -1
- package/esm/codes/scan.js +26 -22
- package/esm/codes/scan.js.map +1 -1
- package/esm/grammar.js +531 -416
- package/esm/grammar.js.map +1 -1
- package/esm/helpers/flatten-deep.d.ts +2 -0
- package/esm/helpers/flatten-deep.js +32 -0
- package/esm/helpers/flatten-deep.js.map +1 -0
- package/esm/helpers/itemNumbering.d.ts +2 -1
- package/esm/helpers/itemNumbering.js +3 -2
- package/esm/helpers/itemNumbering.js.map +1 -1
- package/esm/helpers/makeInterator.js +3 -6
- package/esm/helpers/makeInterator.js.map +1 -1
- package/esm/helpers/makeTransformer.js +1 -3
- package/esm/helpers/makeTransformer.js.map +1 -1
- package/esm/helpers/numberedShorthand.d.ts +2 -1
- package/esm/helpers/numberedShorthand.js +24 -4
- package/esm/helpers/numberedShorthand.js.map +1 -1
- package/esm/index.d.ts +3 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -1
- package/esm/markup-code-letters.d.ts +2 -0
- package/esm/markup-code-letters.js +65 -0
- package/esm/markup-code-letters.js.map +1 -0
- package/esm/pluggableParser.js +13 -5
- package/esm/pluggableParser.js.map +1 -1
- package/esm/plugin-defn-fill-term.js +7 -0
- package/esm/plugin-defn-fill-term.js.map +1 -1
- package/esm/plugin-group-defn.js +6 -8
- package/esm/plugin-group-defn.js.map +1 -1
- package/esm/plugin-group-items.d.ts +4 -1
- package/esm/plugin-group-items.js +43 -9
- package/esm/plugin-group-items.js.map +1 -1
- package/esm/plugin-items.js +6 -5
- package/esm/plugin-items.js.map +1 -1
- package/esm/plugin-tables.js +33 -10
- package/esm/plugin-tables.js.map +1 -1
- package/esm/types.d.ts +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/ast-inerator.js +2 -4
- package/lib/codes/scan.js +26 -22
- package/lib/grammar.js +531 -416
- package/lib/helpers/flatten-deep.d.ts +2 -0
- package/lib/helpers/flatten-deep.js +35 -0
- package/lib/helpers/itemNumbering.d.ts +2 -1
- package/lib/helpers/itemNumbering.js +5 -3
- package/lib/helpers/makeInterator.js +3 -6
- package/lib/helpers/makeTransformer.js +2 -4
- package/lib/helpers/numberedShorthand.d.ts +2 -1
- package/lib/helpers/numberedShorthand.js +26 -5
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/markup-code-letters.d.ts +2 -0
- package/lib/markup-code-letters.js +69 -0
- package/lib/pluggableParser.js +13 -5
- package/lib/plugin-defn-fill-term.js +7 -0
- package/lib/plugin-group-defn.js +6 -8
- package/lib/plugin-group-items.d.ts +4 -1
- package/lib/plugin-group-items.js +44 -12
- package/lib/plugin-items.js +5 -4
- package/lib/plugin-tables.js +37 -14
- package/lib/types.d.ts +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/schema/AstTree.json +1 -0
- package/schema/PodliteDocument.json +1 -0
|
@@ -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,3 +1,4 @@
|
|
|
1
|
-
import { PodNode, PodliteDocument } from '../types';
|
|
1
|
+
import { ConfigItem, PodNode, PodliteDocument } from '../types';
|
|
2
|
+
export declare const numberedOf: (config: ConfigItem[] | undefined) => boolean | null;
|
|
2
3
|
export declare const promoteOrderedLists: <T extends PodliteDocument | PodNode>(ast: T) => T;
|
|
3
4
|
export default promoteOrderedLists;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promoteOrderedLists = void 0;
|
|
3
|
+
exports.promoteOrderedLists = exports.numberedOf = void 0;
|
|
4
4
|
const truthy = (v) => v === true || v === 1 || v === '1' || v === 'true';
|
|
5
|
-
|
|
5
|
+
// the last numbered entry decides; false, 0, '0' and 'false' say not numbered, no entry says nothing
|
|
6
|
+
const numberedOf = (config) => {
|
|
6
7
|
if (!Array.isArray(config))
|
|
7
8
|
return null;
|
|
8
9
|
let result = null;
|
|
@@ -19,6 +20,7 @@ const isNumbered = (config) => {
|
|
|
19
20
|
}
|
|
20
21
|
return result;
|
|
21
22
|
};
|
|
23
|
+
exports.numberedOf = numberedOf;
|
|
22
24
|
const allItemsNumbered = (listNode) => {
|
|
23
25
|
if (!Array.isArray(listNode.content))
|
|
24
26
|
return false;
|
|
@@ -28,7 +30,7 @@ const allItemsNumbered = (listNode) => {
|
|
|
28
30
|
if (!c || c.type !== 'block' || c.name !== 'item')
|
|
29
31
|
continue;
|
|
30
32
|
hasAny = true;
|
|
31
|
-
if (
|
|
33
|
+
if ((0, exports.numberedOf)(c.config) !== true)
|
|
32
34
|
return false;
|
|
33
35
|
}
|
|
34
36
|
return hasAny;
|
|
@@ -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
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const isBeforeText: (child: unknown) => boolean;
|
|
2
|
+
export declare const applyNumberedShorthand: (node: any, para?: any) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyNumberedShorthand = void 0;
|
|
3
|
+
exports.applyNumberedShorthand = exports.isBeforeText = void 0;
|
|
4
4
|
const stripMarker_1 = require("./stripMarker");
|
|
5
5
|
// a single # as the whole first word asks for a numbered heading or item
|
|
6
6
|
const SHORTHAND = /^\s*#(?=\s|$)\s*/;
|
|
@@ -12,12 +12,33 @@ const firstText = para => {
|
|
|
12
12
|
return first;
|
|
13
13
|
return typeof first?.value === 'string' ? first.value : undefined;
|
|
14
14
|
};
|
|
15
|
+
const BEFORE_TEXT = ['blankline', 'config', 'alias', 'set'];
|
|
16
|
+
/*
|
|
17
|
+
=begin pod :kind<export>
|
|
18
|
+
|
|
19
|
+
=head2 isBeforeText
|
|
20
|
+
|
|
21
|
+
Whether a node of a block's content can stand before the text of the block
|
|
22
|
+
without being its text: a blank line, or a C<=config>, C<=alias> or C<=set>
|
|
23
|
+
directive. The first node of the content that is not one of these is where the
|
|
24
|
+
text of an item, a heading or a definition starts — where a leading C<#> or a
|
|
25
|
+
check box is read and where a table of contents takes the entry of an item.
|
|
26
|
+
|
|
27
|
+
=end pod
|
|
28
|
+
*/
|
|
29
|
+
const isBeforeText = (child) => {
|
|
30
|
+
const type = typeof child === 'object' && child !== null ? Reflect.get(child, 'type') : undefined;
|
|
31
|
+
return typeof type === 'string' && BEFORE_TEXT.includes(type);
|
|
32
|
+
};
|
|
33
|
+
exports.isBeforeText = isBeforeText;
|
|
15
34
|
// The shorthand counts as an option written on the block: one written there
|
|
16
35
|
// decides, one given by =set gives way, and =config comes later and skips a
|
|
17
|
-
// name the block already has.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
// name the block already has. Only the first paragraph of text can carry it;
|
|
37
|
+
// indented code in its place keeps its #.
|
|
38
|
+
const applyNumberedShorthand = (node, para = (Array.isArray(node.content) ? node.content : []).find(child => !(0, exports.isBeforeText)(child))) => {
|
|
39
|
+
if (para?.type !== 'para')
|
|
40
|
+
return;
|
|
41
|
+
const text = firstText(para);
|
|
21
42
|
if (text === undefined || !SHORTHAND.test(text))
|
|
22
43
|
return;
|
|
23
44
|
const config = Array.isArray(node.config) ? node.config : [];
|
package/lib/index.d.ts
CHANGED
|
@@ -7,12 +7,14 @@ export * from './block-names';
|
|
|
7
7
|
export { titleParts, isTitleBlock } from './title';
|
|
8
8
|
export type { TitleEntry } from './title';
|
|
9
9
|
export * from './attribute-names';
|
|
10
|
+
export * from './markup-code-letters';
|
|
10
11
|
export * from './blocks-helpers';
|
|
11
12
|
export * from './query-helpers';
|
|
12
13
|
export * from './ast-helpers';
|
|
13
14
|
export { expandAlias, ALIAS_EXPANSION_DEPTH, ALIAS_EXPANSION_BUDGET } from './helpers/alias';
|
|
14
15
|
export { MARKUP_CODE_DEPTH_LIMIT } from './codes/read';
|
|
15
16
|
export * from './helpers/handlers';
|
|
17
|
+
export { isBeforeText } from './helpers/numberedShorthand';
|
|
16
18
|
export { makeInterator } from './ast-inerator';
|
|
17
19
|
export { makeTransformer, isNamedBlock, isSemanticBlock } from './helpers/makeTransformer';
|
|
18
20
|
export { toAny } from './exportAny';
|
|
@@ -25,6 +27,7 @@ export type { LinkConfig } from './helpers/link-config';
|
|
|
25
27
|
export { pluginCleanLocation } from './plugin-clean-location';
|
|
26
28
|
export { toAnyRules } from './helpers/plugins';
|
|
27
29
|
export { podlitePluggable, Podlite, PodliteExport, cleanIds, frozenIds, headingId } from './pluggableParser';
|
|
30
|
+
export { MAX_LIST_LEVEL } from './plugin-group-items';
|
|
28
31
|
import { ConfigScope } from './helpers/configPropagation';
|
|
29
32
|
export { mergeConfigSettings, propagateConfigDefaults, walkConfigScopes } from './helpers/configPropagation';
|
|
30
33
|
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.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.isBeforeText = 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 = exports.isCovered = void 0;
|
|
44
44
|
exports.toAst = toAst;
|
|
45
45
|
exports.getTextContentFromNode = getTextContentFromNode;
|
|
46
46
|
exports.getPodContentFromNode = getPodContentFromNode;
|
|
@@ -60,6 +60,7 @@ var title_1 = require("./title");
|
|
|
60
60
|
Object.defineProperty(exports, "titleParts", { enumerable: true, get: function () { return title_1.titleParts; } });
|
|
61
61
|
Object.defineProperty(exports, "isTitleBlock", { enumerable: true, get: function () { return title_1.isTitleBlock; } });
|
|
62
62
|
__exportStar(require("./attribute-names"), exports);
|
|
63
|
+
__exportStar(require("./markup-code-letters"), exports);
|
|
63
64
|
__exportStar(require("./blocks-helpers"), exports);
|
|
64
65
|
__exportStar(require("./query-helpers"), exports);
|
|
65
66
|
__exportStar(require("./ast-helpers"), exports);
|
|
@@ -70,6 +71,8 @@ Object.defineProperty(exports, "ALIAS_EXPANSION_BUDGET", { enumerable: true, get
|
|
|
70
71
|
var read_1 = require("./codes/read");
|
|
71
72
|
Object.defineProperty(exports, "MARKUP_CODE_DEPTH_LIMIT", { enumerable: true, get: function () { return read_1.MARKUP_CODE_DEPTH_LIMIT; } });
|
|
72
73
|
__exportStar(require("./helpers/handlers"), exports);
|
|
74
|
+
var numberedShorthand_1 = require("./helpers/numberedShorthand");
|
|
75
|
+
Object.defineProperty(exports, "isBeforeText", { enumerable: true, get: function () { return numberedShorthand_1.isBeforeText; } });
|
|
73
76
|
var ast_inerator_2 = require("./ast-inerator");
|
|
74
77
|
Object.defineProperty(exports, "makeInterator", { enumerable: true, get: function () { return ast_inerator_2.makeInterator; } });
|
|
75
78
|
var makeTransformer_1 = require("./helpers/makeTransformer");
|
|
@@ -108,6 +111,8 @@ const plugin_items_1 = __importDefault(require("./plugin-items"));
|
|
|
108
111
|
const plugin_heading_1 = __importDefault(require("./plugin-heading"));
|
|
109
112
|
const plugin_group_defn_1 = __importDefault(require("./plugin-group-defn"));
|
|
110
113
|
const plugin_group_items_1 = __importDefault(require("./plugin-group-items"));
|
|
114
|
+
var plugin_group_items_2 = require("./plugin-group-items");
|
|
115
|
+
Object.defineProperty(exports, "MAX_LIST_LEVEL", { enumerable: true, get: function () { return plugin_group_items_2.MAX_LIST_LEVEL; } });
|
|
111
116
|
const plugin_defn_fill_term_1 = __importDefault(require("./plugin-defn-fill-term"));
|
|
112
117
|
const plugin_set_1 = __importDefault(require("./plugin-set"));
|
|
113
118
|
const configPropagation_1 = require("./helpers/configPropagation");
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
=begin pod :kind<module>
|
|
4
|
+
|
|
5
|
+
=TITLE The letters of markup codes
|
|
6
|
+
|
|
7
|
+
The letters the specification names markup codes by, from its table of codes.
|
|
8
|
+
The reader of codes and the checker take a letter from here rather than each
|
|
9
|
+
deciding what one is.
|
|
10
|
+
|
|
11
|
+
=end pod
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.isMarkupCodeLetter = exports.MARKUP_CODE_LETTERS = void 0;
|
|
15
|
+
/*
|
|
16
|
+
=begin pod :kind<export>
|
|
17
|
+
|
|
18
|
+
=head2 MARKUP_CODE_LETTERS
|
|
19
|
+
|
|
20
|
+
The 26 letters C<A> to C<Z>. C<Q> and C<Y> are reserved and still listed: a
|
|
21
|
+
reserved code written in a document is read as a code.
|
|
22
|
+
|
|
23
|
+
=end pod
|
|
24
|
+
*/
|
|
25
|
+
exports.MARKUP_CODE_LETTERS = [
|
|
26
|
+
'A',
|
|
27
|
+
'B',
|
|
28
|
+
'C',
|
|
29
|
+
'D',
|
|
30
|
+
'E',
|
|
31
|
+
'F',
|
|
32
|
+
'G',
|
|
33
|
+
'H',
|
|
34
|
+
'I',
|
|
35
|
+
'J',
|
|
36
|
+
'K',
|
|
37
|
+
'L',
|
|
38
|
+
'M',
|
|
39
|
+
'N',
|
|
40
|
+
'O',
|
|
41
|
+
'P',
|
|
42
|
+
'Q',
|
|
43
|
+
'R',
|
|
44
|
+
'S',
|
|
45
|
+
'T',
|
|
46
|
+
'U',
|
|
47
|
+
'V',
|
|
48
|
+
'W',
|
|
49
|
+
'X',
|
|
50
|
+
'Y',
|
|
51
|
+
'Z',
|
|
52
|
+
];
|
|
53
|
+
// the reader asks this of every character, so a letter is found without searching the list
|
|
54
|
+
const LETTERS = new Set(exports.MARKUP_CODE_LETTERS);
|
|
55
|
+
/*
|
|
56
|
+
=begin pod :kind<export>
|
|
57
|
+
|
|
58
|
+
=head2 isMarkupCodeLetter
|
|
59
|
+
|
|
60
|
+
Whether a value is one letter of a markup code: a string of exactly one
|
|
61
|
+
character from C<MARKUP_CODE_LETTERS>. C<"BI">, C<"B,I">, a lower-case letter and
|
|
62
|
+
anything not a string are not. It costs the same for every value, since the
|
|
63
|
+
reader of codes asks it of each character.
|
|
64
|
+
|
|
65
|
+
=end pod
|
|
66
|
+
*/
|
|
67
|
+
const isMarkupCodeLetter = (value) => typeof value === 'string' && value.length === 1 && LETTERS.has(value);
|
|
68
|
+
exports.isMarkupCodeLetter = isMarkupCodeLetter;
|
|
69
|
+
//# sourceMappingURL=markup-code-letters.js.map
|
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,17 +63,23 @@ 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 ||
|
|
72
77
|
other.location.end.offset !== d.location.end.offset ||
|
|
73
78
|
j < k)));
|
|
74
|
-
|
|
79
|
+
// the caller holds this array, so it is refilled in place
|
|
80
|
+
diagnostics.length = 0;
|
|
81
|
+
for (const d of innermost)
|
|
82
|
+
diagnostics.push(d);
|
|
75
83
|
const root = (0, _1.mkRootBlock)({ margin: '' }, rawTree);
|
|
76
84
|
// the parse is the one place that has the text the keys are fingerprinted from
|
|
77
85
|
(0, headingKeys_1.assignHeadingKeys)(root, text);
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
* and the remaining content is treated as the definition for the term.
|
|
10
10
|
*/
|
|
11
11
|
const makeTransformer_1 = __importDefault(require("./helpers/makeTransformer"));
|
|
12
|
+
const numberedShorthand_1 = require("./helpers/numberedShorthand");
|
|
12
13
|
exports.default = () => tree => {
|
|
13
14
|
const transformer = (0, makeTransformer_1.default)({
|
|
14
15
|
defn: node => {
|
|
@@ -18,6 +19,8 @@ exports.default = () => tree => {
|
|
|
18
19
|
const count = content.length;
|
|
19
20
|
let newContent = [];
|
|
20
21
|
let isFirstParaProcessed = false;
|
|
22
|
+
// a leading # numbers the definition only when the term is the first text of the block
|
|
23
|
+
let termComesFirst = true;
|
|
21
24
|
for (let i = 0; i < count; i++) {
|
|
22
25
|
const item = content[i];
|
|
23
26
|
if (item.type === 'para' && !isFirstParaProcessed) {
|
|
@@ -34,6 +37,8 @@ exports.default = () => tree => {
|
|
|
34
37
|
text: term,
|
|
35
38
|
content: [{ type: 'text', value: term }],
|
|
36
39
|
};
|
|
40
|
+
if (termComesFirst)
|
|
41
|
+
(0, numberedShorthand_1.applyNumberedShorthand)(node, newTermPara);
|
|
37
42
|
newContent.push(newTermPara);
|
|
38
43
|
if (!(splited.length == 1 && splited[0] === '')) {
|
|
39
44
|
textNode.value = splited.join('\n');
|
|
@@ -43,6 +48,8 @@ exports.default = () => tree => {
|
|
|
43
48
|
isFirstParaProcessed = true;
|
|
44
49
|
}
|
|
45
50
|
else {
|
|
51
|
+
if (!isFirstParaProcessed && !(0, numberedShorthand_1.isBeforeText)(item))
|
|
52
|
+
termComesFirst = false;
|
|
46
53
|
newContent.push(item);
|
|
47
54
|
}
|
|
48
55
|
}
|
package/lib/plugin-group-defn.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const itemNumbering_1 = require("./helpers/itemNumbering");
|
|
3
4
|
exports.default = () => tree => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(n1
|
|
7
|
-
|
|
8
|
-
n1['level'] === n2.level &&
|
|
9
|
-
isNumbered(n1) === isNumbered(n2);
|
|
10
|
-
const isNumbered = node => Boolean(node.config && node.config.numbered);
|
|
5
|
+
// a =config defn or =alias defn carries the name too, but it is a directive, not a definition
|
|
6
|
+
const isDefn = node => node.type === 'block' && node.name === 'defn';
|
|
7
|
+
const isNodesEqual = (n1, n2) => isDefn(n1) && isDefn(n2) && n1['level'] === n2.level && isNumbered(n1) === isNumbered(n2);
|
|
8
|
+
const isNumbered = node => (0, itemNumbering_1.numberedOf)(node.config) === true;
|
|
11
9
|
const group = a => {
|
|
12
10
|
let lastItem = {};
|
|
13
11
|
let result = a.reduce((a, i) => {
|
|
14
|
-
if (i
|
|
12
|
+
if (isDefn(i)) {
|
|
15
13
|
if (isNodesEqual(lastItem, i)) {
|
|
16
14
|
// group items into arrays
|
|
17
15
|
a[a.length - 1].push(i);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.MAX_LIST_LEVEL = void 0;
|
|
4
|
+
const itemNumbering_1 = require("./helpers/itemNumbering");
|
|
5
|
+
// lists nest no deeper than this: deeper trees overflow the stack of the renderers
|
|
6
|
+
exports.MAX_LIST_LEVEL = 50;
|
|
7
|
+
exports.default = (opt = {}) => tree => {
|
|
8
8
|
const isNodesEqual = (n1, n2) =>
|
|
9
9
|
// if nodes items
|
|
10
10
|
(n1.name === 'item' || n1.name === 'defn') &&
|
|
@@ -12,9 +12,39 @@ exports.default = () => tree => {
|
|
|
12
12
|
n1['level'] === n2.level &&
|
|
13
13
|
isNumbered(n1) === isNumbered(n2) &&
|
|
14
14
|
isChecked(n1) === isChecked(n2);
|
|
15
|
-
const isNumbered = node =>
|
|
15
|
+
const isNumbered = node => (0, itemNumbering_1.numberedOf)(node.config) === true;
|
|
16
16
|
const isChecked = node => node.checked !== undefined;
|
|
17
|
-
|
|
17
|
+
// the level a list is built at; the level the author wrote stays on the item
|
|
18
|
+
const nestAt = item => Math.min(Number(item.level), exports.MAX_LIST_LEVEL);
|
|
19
|
+
const tooDeep = item => item.name === 'item' && item.type === 'block' && Number(item.level) > exports.MAX_LIST_LEVEL;
|
|
20
|
+
const report = item => {
|
|
21
|
+
if (!Array.isArray(opt.diagnostics))
|
|
22
|
+
return;
|
|
23
|
+
opt.diagnostics.push({
|
|
24
|
+
severity: 'warning',
|
|
25
|
+
code: 'list-too-deep',
|
|
26
|
+
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}`,
|
|
27
|
+
location: item.location,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
// a list is the items of one content with nothing but blank lines between them
|
|
31
|
+
const reportDeepLists = content => {
|
|
32
|
+
let told = false;
|
|
33
|
+
content.forEach(node => {
|
|
34
|
+
if (node.type === 'blankline')
|
|
35
|
+
return;
|
|
36
|
+
if (node.name !== 'item' || node.type !== 'block')
|
|
37
|
+
told = false;
|
|
38
|
+
else if (!told && tooDeep(node)) {
|
|
39
|
+
report(node);
|
|
40
|
+
told = true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
// the content of a list is grouped again for its next level and is not told twice
|
|
45
|
+
const group = (a, level = 1, ofList = false) => {
|
|
46
|
+
if (!ofList)
|
|
47
|
+
reportDeepLists(a);
|
|
18
48
|
const isInListMode = a => {
|
|
19
49
|
return a.length > 0 && a[a.length - 1].type === 'list';
|
|
20
50
|
};
|
|
@@ -26,21 +56,23 @@ exports.default = () => tree => {
|
|
|
26
56
|
let lastItem = {};
|
|
27
57
|
let result = a.reduce((a, i) => {
|
|
28
58
|
// skip items out of level
|
|
29
|
-
if (i.name === 'item' && i.type === 'block' && i
|
|
30
|
-
|
|
59
|
+
if (i.name === 'item' && i.type === 'block' && nestAt(i) < level) {
|
|
60
|
+
a.push(i);
|
|
61
|
+
return a;
|
|
31
62
|
}
|
|
32
63
|
if (i.name === 'item' &&
|
|
33
64
|
i.type === 'block' &&
|
|
34
65
|
(!isInListMode(a) ||
|
|
35
66
|
// different type of list and item
|
|
36
67
|
// at the same level
|
|
37
|
-
|
|
68
|
+
// and an item past the limit in a list that already stands at the limit
|
|
69
|
+
((nestAt(i) === level || (tooDeep(i) && Number(getList(a).level) === exports.MAX_LIST_LEVEL)) &&
|
|
38
70
|
getList(a).list !== (isNumbered(i) ? 'ordered' : isChecked(i) ? 'task' : 'itemized')))) {
|
|
39
71
|
// create empty list
|
|
40
72
|
// list = ['ordered', 'variable', 'itemized']
|
|
41
73
|
a.push({
|
|
42
74
|
type: 'list',
|
|
43
|
-
level: i.level,
|
|
75
|
+
level: tooDeep(i) ? exports.MAX_LIST_LEVEL : i.level,
|
|
44
76
|
content: [],
|
|
45
77
|
list: isNumbered(i) ? 'ordered' : isChecked(i) ? 'task' : 'itemized',
|
|
46
78
|
});
|
|
@@ -65,7 +97,7 @@ exports.default = () => tree => {
|
|
|
65
97
|
return result.map(item => {
|
|
66
98
|
// process any item with content ( except formatting codes)
|
|
67
99
|
if (item.content && item.type !== 'fcode') {
|
|
68
|
-
item.content = group(item.content, Number(item.level || 0) + 1);
|
|
100
|
+
item.content = group(item.content, Number(item.level || 0) + 1, item.type === 'list');
|
|
69
101
|
}
|
|
70
102
|
return item;
|
|
71
103
|
});
|
package/lib/plugin-items.js
CHANGED
|
@@ -20,9 +20,10 @@ exports.default = () => tree => {
|
|
|
20
20
|
if (checkedConfig) {
|
|
21
21
|
node.checked = checkedConfig.value !== false && checkedConfig.value !== 0 && checkedConfig.value !== '0';
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
// the first text of the item, as for the # shorthand: only a paragraph carries a check box
|
|
24
|
+
const startText = node.content.find(child => !(0, numberedShorthand_1.isBeforeText)(child));
|
|
25
|
+
if (startText?.type === 'para') {
|
|
26
|
+
if (typeof startText.text === 'string' && startText.text) {
|
|
26
27
|
// Check for checkbox syntax [x] or [ ] at start of text
|
|
27
28
|
if (!checkedConfig) {
|
|
28
29
|
const checkboxRe = /^\[( |x)\]\s*/;
|
|
@@ -38,9 +39,9 @@ exports.default = () => tree => {
|
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
(0, numberedShorthand_1.applyNumberedShorthand)(node);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
(0, numberedShorthand_1.applyNumberedShorthand)(node);
|
|
44
45
|
}
|
|
45
46
|
visit(node.content);
|
|
46
47
|
}
|