@podlite/schema 0.0.14 → 0.0.16
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.md +4 -0
- package/esm/ast-helpers.d.ts +2 -0
- package/esm/ast-helpers.js +10 -0
- package/esm/ast-helpers.js.map +1 -0
- package/esm/ast-inerator.d.ts +6 -0
- package/esm/ast-inerator.js +57 -0
- package/esm/ast-inerator.js.map +1 -0
- package/esm/blocks-helpers.d.ts +32 -0
- package/esm/blocks-helpers.js +65 -0
- package/esm/blocks-helpers.js.map +1 -0
- package/esm/exportAny.d.ts +19 -0
- package/esm/exportAny.js +65 -0
- package/esm/exportAny.js.map +1 -0
- package/esm/exportHtml.d.ts +15 -0
- package/esm/exportHtml.js +279 -0
- package/esm/exportHtml.js.map +1 -0
- package/esm/grammar.d.ts +14 -0
- package/esm/grammar.js +6405 -0
- package/esm/grammar.js.map +1 -0
- package/esm/grammarfc.d.ts +14 -0
- package/esm/grammarfc.js +4218 -0
- package/esm/grammarfc.js.map +1 -0
- package/esm/helpers/config.d.ts +12 -0
- package/esm/helpers/config.js +52 -0
- package/esm/helpers/config.js.map +1 -0
- package/esm/helpers/corePlugins.d.ts +12 -0
- package/esm/helpers/corePlugins.js +23 -0
- package/esm/helpers/corePlugins.js.map +1 -0
- package/esm/helpers/handlers.d.ts +47 -0
- package/esm/helpers/handlers.js +107 -0
- package/esm/helpers/handlers.js.map +1 -0
- package/esm/helpers/ids.d.ts +18 -0
- package/esm/helpers/ids.js +69 -0
- package/esm/helpers/ids.js.map +1 -0
- package/esm/helpers/makeInterator.d.ts +5 -0
- package/esm/helpers/makeInterator.js +52 -0
- package/esm/helpers/makeInterator.js.map +1 -0
- package/esm/helpers/makeQuery.d.ts +47 -0
- package/esm/helpers/makeQuery.js +100 -0
- package/esm/helpers/makeQuery.js.map +1 -0
- package/esm/helpers/makeQuery.test.d.ts +1 -0
- package/esm/helpers/makeQuery.test.js +51 -0
- package/esm/helpers/makeQuery.test.js.map +1 -0
- package/esm/helpers/makeTransformer.d.ts +7 -0
- package/esm/helpers/makeTransformer.js +61 -0
- package/esm/helpers/makeTransformer.js.map +1 -0
- package/esm/helpers/plugins.d.ts +2 -0
- package/esm/helpers/plugins.js +23 -0
- package/esm/helpers/plugins.js.map +1 -0
- package/esm/index.d.ts +82 -0
- package/esm/index.js +123 -0
- package/esm/index.js.map +1 -0
- package/esm/pluggableParser.d.ts +27 -0
- package/esm/pluggableParser.js +71 -0
- package/esm/pluggableParser.js.map +1 -0
- package/esm/plugin-clean-location.d.ts +2 -0
- package/esm/plugin-clean-location.js +19 -0
- package/esm/plugin-clean-location.js.map +1 -0
- package/esm/plugin-defn-fill-term.d.ts +2 -0
- package/esm/plugin-defn-fill-term.js +50 -0
- package/esm/plugin-defn-fill-term.js.map +1 -0
- package/esm/plugin-formatting-codes.d.ts +3 -0
- package/esm/plugin-formatting-codes.js +54 -0
- package/esm/plugin-formatting-codes.js.map +1 -0
- package/esm/plugin-group-defn.d.ts +2 -0
- package/esm/plugin-group-defn.js +71 -0
- package/esm/plugin-group-defn.js.map +1 -0
- package/esm/plugin-group-items.d.ts +2 -0
- package/esm/plugin-group-items.js +79 -0
- package/esm/plugin-group-items.js.map +1 -0
- package/esm/plugin-heading.d.ts +2 -0
- package/esm/plugin-heading.js +33 -0
- package/esm/plugin-heading.js.map +1 -0
- package/esm/plugin-items.d.ts +2 -0
- package/esm/plugin-items.js +41 -0
- package/esm/plugin-items.js.map +1 -0
- package/esm/plugin-tables.d.ts +5 -0
- package/esm/plugin-tables.js +141 -0
- package/esm/plugin-tables.js.map +1 -0
- package/esm/plugin-vmargin.d.ts +3 -0
- package/esm/plugin-vmargin.js +29 -0
- package/esm/plugin-vmargin.js.map +1 -0
- package/esm/query-helpers.d.ts +28 -0
- package/esm/query-helpers.js +131 -0
- package/esm/query-helpers.js.map +1 -0
- package/esm/types.d.ts +357 -0
- package/esm/types.js +2 -0
- package/esm/types.js.map +1 -0
- package/esm/writer.d.ts +30 -0
- package/esm/writer.js +85 -0
- package/esm/writer.js.map +1 -0
- package/esm/writerHtml.d.ts +11 -0
- package/esm/writerHtml.js +29 -0
- package/esm/writerHtml.js.map +1 -0
- package/lib/grammar.js +4 -3
- package/lib/plugin-formatting-codes.js +2 -1
- package/lib/types.d.ts +16 -1
- package/package.json +9 -7
- package/schema/AstTree.json +71 -0
- package/schema/PodliteDocument.json +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-tables.js","sourceRoot":"","sources":["../src/plugin-tables.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,eAAe,MAAM,2BAA2B,CAAA;AACvD,SAAS,WAAW,CAAC,GAAG;IACtB,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC5G,CAAC;AACD;;GAEG;AAEH,yBAAyB;AACzB,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;IAChC,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACpC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;KAC3D;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACrB,CAAC,CAAA;A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{
|
|
3
|
+
// if( (node.type || "").match(/(code|text)/) ) {
|
|
4
|
+
if (node.type == 'code' || node.type == 'text') {
|
|
5
|
+
if (node.margin && context.margin && context.margin.length > 0 && context.margin.length == node.margin.length) {
|
|
6
|
+
;
|
|
7
|
+
node.type = 'para';
|
|
8
|
+
}
|
|
9
|
+
if (node.type === 'code') {
|
|
10
|
+
// remove parent margin
|
|
11
|
+
var regex = new RegExp(`^[ \t]{0,${node.margin.length}}`, 'gm');
|
|
12
|
+
node.text = node.text.replace(regex, '');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (node.type === 'block') {
|
|
16
|
+
context.margin = typeof node.margin !== 'string' ? '' : node.margin;
|
|
17
|
+
let newctx = { ...context };
|
|
18
|
+
newctx.nest = (newctx.nest || 0) + 1;
|
|
19
|
+
node.content.map(n => {
|
|
20
|
+
visit_node(n, context);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var ctx = {};
|
|
25
|
+
tree.forEach(n => visit_node(n, ctx));
|
|
26
|
+
return tree;
|
|
27
|
+
};
|
|
28
|
+
export default middle;
|
|
29
|
+
//# sourceMappingURL=plugin-vmargin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-vmargin.js","sourceRoot":"","sources":["../src/plugin-vmargin.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAiB,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE;IACxC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAE,UAA2C,EAAE,EAAE,EAAE;QAC/E,iDAAiD;QACjD,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM,EAAE;YAC9C,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBAC7G,CAAC;gBAAC,IAAY,CAAC,IAAI,GAAG,MAAM,CAAA;aAC7B;YACD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;gBACxB,uBAAuB;gBACvB,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,IAAI,CAAC,CAAA;gBAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;aACzC;SACF;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;YACzB,OAAO,CAAC,MAAM,GAAG,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA;YACnE,IAAI,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,CAAA;YAC3B,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;YACpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBACnB,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;YACxB,CAAC,CAAC,CAAA;SACH;IACH,CAAC,CAAA;IACD,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;IACrC,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AACD,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PodNode } from './types';
|
|
2
|
+
declare type Query = ((par: Object) => Boolean) | any;
|
|
3
|
+
/**
|
|
4
|
+
* compileQuery - compile a query to a function
|
|
5
|
+
|
|
6
|
+
Object as a parameter:
|
|
7
|
+
{'name':'head', level:[1,2,3,4]}
|
|
8
|
+
|
|
9
|
+
const checkObject = compileQuery({name:'head',level:2}, (item)=>item.name === 1);
|
|
10
|
+
|
|
11
|
+
Function as a parameter:
|
|
12
|
+
(item)=>item.name === 1
|
|
13
|
+
const checkObject2 = compileQuery((i)=>i.name == '1')
|
|
14
|
+
|
|
15
|
+
const r = checkObject([{name:'head', level:1},{name:'head', level:2},{name:'head', level:2}, {name:1, level:2}])
|
|
16
|
+
*
|
|
17
|
+
* @param obj
|
|
18
|
+
* @returns function that can be used to filter the objects
|
|
19
|
+
*/
|
|
20
|
+
export declare const compileQuery: (...obj: Query[]) => (any: any) => any;
|
|
21
|
+
/**
|
|
22
|
+
* Get nodes by queries
|
|
23
|
+
* @param tree
|
|
24
|
+
* @param queries
|
|
25
|
+
* @returns array of matched nodes
|
|
26
|
+
*/
|
|
27
|
+
export declare const getFromTree: (tree: any, ...queries: string[] | any) => PodNode[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { makeTransformer } from './';
|
|
2
|
+
/**
|
|
3
|
+
* compileQuery - compile a query to a function
|
|
4
|
+
|
|
5
|
+
Object as a parameter:
|
|
6
|
+
{'name':'head', level:[1,2,3,4]}
|
|
7
|
+
|
|
8
|
+
const checkObject = compileQuery({name:'head',level:2}, (item)=>item.name === 1);
|
|
9
|
+
|
|
10
|
+
Function as a parameter:
|
|
11
|
+
(item)=>item.name === 1
|
|
12
|
+
const checkObject2 = compileQuery((i)=>i.name == '1')
|
|
13
|
+
|
|
14
|
+
const r = checkObject([{name:'head', level:1},{name:'head', level:2},{name:'head', level:2}, {name:1, level:2}])
|
|
15
|
+
*
|
|
16
|
+
* @param obj
|
|
17
|
+
* @returns function that can be used to filter the objects
|
|
18
|
+
*/
|
|
19
|
+
export const compileQuery = (...obj) => {
|
|
20
|
+
const queries = [];
|
|
21
|
+
const compiledQueries = obj.map(compileAtomQuery);
|
|
22
|
+
return function OR(par) {
|
|
23
|
+
const source = par instanceof Array ? par : [par];
|
|
24
|
+
const result = [];
|
|
25
|
+
source.forEach(item => {
|
|
26
|
+
if (item instanceof Array) {
|
|
27
|
+
result.push(...OR(item));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// obj should accomplished if some queries is true
|
|
31
|
+
if (compiledQueries.some(fn => fn(item).length > 0)) {
|
|
32
|
+
result.push(item);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const compileAtomQuery = (obj) => {
|
|
40
|
+
const queries = [];
|
|
41
|
+
if (obj instanceof Array) {
|
|
42
|
+
throw new Error('Wrong query parameter [Array], should be [Function] or [Object]');
|
|
43
|
+
}
|
|
44
|
+
else if (typeof obj === 'function') {
|
|
45
|
+
queries.push(obj);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
for (const entry of Object.entries(obj)) {
|
|
49
|
+
const [key, value] = entry;
|
|
50
|
+
const checkValue = val => {
|
|
51
|
+
if (value instanceof Array) {
|
|
52
|
+
return value.includes(val);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
if (typeof value === 'number') {
|
|
56
|
+
return parseInt(val, 10) === value;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return val === value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const checkKeyfn = (obj) => {
|
|
64
|
+
if (obj.hasOwnProperty(key)) {
|
|
65
|
+
return checkValue(obj[key]);
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
};
|
|
69
|
+
queries.push(checkKeyfn);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return function AND(obj) {
|
|
73
|
+
const source = obj instanceof Array ? obj : [obj];
|
|
74
|
+
const result = [];
|
|
75
|
+
source.forEach(item => {
|
|
76
|
+
if (item instanceof Array) {
|
|
77
|
+
result.push(...AND(item));
|
|
78
|
+
}
|
|
79
|
+
// obj should accomplished if all queries to be true
|
|
80
|
+
if (queries.every(fn => fn(item))) {
|
|
81
|
+
result.push(item);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Get nodes by queries
|
|
89
|
+
* @param tree
|
|
90
|
+
* @param queries
|
|
91
|
+
* @returns array of matched nodes
|
|
92
|
+
*/
|
|
93
|
+
export const getFromTree = (tree, ...queries) => {
|
|
94
|
+
if (!tree) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
let results = [];
|
|
98
|
+
let rules = {};
|
|
99
|
+
const transformer = makeTransformer({
|
|
100
|
+
'*:*': (node, ctx) => {
|
|
101
|
+
results.push(node);
|
|
102
|
+
if ('content' in node) {
|
|
103
|
+
return { node, content: transformer(node.content, { ...ctx }) };
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
transformer(tree, {});
|
|
108
|
+
//convert queries
|
|
109
|
+
const queryAtoms = [];
|
|
110
|
+
queries.forEach(q => {
|
|
111
|
+
if (typeof q === 'string') {
|
|
112
|
+
const getNameLevel = q.match(/^(?<name>(item|head))(?<level>(\d+)?)$/);
|
|
113
|
+
if (getNameLevel) {
|
|
114
|
+
let { name, level } = getNameLevel.groups;
|
|
115
|
+
if (name === 'item' && !level) {
|
|
116
|
+
level = '1';
|
|
117
|
+
}
|
|
118
|
+
const levelNum = level ? parseInt(level, 10) : undefined;
|
|
119
|
+
queryAtoms.push({ name, ...(levelNum ? { level: levelNum } : {}) });
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
queryAtoms.push({ name: q });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
queryAtoms.push(q);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return compileQuery(...queryAtoms)(results);
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=query-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-helpers.js","sourceRoot":"","sources":["../src/query-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAIpC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,GAAY,EAAkB,EAAE;IAC9D,MAAM,OAAO,GAAoC,EAAE,CAAA;IACnD,MAAM,eAAe,GAAG,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IACjD,OAAO,SAAS,EAAE,CAAC,GAAG;QACpB,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACjD,MAAM,MAAM,GAAG,EAAE,CAAA;QAEjB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACpB,IAAI,IAAI,YAAY,KAAK,EAAE;gBACzB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;aACzB;iBAAM;gBACL,kDAAkD;gBAClD,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;oBACnD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;iBAClB;aACF;QACH,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AACH,CAAC,CAAA;AACD,MAAM,gBAAgB,GAAG,CAAC,GAAU,EAAkB,EAAE;IACtD,MAAM,OAAO,GAAoC,EAAE,CAAA;IACnD,IAAI,GAAG,YAAY,KAAK,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;KACnF;SAAM,IAAI,OAAO,GAAG,KAAK,UAAU,EA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C,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;gBACxD,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;aACpE;iBAAM;gBACL,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;aAC7B;SACF;aAAM;YACL,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SACnB;IACH,CAAC,CAAC,CAAA;IACF,OAAO,YAAY,CAAC,GAAG,UAAU,CAAC,CAAC,OAAO,CAAC,CAAA;AAC7C,CAAC,CAAA"}
|
package/esm/types.d.ts
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
export interface RuleHandler<T = any> {
|
|
2
|
+
(writer: any, processor: any, tree: PodliteDocument): (node: T, ctx: any, interator: any) => void | AstTree | PodNode;
|
|
3
|
+
}
|
|
4
|
+
export interface Plugin {
|
|
5
|
+
toAst?: RuleHandler;
|
|
6
|
+
toAstAfter?: RuleHandler;
|
|
7
|
+
toHtml?: RuleHandler;
|
|
8
|
+
toJSX?: (helper: any) => RuleHandler;
|
|
9
|
+
}
|
|
10
|
+
export interface Plugins {
|
|
11
|
+
[name: string]: Plugin;
|
|
12
|
+
}
|
|
13
|
+
export interface RulesStrict {
|
|
14
|
+
'A<>': RuleHandler<FormattingCodeA>;
|
|
15
|
+
'B<>': RuleHandler<FormattingCodeB>;
|
|
16
|
+
'C<>': RuleHandler<FormattingCodeC>;
|
|
17
|
+
'D<>': RuleHandler<FormattingCodeD>;
|
|
18
|
+
'E<>': RuleHandler<FormattingCodeE>;
|
|
19
|
+
'I<>': RuleHandler<FormattingCodeI>;
|
|
20
|
+
'K<>': RuleHandler<FormattingCodeAny>;
|
|
21
|
+
'R<>': RuleHandler<FormattingCodeAny>;
|
|
22
|
+
'T<>': RuleHandler<FormattingCodeAny>;
|
|
23
|
+
'V<>': RuleHandler<FormattingCodeAny>;
|
|
24
|
+
'N<>': RuleHandler<FormattingCodeN>;
|
|
25
|
+
'X<>': RuleHandler<FormattingCodeX>;
|
|
26
|
+
'S<>': RuleHandler<FormattingCodeS>;
|
|
27
|
+
'L<>': RuleHandler<FormattingCodeL>;
|
|
28
|
+
'U<>': RuleHandler<FormattingCodeAny>;
|
|
29
|
+
'Z<>': RuleHandler<FormattingCodeAny>;
|
|
30
|
+
'Delete<>': RuleHandler<FormattingCodeAny>;
|
|
31
|
+
pod: RuleHandler<Para>;
|
|
32
|
+
root: RuleHandler<RootBlock>;
|
|
33
|
+
':para': RuleHandler<Para>;
|
|
34
|
+
':text': RuleHandler<Text>;
|
|
35
|
+
':blankline': RuleHandler<BlankLine>;
|
|
36
|
+
':ambient': RuleHandler<Ambient>;
|
|
37
|
+
':code': RuleHandler<Code>;
|
|
38
|
+
':verbatim': RuleHandler<Verbatim>;
|
|
39
|
+
':list': RuleHandler<List>;
|
|
40
|
+
':config': RuleHandler<BlockConfig>;
|
|
41
|
+
':alias': RuleHandler<Alias>;
|
|
42
|
+
data: RuleHandler<BlockData>;
|
|
43
|
+
code: RuleHandler<BlockCode>;
|
|
44
|
+
para: RuleHandler<BlockPara>;
|
|
45
|
+
defn: RuleHandler<BlockDefn>;
|
|
46
|
+
nested: RuleHandler<BlockNested>;
|
|
47
|
+
output: RuleHandler<BlockOutput>;
|
|
48
|
+
input: RuleHandler<BlockInput>;
|
|
49
|
+
picture: RuleHandler<BlockPicture>;
|
|
50
|
+
image: RuleHandler<BlockImage>;
|
|
51
|
+
':image': RuleHandler<Image>;
|
|
52
|
+
'item:block': RuleHandler<BlockItem>;
|
|
53
|
+
item: RuleHandler<BlockItem>;
|
|
54
|
+
'comment:block': RuleHandler<BlockComment>;
|
|
55
|
+
comment: RuleHandler<BlockComment>;
|
|
56
|
+
'head:block': RuleHandler<BlockHead>;
|
|
57
|
+
head: RuleHandler<BlockHead>;
|
|
58
|
+
':fcode': RuleHandler<FormattingCodes>;
|
|
59
|
+
'table:block': RuleHandler<BlockTable>;
|
|
60
|
+
table: RuleHandler<BlockTable>;
|
|
61
|
+
':separator': RuleHandler<Separator>;
|
|
62
|
+
table_row: RuleHandler<TableRow>;
|
|
63
|
+
table_cell: RuleHandler<TableCell>;
|
|
64
|
+
table_head: RuleHandler<TableHead>;
|
|
65
|
+
toc: RuleHandler<BlockToc>;
|
|
66
|
+
':toc': RuleHandler<Toc>;
|
|
67
|
+
':toc-list': RuleHandler<TocList>;
|
|
68
|
+
':toc-item': RuleHandler<TocItem>;
|
|
69
|
+
markdown: RuleHandler<BlockMarkdown>;
|
|
70
|
+
Diagram: RuleHandler<BlockDiagram>;
|
|
71
|
+
Mermaid: RuleHandler<BlockMermaid>;
|
|
72
|
+
Image: RuleHandler<BlockNamed>;
|
|
73
|
+
}
|
|
74
|
+
export interface Rules extends RulesStrict {
|
|
75
|
+
[name: string]: RuleHandler;
|
|
76
|
+
}
|
|
77
|
+
export interface Position {
|
|
78
|
+
line: number;
|
|
79
|
+
column: number;
|
|
80
|
+
offset: number;
|
|
81
|
+
}
|
|
82
|
+
export interface Location {
|
|
83
|
+
start: Position;
|
|
84
|
+
end: Position;
|
|
85
|
+
}
|
|
86
|
+
export interface Image {
|
|
87
|
+
type: 'image';
|
|
88
|
+
src: string;
|
|
89
|
+
alt?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface Toc {
|
|
92
|
+
type: 'toc';
|
|
93
|
+
title?: string;
|
|
94
|
+
content: TocList;
|
|
95
|
+
}
|
|
96
|
+
export interface TocList {
|
|
97
|
+
type: 'toc-list';
|
|
98
|
+
level: number;
|
|
99
|
+
content: Array<TocItem | TocList>;
|
|
100
|
+
}
|
|
101
|
+
export interface TocItem {
|
|
102
|
+
type: 'toc-item';
|
|
103
|
+
node: PodNode;
|
|
104
|
+
content: Array<Node>;
|
|
105
|
+
}
|
|
106
|
+
export interface BlockImage extends Omit<Block, 'content'> {
|
|
107
|
+
name: 'image';
|
|
108
|
+
caption?: string;
|
|
109
|
+
link?: string;
|
|
110
|
+
content: [Image, BlockCaption];
|
|
111
|
+
}
|
|
112
|
+
export interface BlockPicture extends Omit<Block, 'content'> {
|
|
113
|
+
name: 'picture';
|
|
114
|
+
caption?: string;
|
|
115
|
+
link?: string;
|
|
116
|
+
content: [Image, BlockCaption];
|
|
117
|
+
}
|
|
118
|
+
export interface BlockCaption extends Omit<Block, 'content' | 'location' | 'margin' | 'config' | 'id'> {
|
|
119
|
+
name: 'caption';
|
|
120
|
+
content: Array<Node>;
|
|
121
|
+
}
|
|
122
|
+
export interface RootBlock extends Omit<Block, 'location'> {
|
|
123
|
+
name: 'root';
|
|
124
|
+
content: AstTree;
|
|
125
|
+
}
|
|
126
|
+
export interface FormattingCodeB {
|
|
127
|
+
type: 'fcode';
|
|
128
|
+
name: 'B';
|
|
129
|
+
content?: Array<Node>;
|
|
130
|
+
}
|
|
131
|
+
export interface FormattingCodeC {
|
|
132
|
+
type: 'fcode';
|
|
133
|
+
name: 'C';
|
|
134
|
+
content?: Array<FormattingCodes | string>;
|
|
135
|
+
}
|
|
136
|
+
export interface FormattingCodeE {
|
|
137
|
+
type: 'fcode';
|
|
138
|
+
name: 'E';
|
|
139
|
+
content: Array<{
|
|
140
|
+
type: 'number';
|
|
141
|
+
value: number;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
144
|
+
export interface FormattingCodeN {
|
|
145
|
+
type: 'fcode';
|
|
146
|
+
name: 'N';
|
|
147
|
+
content?: Array<FormattingCodes | string>;
|
|
148
|
+
}
|
|
149
|
+
export interface FormattingCodeX {
|
|
150
|
+
type: 'fcode';
|
|
151
|
+
name: 'X';
|
|
152
|
+
entry: Array<string> | null;
|
|
153
|
+
content?: Array<FormattingCodes | string>;
|
|
154
|
+
}
|
|
155
|
+
export interface FormattingCodeZ {
|
|
156
|
+
type: 'fcode';
|
|
157
|
+
name: 'Z';
|
|
158
|
+
content?: string;
|
|
159
|
+
}
|
|
160
|
+
export interface FormattingCodeV {
|
|
161
|
+
type: 'fcode';
|
|
162
|
+
name: 'V';
|
|
163
|
+
content?: string;
|
|
164
|
+
}
|
|
165
|
+
export interface FormattingCodeS {
|
|
166
|
+
type: 'fcode';
|
|
167
|
+
name: 'S';
|
|
168
|
+
content?: string | Text;
|
|
169
|
+
}
|
|
170
|
+
export interface FormattingCodeA {
|
|
171
|
+
type: 'fcode';
|
|
172
|
+
name: 'A';
|
|
173
|
+
content: string | Text;
|
|
174
|
+
}
|
|
175
|
+
export interface FormattingCodeD {
|
|
176
|
+
type: 'fcode';
|
|
177
|
+
name: 'D';
|
|
178
|
+
synonyms: Array<string>;
|
|
179
|
+
content: string;
|
|
180
|
+
}
|
|
181
|
+
export interface FormattingCodeL {
|
|
182
|
+
type: 'fcode';
|
|
183
|
+
name: 'L';
|
|
184
|
+
meta: string | null;
|
|
185
|
+
content: string | Text;
|
|
186
|
+
}
|
|
187
|
+
export interface FormattingCodeI {
|
|
188
|
+
type: 'fcode';
|
|
189
|
+
name: 'I';
|
|
190
|
+
meta: string;
|
|
191
|
+
content: string | Text;
|
|
192
|
+
}
|
|
193
|
+
export interface FormattingCodeAny {
|
|
194
|
+
type: 'fcode';
|
|
195
|
+
name: string;
|
|
196
|
+
content?: Array<FormattingCodes | string>;
|
|
197
|
+
}
|
|
198
|
+
export interface Ambient {
|
|
199
|
+
type: 'ambient';
|
|
200
|
+
text: string;
|
|
201
|
+
location: Location;
|
|
202
|
+
}
|
|
203
|
+
export interface Verbatim {
|
|
204
|
+
type: 'verbatim';
|
|
205
|
+
value: string;
|
|
206
|
+
}
|
|
207
|
+
export interface Text {
|
|
208
|
+
type: 'text';
|
|
209
|
+
value: string;
|
|
210
|
+
}
|
|
211
|
+
export interface Para {
|
|
212
|
+
type: 'para';
|
|
213
|
+
text: string;
|
|
214
|
+
margin: string;
|
|
215
|
+
location: Location;
|
|
216
|
+
content: Array<Node | FormattingCodes>;
|
|
217
|
+
}
|
|
218
|
+
export interface Code {
|
|
219
|
+
type: 'code';
|
|
220
|
+
text: string;
|
|
221
|
+
margin: string;
|
|
222
|
+
location: Location;
|
|
223
|
+
content: Array<Verbatim | string>;
|
|
224
|
+
}
|
|
225
|
+
export interface BlankLine {
|
|
226
|
+
type: 'blankline';
|
|
227
|
+
}
|
|
228
|
+
export interface List {
|
|
229
|
+
type: 'list';
|
|
230
|
+
level: string | number;
|
|
231
|
+
content: Array<BlockItem | BlankLine | List>;
|
|
232
|
+
list: 'itemized';
|
|
233
|
+
}
|
|
234
|
+
export interface ConfigItemKV {
|
|
235
|
+
[key: string]: string | number | boolean;
|
|
236
|
+
}
|
|
237
|
+
export interface BrokenConfigItem extends Omit<ConfigItem, 'type'> {
|
|
238
|
+
}
|
|
239
|
+
export interface ConfigItem {
|
|
240
|
+
name: string;
|
|
241
|
+
value: boolean | string | number | Array<string | number | boolean> | ConfigItemKV;
|
|
242
|
+
type: string;
|
|
243
|
+
}
|
|
244
|
+
export interface BlockConfig {
|
|
245
|
+
name: string;
|
|
246
|
+
type: 'config';
|
|
247
|
+
config: Array<ConfigItem>;
|
|
248
|
+
margin: string;
|
|
249
|
+
}
|
|
250
|
+
export interface Alias {
|
|
251
|
+
name: string;
|
|
252
|
+
type: 'alias';
|
|
253
|
+
replacement: Array<string>;
|
|
254
|
+
margin: string;
|
|
255
|
+
}
|
|
256
|
+
export interface Separator {
|
|
257
|
+
type: 'separator';
|
|
258
|
+
text: string;
|
|
259
|
+
}
|
|
260
|
+
export interface Block {
|
|
261
|
+
type: 'block';
|
|
262
|
+
location: Location;
|
|
263
|
+
content: Array<Node>;
|
|
264
|
+
margin: string;
|
|
265
|
+
config?: Array<ConfigItem | BrokenConfigItem>;
|
|
266
|
+
id?: string;
|
|
267
|
+
}
|
|
268
|
+
export interface BlockPod extends Block {
|
|
269
|
+
name: 'pod';
|
|
270
|
+
}
|
|
271
|
+
export interface BlockData extends Block {
|
|
272
|
+
name: 'data';
|
|
273
|
+
}
|
|
274
|
+
export interface BlockComment extends Block {
|
|
275
|
+
name: 'comment';
|
|
276
|
+
}
|
|
277
|
+
export interface BlockDefn extends Block {
|
|
278
|
+
name: 'defn';
|
|
279
|
+
}
|
|
280
|
+
export interface BlockItem extends Block {
|
|
281
|
+
name: 'item';
|
|
282
|
+
content: Array<Node>;
|
|
283
|
+
level: string | number;
|
|
284
|
+
}
|
|
285
|
+
export interface BlockOutput extends Block {
|
|
286
|
+
name: 'output';
|
|
287
|
+
}
|
|
288
|
+
export interface BlockInput extends Block {
|
|
289
|
+
name: 'input';
|
|
290
|
+
}
|
|
291
|
+
export interface BlockPara extends Block {
|
|
292
|
+
name: 'para';
|
|
293
|
+
}
|
|
294
|
+
export interface BlockCode extends Block {
|
|
295
|
+
name: 'code';
|
|
296
|
+
}
|
|
297
|
+
export interface BlockToc extends Block {
|
|
298
|
+
name: 'toc';
|
|
299
|
+
}
|
|
300
|
+
export interface BlockMarkdown extends Block {
|
|
301
|
+
name: 'markdown';
|
|
302
|
+
}
|
|
303
|
+
export interface BlockNested extends Block {
|
|
304
|
+
name: 'nested';
|
|
305
|
+
}
|
|
306
|
+
export interface BlockHead extends Block {
|
|
307
|
+
name: 'head';
|
|
308
|
+
level: number | string;
|
|
309
|
+
}
|
|
310
|
+
export interface BlockTable extends Omit<Block, 'content'> {
|
|
311
|
+
name: 'table';
|
|
312
|
+
content: Array<TableHead | TableSeparator | TableRow | BlankLine>;
|
|
313
|
+
text?: string;
|
|
314
|
+
}
|
|
315
|
+
export interface TableCell {
|
|
316
|
+
name: 'table_cell';
|
|
317
|
+
type: 'block';
|
|
318
|
+
content: Array<string>;
|
|
319
|
+
}
|
|
320
|
+
export interface TableRow {
|
|
321
|
+
name: 'table_row';
|
|
322
|
+
type: 'block';
|
|
323
|
+
content: Array<TableCell>;
|
|
324
|
+
}
|
|
325
|
+
export interface TableHead {
|
|
326
|
+
name: 'table_head';
|
|
327
|
+
type: 'block';
|
|
328
|
+
content: Array<TableCell>;
|
|
329
|
+
}
|
|
330
|
+
export interface TableSeparator {
|
|
331
|
+
type: 'separator';
|
|
332
|
+
text: string;
|
|
333
|
+
}
|
|
334
|
+
export declare type BlockAny = BlockNamed;
|
|
335
|
+
export interface BlockNamed extends Omit<Block, 'content'> {
|
|
336
|
+
name: Capitalize<string>;
|
|
337
|
+
content: [(Verbatim | Para | Code)?] | Array<Image | BlockCaption> | RootBlock;
|
|
338
|
+
}
|
|
339
|
+
export interface BlockDiagram extends Omit<BlockNamed, 'content'> {
|
|
340
|
+
name: 'Diagram';
|
|
341
|
+
content: [Verbatim];
|
|
342
|
+
custom?: {
|
|
343
|
+
location: Location;
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
export interface BlockMermaid extends Omit<BlockNamed, 'content'> {
|
|
347
|
+
name: 'Mermaid';
|
|
348
|
+
content: [Verbatim];
|
|
349
|
+
custom?: {
|
|
350
|
+
location: Location;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
export declare type FormattingCodes = FormattingCodeA | FormattingCodeC | FormattingCodeB | FormattingCodeD | FormattingCodeE | FormattingCodeI | FormattingCodeL | FormattingCodeN | FormattingCodeX | FormattingCodeZ | FormattingCodeV | FormattingCodeS | FormattingCodeAny;
|
|
354
|
+
export declare type PodNode = Ambient | BlockPod | BlockData | BlockCode | BlankLine | BlockNested | BlockMarkdown | BlockOutput | BlockInput | BlockPara | BlockHead | BlockComment | BlockDefn | string | Para | Text | Code | BlockNamed | BlockAny | Verbatim | BlockTable | List | BlockConfig | BlockItem | Alias | BlockToc | BlockPicture | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
|
|
355
|
+
export declare type Node = PodNode;
|
|
356
|
+
export declare type AstTree = Array<PodNode>;
|
|
357
|
+
export declare type PodliteDocument = RootBlock;
|
package/esm/types.js
ADDED
package/esm/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/esm/writer.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default writer
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
import * as Events from 'events';
|
|
6
|
+
declare class Writer extends Events.EventEmitter {
|
|
7
|
+
INDEXTERMS: any[];
|
|
8
|
+
FOOTNOTES: any[];
|
|
9
|
+
output: any;
|
|
10
|
+
errors: any;
|
|
11
|
+
out: any;
|
|
12
|
+
ons: any[];
|
|
13
|
+
constructor(output?: any);
|
|
14
|
+
escape(p: any): any;
|
|
15
|
+
write(p: any): void;
|
|
16
|
+
writeRaw(str: any): void;
|
|
17
|
+
getStr(): {
|
|
18
|
+
errors: any;
|
|
19
|
+
toString: () => any;
|
|
20
|
+
valueOf: () => any;
|
|
21
|
+
};
|
|
22
|
+
startWrite(tree: any): void;
|
|
23
|
+
on(...params: any[]): this;
|
|
24
|
+
endWrite: () => void;
|
|
25
|
+
_add_nesting(n: number): void;
|
|
26
|
+
_remove_nesting(n: number): void;
|
|
27
|
+
addLevel(n: number): void;
|
|
28
|
+
removeLevel(n: number): void;
|
|
29
|
+
}
|
|
30
|
+
export default Writer;
|