@podlite/schema 0.0.11 → 0.0.13

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 (70) hide show
  1. package/CHANGELOG.md +36 -4
  2. package/LICENSE +1 -1
  3. package/README.md +40 -0
  4. package/lib/ast-helpers.d.ts +1 -1
  5. package/lib/ast-helpers.js +2 -1
  6. package/lib/ast-inerator.d.ts +0 -1
  7. package/lib/ast-inerator.js +7 -15
  8. package/lib/blocks-helpers.d.ts +1 -1
  9. package/lib/blocks-helpers.js +15 -12
  10. package/lib/exportAny.d.ts +19 -0
  11. package/lib/exportAny.js +72 -0
  12. package/lib/exportHtml.d.ts +15 -0
  13. package/lib/exportHtml.js +284 -0
  14. package/lib/grammar.d.ts +14 -0
  15. package/lib/grammar.js +6396 -0
  16. package/lib/grammarfc.d.ts +14 -0
  17. package/lib/grammarfc.js +3363 -0
  18. package/lib/helpers/config.d.ts +12 -0
  19. package/lib/helpers/config.js +56 -0
  20. package/lib/helpers/corePlugins.d.ts +12 -0
  21. package/lib/helpers/corePlugins.js +26 -0
  22. package/lib/helpers/handlers.d.ts +47 -0
  23. package/lib/helpers/handlers.js +120 -0
  24. package/lib/helpers/ids.d.ts +18 -0
  25. package/lib/helpers/ids.js +74 -0
  26. package/lib/helpers/makeInterator.d.ts +5 -0
  27. package/lib/helpers/makeInterator.js +54 -0
  28. package/lib/helpers/makeQuery.d.ts +47 -0
  29. package/lib/helpers/makeQuery.js +107 -0
  30. package/lib/helpers/makeQuery.test.d.ts +1 -0
  31. package/lib/helpers/makeQuery.test.js +51 -0
  32. package/lib/helpers/makeTransformer.d.ts +7 -0
  33. package/lib/helpers/makeTransformer.js +67 -0
  34. package/lib/helpers/plugins.d.ts +2 -0
  35. package/lib/helpers/plugins.js +27 -0
  36. package/lib/index.d.ts +64 -0
  37. package/lib/index.js +85 -5
  38. package/lib/pluggableParser.d.ts +27 -0
  39. package/lib/pluggableParser.js +80 -0
  40. package/lib/plugin-clean-location.d.ts +2 -0
  41. package/lib/plugin-clean-location.js +26 -0
  42. package/lib/plugin-defn-fill-term.d.ts +2 -0
  43. package/lib/plugin-defn-fill-term.js +55 -0
  44. package/lib/plugin-formatting-codes.d.ts +3 -0
  45. package/lib/plugin-formatting-codes.js +76 -0
  46. package/lib/plugin-group-defn.d.ts +2 -0
  47. package/lib/plugin-group-defn.js +73 -0
  48. package/lib/plugin-group-items.d.ts +2 -0
  49. package/lib/plugin-group-items.js +84 -0
  50. package/lib/plugin-heading.d.ts +2 -0
  51. package/lib/plugin-heading.js +35 -0
  52. package/lib/plugin-items.d.ts +2 -0
  53. package/lib/plugin-items.js +43 -0
  54. package/lib/plugin-tables.d.ts +5 -0
  55. package/lib/plugin-tables.js +146 -0
  56. package/lib/plugin-vmargin.d.ts +3 -0
  57. package/lib/plugin-vmargin.js +31 -0
  58. package/lib/query-helpers.d.ts +2 -1
  59. package/lib/query-helpers.js +10 -10
  60. package/lib/types.d.ts +69 -69
  61. package/lib/types.js +1 -0
  62. package/lib/writer.d.ts +30 -0
  63. package/lib/writer.js +106 -0
  64. package/lib/writerHtml.d.ts +11 -0
  65. package/lib/writerHtml.js +34 -0
  66. package/package.json +18 -10
  67. package/schema/index.d.ts +3 -3
  68. package/index.js +0 -2
  69. package/lib/helpers.d.ts +0 -1
  70. package/lib/helpers.js +0 -5
