@podlite/schema 0.0.13 → 0.0.15

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/esm/ast-helpers.d.ts +2 -0
  3. package/esm/ast-helpers.js +10 -0
  4. package/esm/ast-helpers.js.map +1 -0
  5. package/esm/ast-inerator.d.ts +6 -0
  6. package/esm/ast-inerator.js +57 -0
  7. package/esm/ast-inerator.js.map +1 -0
  8. package/esm/blocks-helpers.d.ts +32 -0
  9. package/esm/blocks-helpers.js +65 -0
  10. package/esm/blocks-helpers.js.map +1 -0
  11. package/esm/exportAny.d.ts +19 -0
  12. package/esm/exportAny.js +65 -0
  13. package/esm/exportAny.js.map +1 -0
  14. package/esm/exportHtml.d.ts +15 -0
  15. package/esm/exportHtml.js +279 -0
  16. package/esm/exportHtml.js.map +1 -0
  17. package/esm/grammar.d.ts +14 -0
  18. package/esm/grammar.js +6404 -0
  19. package/esm/grammar.js.map +1 -0
  20. package/esm/grammarfc.d.ts +14 -0
  21. package/esm/grammarfc.js +4218 -0
  22. package/esm/grammarfc.js.map +1 -0
  23. package/esm/helpers/config.d.ts +12 -0
  24. package/esm/helpers/config.js +52 -0
  25. package/esm/helpers/config.js.map +1 -0
  26. package/esm/helpers/corePlugins.d.ts +12 -0
  27. package/esm/helpers/corePlugins.js +23 -0
  28. package/esm/helpers/corePlugins.js.map +1 -0
  29. package/esm/helpers/handlers.d.ts +47 -0
  30. package/esm/helpers/handlers.js +107 -0
  31. package/esm/helpers/handlers.js.map +1 -0
  32. package/esm/helpers/ids.d.ts +18 -0
  33. package/esm/helpers/ids.js +69 -0
  34. package/esm/helpers/ids.js.map +1 -0
  35. package/esm/helpers/makeInterator.d.ts +5 -0
  36. package/esm/helpers/makeInterator.js +52 -0
  37. package/esm/helpers/makeInterator.js.map +1 -0
  38. package/esm/helpers/makeQuery.d.ts +47 -0
  39. package/esm/helpers/makeQuery.js +100 -0
  40. package/esm/helpers/makeQuery.js.map +1 -0
  41. package/esm/helpers/makeQuery.test.d.ts +1 -0
  42. package/esm/helpers/makeQuery.test.js +51 -0
  43. package/esm/helpers/makeQuery.test.js.map +1 -0
  44. package/esm/helpers/makeTransformer.d.ts +7 -0
  45. package/esm/helpers/makeTransformer.js +61 -0
  46. package/esm/helpers/makeTransformer.js.map +1 -0
  47. package/esm/helpers/plugins.d.ts +2 -0
  48. package/esm/helpers/plugins.js +23 -0
  49. package/esm/helpers/plugins.js.map +1 -0
  50. package/esm/index.d.ts +82 -0
  51. package/esm/index.js +123 -0
  52. package/esm/index.js.map +1 -0
  53. package/esm/pluggableParser.d.ts +27 -0
  54. package/esm/pluggableParser.js +71 -0
  55. package/esm/pluggableParser.js.map +1 -0
  56. package/esm/plugin-clean-location.d.ts +2 -0
  57. package/esm/plugin-clean-location.js +19 -0
  58. package/esm/plugin-clean-location.js.map +1 -0
  59. package/esm/plugin-defn-fill-term.d.ts +2 -0
  60. package/esm/plugin-defn-fill-term.js +50 -0
  61. package/esm/plugin-defn-fill-term.js.map +1 -0
  62. package/esm/plugin-formatting-codes.d.ts +3 -0
  63. package/esm/plugin-formatting-codes.js +53 -0
  64. package/esm/plugin-formatting-codes.js.map +1 -0
  65. package/esm/plugin-group-defn.d.ts +2 -0
  66. package/esm/plugin-group-defn.js +71 -0
  67. package/esm/plugin-group-defn.js.map +1 -0
  68. package/esm/plugin-group-items.d.ts +2 -0
  69. package/esm/plugin-group-items.js +79 -0
  70. package/esm/plugin-group-items.js.map +1 -0
  71. package/esm/plugin-heading.d.ts +2 -0
  72. package/esm/plugin-heading.js +33 -0
  73. package/esm/plugin-heading.js.map +1 -0
  74. package/esm/plugin-items.d.ts +2 -0
  75. package/esm/plugin-items.js +41 -0
  76. package/esm/plugin-items.js.map +1 -0
  77. package/esm/plugin-tables.d.ts +5 -0
  78. package/esm/plugin-tables.js +141 -0
  79. package/esm/plugin-tables.js.map +1 -0
  80. package/esm/plugin-vmargin.d.ts +3 -0
  81. package/esm/plugin-vmargin.js +29 -0
  82. package/esm/plugin-vmargin.js.map +1 -0
  83. package/esm/query-helpers.d.ts +28 -0
  84. package/esm/query-helpers.js +131 -0
  85. package/esm/query-helpers.js.map +1 -0
  86. package/esm/types.d.ts +342 -0
  87. package/esm/types.js +2 -0
  88. package/esm/types.js.map +1 -0
  89. package/esm/writer.d.ts +30 -0
  90. package/esm/writer.js +85 -0
  91. package/esm/writer.js.map +1 -0
  92. package/esm/writerHtml.d.ts +11 -0
  93. package/esm/writerHtml.js +29 -0
  94. package/esm/writerHtml.js.map +1 -0
  95. package/lib/grammar.js +29 -21
  96. package/lib/grammarfc.js +1098 -243
  97. package/lib/plugin-formatting-codes.js +2 -1
  98. package/lib/types.d.ts +9 -1
  99. package/package.json +11 -8
  100. package/schema/AstTree.json +116 -0
  101. package/schema/PodliteDocument.json +116 -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,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,CACtE,CAAA;gBACH,CAAC;aACF,CAAC,CAAC,IAAI,CAAC,CAAA;YAER,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAC,CAAA;IACF,OAAO,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AAC9B,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { ParserPlugin } from './';