package/lib/types.d.ts CHANGED
@@ -28,8 +28,8 @@ export interface RulesStrict {
28
28
  'U<>': RuleHandler<FormattingCodeAny>;
29
29
  'Z<>': RuleHandler<FormattingCodeAny>;
30
30
  'Delete<>': RuleHandler<FormattingCodeAny>;
31
- 'pod': RuleHandler<Para>;
32
- 'root': RuleHandler<RootBlock>;
31
+ pod: RuleHandler<Para>;
32
+ root: RuleHandler<RootBlock>;
33
33
  ':para': RuleHandler<Para>;
34
34
  ':text': RuleHandler<Text>;
35
35
  ':blankline': RuleHandler<BlankLine>;
@@ -39,33 +39,33 @@ export interface RulesStrict {
39
39
  ':list': RuleHandler<List>;
40
40
  ':config': RuleHandler<BlockConfig>;
41
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>;
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
50
  ':image': RuleHandler<Image>;
51
51
  'item:block': RuleHandler<BlockItem>;
52
- 'item': RuleHandler<BlockItem>;
52
+ item: RuleHandler<BlockItem>;
53
53
  'comment:block': RuleHandler<BlockComment>;
54
- 'comment': RuleHandler<BlockComment>;
54
+ comment: RuleHandler<BlockComment>;
55
55
  'head:block': RuleHandler<BlockHead>;
56
- 'head': RuleHandler<BlockHead>;
56
+ head: RuleHandler<BlockHead>;
57
57
  ':fcode': RuleHandler<FormattingCodes>;
58
58
  'table:block': RuleHandler<BlockTable>;
59
- 'table': RuleHandler<BlockTable>;
59
+ table: RuleHandler<BlockTable>;
60
60
  ':separator': RuleHandler<Separator>;
61
- 'table_row': RuleHandler<TableRow>;
62
- 'table_cell': RuleHandler<TableCell>;
63
- 'table_head': RuleHandler<TableHead>;
61
+ table_row: RuleHandler<TableRow>;
62
+ table_cell: RuleHandler<TableCell>;
63
+ table_head: RuleHandler<TableHead>;
64
64
  ':toc': RuleHandler<Toc>;
65
65
  ':toc-list': RuleHandler<TocList>;
66
66
  ':toc-item': RuleHandler<TocItem>;
67
- 'Diagram': RuleHandler<BlockDiagram>;
68
- 'Image': RuleHandler<BlockNamed>;
67
+ Diagram: RuleHandler<BlockDiagram>;
68
+ Image: RuleHandler<BlockNamed>;
69
69
  }
70
70
  export interface Rules extends RulesStrict {
71
71
  [name: string]: RuleHandler;
@@ -114,112 +114,112 @@ export interface RootBlock extends Omit<Block, 'location'> {
114
114
  content: AstTree;
115
115
  }
116
116
  export interface FormattingCodeB {
117
- type: "fcode";
118
- name: "B";
117
+ type: 'fcode';
118
+ name: 'B';
119
119
  content?: Array<Node>;
120
120
  }
121
121
  export interface FormattingCodeC {
122
- type: "fcode";
123
- name: "C";
122
+ type: 'fcode';
123
+ name: 'C';
124
124
  content?: Array<FormattingCodes | string>;
125
125
  }
126
126
  export interface FormattingCodeE {
127
- type: "fcode";
128
- name: "E";
127
+ type: 'fcode';
128
+ name: 'E';
129
129
  content: Array<{
130
- type: "number";
130
+ type: 'number';
131
131
  value: number;
132
132
  }>;
133
133
  }
134
134
  export interface FormattingCodeN {
135
- type: "fcode";
136
- name: "N";
135
+ type: 'fcode';
136
+ name: 'N';
137
137
  content?: Array<FormattingCodes | string>;
138
138
  }
139
139
  export interface FormattingCodeX {
140
- type: "fcode";
141
- name: "X";
140
+ type: 'fcode';
141
+ name: 'X';
142
142
  entry: Array<string> | null;
143
143
  content?: Array<FormattingCodes | string>;
144
144
  }
145
145
  export interface FormattingCodeZ {
146
- type: "fcode";
147
- name: "Z";
146
+ type: 'fcode';
147
+ name: 'Z';
148
148
  content?: string;
149
149
  }
150
150
  export interface FormattingCodeV {
151
- type: "fcode";
152
- name: "V";
151
+ type: 'fcode';
152
+ name: 'V';
153
153
  content?: string;
154
154
  }
155
155
  export interface FormattingCodeS {
156
- type: "fcode";
157
- name: "S";
156
+ type: 'fcode';
157
+ name: 'S';
158
158
  content?: string | Text;
159
159
  }
160
160
  export interface FormattingCodeA {
161
- type: "fcode";
162
- name: "A";
161
+ type: 'fcode';
162
+ name: 'A';
163
163
  content: string | Text;
164
164
  }
165
165
  export interface FormattingCodeD {
166
- type: "fcode";
167
- name: "D";
166
+ type: 'fcode';
167
+ name: 'D';
168
168
  synonyms: Array<string>;
169
169
  content: string;
170
170
  }
171
171
  export interface FormattingCodeL {
172
- type: "fcode";
173
- name: "L";
172
+ type: 'fcode';
173
+ name: 'L';
174
174
  meta: string | null;
175
175
  content: string | Text;
176
176
  }
177
177
  export interface FormattingCodeI {
178
- type: "fcode";
179
- name: "I";
178
+ type: 'fcode';
179
+ name: 'I';
180
180
  meta: string;
181
181
  content: string | Text;
182
182
  }
183
183
  export interface FormattingCodeAny {
184
- type: "fcode";
184
+ type: 'fcode';
185
185
  name: string;
186
186
  content?: Array<FormattingCodes | string>;
187
187
  }
188
188
  export interface Ambient {
189
- type: "ambient";
189
+ type: 'ambient';
190
190
  text: string;
191
191
  location: Location;
192
192
  }
193
193
  export interface Verbatim {
194
- type: "verbatim";
194
+ type: 'verbatim';
195
195
  value: string;
196
196
  }
197
197
  export interface Text {
198
- type: "text";
198
+ type: 'text';
199
199
  value: string;
200
200
  }
201
201
  export interface Para {
202
- type: "para";
202
+ type: 'para';
203
203
  text: string;
204
204
  margin: string;
205
205
  location: Location;
206
206
  content: Array<Node | FormattingCodes>;
207
207
  }
208
208
  export interface Code {
209
- type: "code";
209
+ type: 'code';
210
210
  text: string;
211
211
  margin: string;
212
212
  location: Location;
213
213
  content: Array<Verbatim | string>;
214
214
  }
215
215
  export interface BlankLine {
216
- type: "blankline";
216
+ type: 'blankline';
217
217
  }
218
218
  export interface List {
219
- type: "list";
219
+ type: 'list';
220
220
  level: string | number;
221
221
  content: Array<BlockItem | BlankLine | List>;
222
- list: "itemized";
222
+ list: 'itemized';
223
223
  }
224
224
  export interface ConfigItemKV {
225
225
  [key: string]: string | number | boolean;
@@ -233,13 +233,13 @@ export interface ConfigItem {
233
233
  }
234
234
  export interface BlockConfig {
235
235
  name: string;
236
- type: "config";
236
+ type: 'config';
237
237
  config: Array<ConfigItem>;
238
238
  margin: string;
239
239
  }
240
240
  export interface Alias {
241
241
  name: string;
242
- type: "alias";
242
+ type: 'alias';
243
243
  replacement: Array<string>;
244
244
  margin: string;
245
245
  }
@@ -248,7 +248,7 @@ export interface Separator {
248
248
  text: string;
249
249
  }
250
250
  export interface Block {
251
- type: "block";
251
+ type: 'block';
252
252
  location: Location;
253
253
  content: Array<Node>;
254
254
  margin: string;
@@ -268,18 +268,18 @@ export interface BlockDefn extends Block {
268
268
  name: 'defn';
269
269
  }
270
270
  export interface BlockItem extends Block {
271
- name: "item";
271
+ name: 'item';
272
272
  content: Array<Node>;
273
273
  level: string | number;
274
274
  }
275
275
  export interface BlockOutput extends Block {
276
- name: "output";
276
+ name: 'output';
277
277
  }
278
278
  export interface BlockInput extends Block {
279
- name: "input";
279
+ name: 'input';
280
280
  }
281
281
  export interface BlockPara extends Block {
282
- name: "para";
282
+ name: 'para';
283
283
  }
284
284
  export interface BlockCode extends Block {
285
285
  name: 'code';
@@ -292,28 +292,28 @@ export interface BlockHead extends Block {
292
292
  level: number | string;
293
293
  }
294
294
  export interface BlockTable extends Omit<Block, 'content'> {
295
- name: "table";
295
+ name: 'table';
296
296
  content: Array<TableHead | TableSeparator | TableRow | BlankLine>;
297
297
  text?: string;
298
298
  }
299
299
  export interface TableCell {
300
- name: "table_cell";
301
- type: "block";
300
+ name: 'table_cell';
301
+ type: 'block';
302
302
  content: Array<string>;
303
303
  }
304
304
  export interface TableRow {
305
- name: "table_row";
306
- type: "block";
305
+ name: 'table_row';
306
+ type: 'block';
307
307
  content: Array<TableCell>;
308
308
  }
309
309
  export interface TableHead {
310
- name: "table_head";
311
- type: "block";
310
+ name: 'table_head';
311
+ type: 'block';
312
312
  content: Array<TableCell>;
313
313
  }
314
314
  export interface TableSeparator {
315
- "type": "separator";
316
- "text": string;
315
+ type: 'separator';
316
+ text: string;
317
317
  }
318
318
  export declare type BlockAny = BlockNamed;
319
319
  export interface BlockNamed extends Omit<Block, 'content'> {
package/lib/types.js CHANGED
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -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/lib/writer.js ADDED
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ /**
3
+ * Default writer
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const Events = __importStar(require("events"));
26
+ class Writer extends Events.EventEmitter {
27
+ INDEXTERMS;
28
+ FOOTNOTES;
29
+ output;
30
+ errors;
31
+ out;
32
+ ons;
33
+ // write: (p: any) => void;
34
+ // getStr: () => { errors: any; toString: () => any; valueOf: () => any; };
35
+ // errors: any;
36
+ // out: any;
37
+ // startWrite: () => void;
38
+ // ons: any[];
39
+ // endWrite: () => void;
40
+ constructor(output) {
41
+ super();
42
+ // save X<> entries
43
+ this.INDEXTERMS = [];
44
+ // save N<> annotates
45
+ this.FOOTNOTES = [];
46
+ this.output = output;
47
+ this.ons = [];
48
+ this.emit('ready');
49
+ }
50
+ // escape function for output
51
+ escape(p) {
52
+ return p;
53
+ }
54
+ // write with escape special symbols
55
+ write(p) {
56
+ return this.writeRaw(this.escape(p));
57
+ }
58
+ // raw write as is
59
+ writeRaw(str) {
60
+ if ('function' === typeof this.output) {
61
+ this.output(str);
62
+ }
63
+ else {
64
+ console.log(str);
65
+ }
66
+ }
67
+ getStr() {
68
+ return {
69
+ errors: this.errors,
70
+ toString: () => this.out,
71
+ valueOf: () => this.out,
72
+ };
73
+ }
74
+ startWrite(tree) {
75
+ // setup events
76
+ ;
77
+ (this.ons || []).map(a =>
78
+ //@ts-ignore
79
+ super.on(...a));
80
+ this.emit('start', tree);
81
+ this.addListener('errors', err => {
82
+ this.errors = this.errors || [];
83
+ this.errors.push(err);
84
+ });
85
+ }
86
+ on(...params) {
87
+ // overload 'on' method for reverse setup handlers
88
+ this.ons = this.ons || [];
89
+ this.ons.unshift([...params]);
90
+ return this;
91
+ }
92
+ endWrite = () => {
93
+ this.emit('end');
94
+ };
95
+ // nesting methods
96
+ _add_nesting(n) { }
97
+ _remove_nesting(n) { }
98
+ addLevel(n) {
99
+ this._add_nesting(n);
100
+ }
101
+ removeLevel(n) {
102
+ this._remove_nesting(n);
103
+ }
104
+ }
105
+ exports.default = Writer;
106
+ //# sourceMappingURL=writer.js.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * HTML writer
3
+ */
4
+ import Writer from './writer';
5
+ declare class WriterHTML extends Writer {
6
+ constructor(output?: any);
7
+ escape(string: any): string;
8
+ _add_nesting(n: any): void;
9
+ _remove_nesting(n: any): void;
10
+ }
11
+ export default WriterHTML;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * HTML writer
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const writer_1 = __importDefault(require("./writer"));
10
+ class WriterHTML extends writer_1.default {
11
+ constructor(output) {
12
+ super(output);
13
+ }
14
+ escape(string) {
15
+ const HTML_CHARS = {
16
+ '&': '&amp;',
17
+ '<': '&lt;',
18
+ '>': '&gt;',
19
+ '"': '&quot;',
20
+ "'": '&#x27;',
21
+ '/': '&#x2F;',
22
+ '`': '&#x60;',
23
+ };
24
+ return (string + '').replace(/[&<>"'\/`]/g, match => HTML_CHARS[match]);
25
+ }
26
+ _add_nesting(n) {
27
+ this.writeRaw('<blockquote>'.repeat(n));
28
+ }
29
+ _remove_nesting(n) {
30
+ this.writeRaw('</blockquote>'.repeat(n));
31
+ }
32
+ }
33
+ exports.default = WriterHTML;
34
+ //# sourceMappingURL=writerHtml.js.map
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@podlite/schema",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "podlite schema",
5
- "main": "index.js",
5
+ "main": "lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "MIT",
8
8
  "files": [
@@ -18,30 +18,38 @@
18
18
  "engineStrict": true,
19
19
  "publishConfig": {
20
20
  "access": "public",
21
- "main": "index.js",
22
- "module": "index.js",
21
+ "main": "lib/index.js",
23
22
  "types": "./lib/index.d.ts"
24
23
  },
25
24
  "scripts": {
26
- "clean": "rm -rf lib tsconfig.tsbuildinfo",
27
- "build": "run-s build:ts build:ast",
25
+ "clean": "rm -rf lib esm tsconfig.tsbuildinfo",
26
+ "build": "run-s build:pegjs build:ts build:ast ",
28
27
  "build:ast": "ts-node scripts/make-ast-scheme.ts",
29
28
  "build:ts": "yarn g:tsc --build $INIT_CWD",
29
+ "build:esm": "yarn g:tsctest -p tsconfig.esm.json",
30
+ "build:pegjs": "pegjs -o src/grammar.js src/grammar.pegjs && pegjs -o src/grammarfc.js src/grammarfc.pegjs",
30
31
  "watch": "npx nodemon -e js,ts --exec 'yarn' build",
31
32
  "test": "yarn g:jest --passWithNoTests"
32
33
  },
34
+ "keywords": [
35
+ "markdown",
36
+ "podlite",
37
+ "markup",
38
+ "markup-language"
39
+ ],
33
40
  "dependencies": {
34
41
  "ajv": "^7.2.3",
42
+ "events": "^3.1.0",
35
43
  "json-pointer": "^0.6.1",
36
- "nanoid": "3.1.30",
37
- "pod6": "^0.0.48"
44
+ "nanoid": "3.1.30"
38
45
  },
39
46
  "devDependencies": {
40
47
  "@types/node": "^17.0.7",
41
48
  "glob": "^7.2.0",
49
+ "npm-run-all": "^4.1.5",
50
+ "pegjs": "^0.10.0",
42
51
  "ts-node": "^9.1.1",
43
52
  "typescript": "4.5.5",
44
53
  "typescript-json-schema": "0.53.0"
45
- },
46
- "module": "index.js"
54
+ }
47
55
  }
package/schema/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export var Test: any;
2
- export var AstTree: any;
3
- export var PodliteDocument: any;
1
+ export var Test: any
2
+ export var AstTree: any
3
+ export var PodliteDocument: any
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- 'use strict'
2
- module.exports = require('./lib')
package/lib/helpers.d.ts DELETED
@@ -1 +0,0 @@
1
- export { wrapContent } from 'pod6/built/helpers/handlers';
package/lib/helpers.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapContent = void 0;
4
- var handlers_1 = require("pod6/built/helpers/handlers");
5
- Object.defineProperty(exports, "wrapContent", { enumerable: true, get: function () { return handlers_1.wrapContent; } });