2
+ declare const middle: ParserPlugin;
3
+ export default middle;
@@ -0,0 +1,29 @@
1
+ const middle = () => tree => {
2
+ const visit_node = (node, context = {}) => {
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,OAA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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;IACt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AM,CAAA;gBACzC,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,KAAK,EAAE;oBAC7B,KAAK,GAAG,GAAG,CAAA;iBACZ;gBACD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,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,342 @@
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
+ image: RuleHandler<BlockImage>;
50
+ ':image': RuleHandler<Image>;
51
+ 'item:block': RuleHandler<BlockItem>;
52
+ item: RuleHandler<BlockItem>;
53
+ 'comment:block': RuleHandler<BlockComment>;
54
+ comment: RuleHandler<BlockComment>;
55
+ 'head:block': RuleHandler<BlockHead>;
56
+ head: RuleHandler<BlockHead>;
57
+ ':fcode': RuleHandler<FormattingCodes>;
58
+ 'table:block': RuleHandler<BlockTable>;
59
+ table: RuleHandler<BlockTable>;
60
+ ':separator': RuleHandler<Separator>;
61
+ table_row: RuleHandler<TableRow>;
62
+ table_cell: RuleHandler<TableCell>;
63
+ table_head: RuleHandler<TableHead>;
64
+ toc: RuleHandler<BlockToc>;
65
+ ':toc': RuleHandler<Toc>;
66
+ ':toc-list': RuleHandler<TocList>;
67
+ ':toc-item': RuleHandler<TocItem>;
68
+ markdown: RuleHandler<BlockMarkdown>;
69
+ Diagram: RuleHandler<BlockDiagram>;
70
+ Image: RuleHandler<BlockNamed>;
71
+ }
72
+ export interface Rules extends RulesStrict {
73
+ [name: string]: RuleHandler;
74
+ }
75
+ export interface Position {
76
+ line: number;
77
+ column: number;
78
+ offset: number;
79
+ }
80
+ export interface Location {
81
+ start: Position;
82
+ end: Position;
83
+ }
84
+ export interface Image {
85
+ type: 'image';
86
+ src: string;
87
+ alt?: string;
88
+ }
89
+ export interface Toc {
90
+ type: 'toc';
91
+ title?: string;
92
+ content: TocList;
93
+ }
94
+ export interface TocList {
95
+ type: 'toc-list';
96
+ level: number;
97
+ content: Array<TocItem | TocList>;
98
+ }
99
+ export interface TocItem {
100
+ type: 'toc-item';
101
+ node: PodNode;
102
+ content: Array<Node>;
103
+ }
104
+ export interface BlockImage extends Omit<Block, 'content'> {
105
+ name: 'image';
106
+ caption?: string;
107
+ link?: string;
108
+ content: [Image, BlockCaption];
109
+ }
110
+ export interface BlockCaption extends Omit<Block, 'content' | 'location' | 'margin' | 'config' | 'id'> {
111
+ name: 'caption';
112
+ content: Array<Node>;
113
+ }
114
+ export interface RootBlock extends Omit<Block, 'location'> {
115
+ name: 'root';
116
+ content: AstTree;
117
+ }
118
+ export interface FormattingCodeB {
119
+ type: 'fcode';
120
+ name: 'B';
121
+ content?: Array<Node>;
122
+ }
123
+ export interface FormattingCodeC {
124
+ type: 'fcode';
125
+ name: 'C';
126
+ content?: Array<FormattingCodes | string>;
127
+ }
128
+ export interface FormattingCodeE {
129
+ type: 'fcode';
130
+ name: 'E';
131
+ content: Array<{
132
+ type: 'number';
133
+ value: number;
134
+ }>;
135
+ }
136
+ export interface FormattingCodeN {
137
+ type: 'fcode';
138
+ name: 'N';
139
+ content?: Array<FormattingCodes | string>;
140
+ }
141
+ export interface FormattingCodeX {
142
+ type: 'fcode';
143
+ name: 'X';
144
+ entry: Array<string> | null;
145
+ content?: Array<FormattingCodes | string>;
146
+ }
147
+ export interface FormattingCodeZ {
148
+ type: 'fcode';
149
+ name: 'Z';
150
+ content?: string;
151
+ }
152
+ export interface FormattingCodeV {
153
+ type: 'fcode';
154
+ name: 'V';
155
+ content?: string;
156
+ }
157
+ export interface FormattingCodeS {
158
+ type: 'fcode';
159
+ name: 'S';
160
+ content?: string | Text;
161
+ }
162
+ export interface FormattingCodeA {
163
+ type: 'fcode';
164
+ name: 'A';
165
+ content: string | Text;
166
+ }
167
+ export interface FormattingCodeD {
168
+ type: 'fcode';
169
+ name: 'D';
170
+ synonyms: Array<string>;
171
+ content: string;
172
+ }
173
+ export interface FormattingCodeL {
174
+ type: 'fcode';
175
+ name: 'L';
176
+ meta: string | null;
177
+ content: string | Text;
178
+ }
179
+ export interface FormattingCodeI {
180
+ type: 'fcode';
181
+ name: 'I';
182
+ meta: string;
183
+ content: string | Text;
184
+ }
185
+ export interface FormattingCodeAny {
186
+ type: 'fcode';
187
+ name: string;
188
+ content?: Array<FormattingCodes | string>;
189
+ }
190
+ export interface Ambient {
191
+ type: 'ambient';
192
+ text: string;
193
+ location: Location;
194
+ }
195
+ export interface Verbatim {
196
+ type: 'verbatim';
197
+ value: string;
198
+ }
199
+ export interface Text {
200
+ type: 'text';
201
+ value: string;
202
+ }
203
+ export interface Para {
204
+ type: 'para';
205
+ text: string;
206
+ margin: string;
207
+ location: Location;
208
+ content: Array<Node | FormattingCodes>;
209
+ }
210
+ export interface Code {
211
+ type: 'code';
212
+ text: string;
213
+ margin: string;
214
+ location: Location;
215
+ content: Array<Verbatim | string>;
216
+ }
217
+ export interface BlankLine {
218
+ type: 'blankline';
219
+ }
220
+ export interface List {
221
+ type: 'list';
222
+ level: string | number;
223
+ content: Array<BlockItem | BlankLine | List>;
224
+ list: 'itemized';
225
+ }
226
+ export interface ConfigItemKV {
227
+ [key: string]: string | number | boolean;
228
+ }
229
+ export interface BrokenConfigItem extends Omit<ConfigItem, 'type'> {
230
+ }
231
+ export interface ConfigItem {
232
+ name: string;
233
+ value: boolean | string | number | Array<string | number | boolean> | ConfigItemKV;
234
+ type: string;
235
+ }
236
+ export interface BlockConfig {
237
+ name: string;
238
+ type: 'config';
239
+ config: Array<ConfigItem>;
240
+ margin: string;
241
+ }
242
+ export interface Alias {
243
+ name: string;
244
+ type: 'alias';
245
+ replacement: Array<string>;
246
+ margin: string;
247
+ }
248
+ export interface Separator {
249
+ type: 'separator';
250
+ text: string;
251
+ }
252
+ export interface Block {
253
+ type: 'block';
254
+ location: Location;
255
+ content: Array<Node>;
256
+ margin: string;
257
+ config?: Array<ConfigItem | BrokenConfigItem>;
258
+ id?: string;
259
+ }
260
+ export interface BlockPod extends Block {
261
+ name: 'pod';
262
+ }
263
+ export interface BlockData extends Block {
264
+ name: 'data';
265
+ }
266
+ export interface BlockComment extends Block {
267
+ name: 'comment';
268
+ }
269
+ export interface BlockDefn extends Block {
270
+ name: 'defn';
271
+ }
272
+ export interface BlockItem extends Block {
273
+ name: 'item';
274
+ content: Array<Node>;
275
+ level: string | number;
276
+ }
277
+ export interface BlockOutput extends Block {
278
+ name: 'output';
279
+ }
280
+ export interface BlockInput extends Block {
281
+ name: 'input';
282
+ }
283
+ export interface BlockPara extends Block {
284
+ name: 'para';
285
+ }
286
+ export interface BlockCode extends Block {
287
+ name: 'code';
288
+ }
289
+ export interface BlockToc extends Block {
290
+ name: 'toc';
291
+ }
292
+ export interface BlockMarkdown extends Block {
293
+ name: 'markdown';
294
+ }
295
+ export interface BlockNested extends Block {
296
+ name: 'nested';
297
+ }
298
+ export interface BlockHead extends Block {
299
+ name: 'head';
300
+ level: number | string;
301
+ }
302
+ export interface BlockTable extends Omit<Block, 'content'> {
303
+ name: 'table';
304
+ content: Array<TableHead | TableSeparator | TableRow | BlankLine>;
305
+ text?: string;
306
+ }
307
+ export interface TableCell {
308
+ name: 'table_cell';
309
+ type: 'block';
310
+ content: Array<string>;
311
+ }
312
+ export interface TableRow {
313
+ name: 'table_row';
314
+ type: 'block';
315
+ content: Array<TableCell>;
316
+ }
317
+ export interface TableHead {
318
+ name: 'table_head';
319
+ type: 'block';
320
+ content: Array<TableCell>;
321
+ }
322
+ export interface TableSeparator {
323
+ type: 'separator';
324
+ text: string;
325
+ }
326
+ export declare type BlockAny = BlockNamed;
327
+ export interface BlockNamed extends Omit<Block, 'content'> {
328
+ name: Capitalize<string>;
329
+ content: [(Verbatim | Para | Code)?] | Array<Image | BlockCaption> | RootBlock;
330
+ }
331
+ export interface BlockDiagram extends Omit<BlockNamed, 'content'> {
332
+ name: 'Diagram';
333
+ content: [Verbatim];
334
+ custom?: {
335
+ location: Location;
336
+ };
337
+ }
338
+ export declare type FormattingCodes = FormattingCodeA | FormattingCodeC | FormattingCodeB | FormattingCodeD | FormattingCodeE | FormattingCodeI | FormattingCodeL | FormattingCodeN | FormattingCodeX | FormattingCodeZ | FormattingCodeV | FormattingCodeS | FormattingCodeAny;
339
+ 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 | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
340
+ export declare type Node = PodNode;
341
+ export declare type AstTree = Array<PodNode>;
342
+ export declare type PodliteDocument = RootBlock;
package/esm/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -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;
package/esm/writer.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Default writer
3
+ */
4
+ import * as Events from 'events';
5
+ class Writer extends Events.EventEmitter {
6
+ INDEXTERMS;
7
+ FOOTNOTES;
8
+ output;
9
+ errors;
10
+ out;
11
+ ons;
12
+ // write: (p: any) => void;
13
+ // getStr: () => { errors: any; toString: () => any; valueOf: () => any; };
14
+ // errors: any;
15
+ // out: any;
16
+ // startWrite: () => void;
17
+ // ons: any[];
18
+ // endWrite: () => void;
19
+ constructor(output) {
20
+ super();
21
+ // save X<> entries
22
+ this.INDEXTERMS = [];
23
+ // save N<> annotates
24
+ this.FOOTNOTES = [];
25
+ this.output = output;
26
+ this.ons = [];
27
+ this.emit('ready');
28
+ }
29
+ // escape function for output
30
+ escape(p) {
31
+ return p;
32
+ }
33
+ // write with escape special symbols
34
+ write(p) {
35
+ return this.writeRaw(this.escape(p));
36
+ }
37
+ // raw write as is
38
+ writeRaw(str) {
39
+ if ('function' === typeof this.output) {
40
+ this.output(str);
41
+ }
42
+ else {
43
+ console.log(str);
44
+ }
45
+ }
46
+ getStr() {
47
+ return {
48
+ errors: this.errors,
49
+ toString: () => this.out,
50
+ valueOf: () => this.out,
51
+ };
52
+ }
53
+ startWrite(tree) {
54
+ // setup events
55
+ ;
56
+ (this.ons || []).map(a =>
57
+ //@ts-ignore
58
+ super.on(...a));
59
+ this.emit('start', tree);
60
+ this.addListener('errors', err => {
61
+ this.errors = this.errors || [];
62
+ this.errors.push(err);
63
+ });
64
+ }
65
+ on(...params) {
66
+ // overload 'on' method for reverse setup handlers
67
+ this.ons = this.ons || [];
68
+ this.ons.unshift([...params]);
69
+ return this;
70
+ }
71
+ endWrite = () => {
72
+ this.emit('end');
73
+ };
74
+ // nesting methods
75
+ _add_nesting(n) { }
76
+ _remove_nesting(n) { }
77
+ addLevel(n) {
78
+ this._add_nesting(n);
79
+ }
80
+ removeLevel(n) {
81
+ this._remove_nesting(n);
82
+ }
83
+ }
84
+ export default Writer;
85
+ //# sourceMappingURL=writer.js.map