@podlite/schema 0.0.11 → 0.0.12

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 (54) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +1 -1
  3. package/lib/ast-helpers.d.ts +1 -1
  4. package/lib/ast-helpers.js +1 -1
  5. package/lib/ast-inerator.js +2 -2
  6. package/lib/exportAny.d.ts +19 -0
  7. package/lib/exportAny.js +64 -0
  8. package/lib/exportHtml.d.ts +15 -0
  9. package/lib/exportHtml.js +277 -0
  10. package/lib/grammar.d.ts +14 -0
  11. package/lib/grammar.js +6395 -0
  12. package/lib/grammarfc.d.ts +14 -0
  13. package/lib/grammarfc.js +3362 -0
  14. package/lib/helpers/config.d.ts +12 -0
  15. package/lib/helpers/config.js +51 -0
  16. package/lib/helpers/handlers.d.ts +47 -0
  17. package/lib/helpers/handlers.js +119 -0
  18. package/lib/helpers/makeInterator.d.ts +5 -0
  19. package/lib/helpers/makeInterator.js +51 -0
  20. package/lib/helpers/makeQuery.d.ts +47 -0
  21. package/lib/helpers/makeQuery.js +103 -0
  22. package/lib/helpers/makeQuery.test.d.ts +1 -0
  23. package/lib/helpers/makeQuery.test.js +41 -0
  24. package/lib/helpers/makeTransformer.d.ts +7 -0
  25. package/lib/helpers/makeTransformer.js +70 -0
  26. package/lib/index.d.ts +61 -0
  27. package/lib/index.js +71 -1
  28. package/lib/plugin-clean-location.d.ts +2 -0
  29. package/lib/plugin-clean-location.js +23 -0
  30. package/lib/plugin-defn-fill-term.d.ts +2 -0
  31. package/lib/plugin-defn-fill-term.js +52 -0
  32. package/lib/plugin-formatting-codes.d.ts +3 -0
  33. package/lib/plugin-formatting-codes.js +48 -0
  34. package/lib/plugin-group-defn.d.ts +2 -0
  35. package/lib/plugin-group-defn.js +73 -0
  36. package/lib/plugin-group-items.d.ts +2 -0
  37. package/lib/plugin-group-items.js +82 -0
  38. package/lib/plugin-heading.d.ts +2 -0
  39. package/lib/plugin-heading.js +32 -0
  40. package/lib/plugin-items.d.ts +2 -0
  41. package/lib/plugin-items.js +40 -0
  42. package/lib/plugin-tables.d.ts +5 -0
  43. package/lib/plugin-tables.js +131 -0
  44. package/lib/plugin-vmargin.d.ts +3 -0
  45. package/lib/plugin-vmargin.js +29 -0
  46. package/lib/query-helpers.d.ts +2 -1
  47. package/lib/query-helpers.js +2 -5
  48. package/lib/writer.d.ts +30 -0
  49. package/lib/writer.js +91 -0
  50. package/lib/writerHtml.d.ts +11 -0
  51. package/lib/writerHtml.js +33 -0
  52. package/package.json +13 -4
  53. package/lib/helpers.d.ts +0 -1
  54. package/lib/helpers.js +0 -5
@@ -1,10 +1,7 @@
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
3
  exports.getFromTree = exports.compileQuery = void 0;
7
- const makeTransformer_1 = __importDefault(require("pod6/built/helpers/makeTransformer"));
4
+ const _1 = require("./");
8
5
  /**
9
6
  * compileQuery - compile a query to a function
10
7
 
@@ -103,7 +100,7 @@ const getFromTree = (tree, ...queries) => {
103
100
  }
104
101
  let results = [];
105
102
  let rules = {};
106
- const transformer = (0, makeTransformer_1.default)({ '*:*': (node, ctx) => {
103
+ const transformer = (0, _1.makeTransformer)({ '*:*': (node, ctx) => {
107
104
  results.push(node);
108
105
  if ('content' in node) {
109
106
  return { node, content: transformer(node.content, { ...ctx }) };
@@ -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,91 @@
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
+ // write: (p: any) => void;
28
+ // getStr: () => { errors: any; toString: () => any; valueOf: () => any; };
29
+ // errors: any;
30
+ // out: any;
31
+ // startWrite: () => void;
32
+ // ons: any[];
33
+ // endWrite: () => void;
34
+ constructor(output) {
35
+ super();
36
+ this.endWrite = () => {
37
+ this.emit('end');
38
+ };
39
+ // save X<> entries
40
+ this.INDEXTERMS = [];
41
+ // save N<> annotates
42
+ this.FOOTNOTES = [];
43
+ this.output = output;
44
+ this.ons = [];
45
+ this.emit('ready');
46
+ }
47
+ // escape function for output
48
+ escape(p) { return p; }
49
+ // write with escape special symbols
50
+ write(p) { return this.writeRaw(this.escape(p)); }
51
+ // raw write as is
52
+ writeRaw(str) {
53
+ if ('function' === typeof this.output) {
54
+ this.output(str);
55
+ }
56
+ else {
57
+ console.log(str);
58
+ }
59
+ }
60
+ getStr() {
61
+ return {
62
+ errors: this.errors,
63
+ toString: () => this.out,
64
+ valueOf: () => this.out
65
+ };
66
+ }
67
+ startWrite(tree) {
68
+ // setup events
69
+ (this.ons || []).map(a =>
70
+ //@ts-ignore
71
+ super.on(...a));
72
+ this.emit('start', tree);
73
+ this.addListener('errors', (err) => { this.errors = this.errors || []; this.errors.push(err); });
74
+ }
75
+ on(...params) {
76
+ // overload 'on' method for reverse setup handlers
77
+ this.ons = this.ons || [];
78
+ this.ons.unshift([...params]);
79
+ return this;
80
+ }
81
+ // nesting methods
82
+ _add_nesting(n) { }
83
+ _remove_nesting(n) { }
84
+ addLevel(n) {
85
+ this._add_nesting(n);
86
+ }
87
+ removeLevel(n) {
88
+ this._remove_nesting(n);
89
+ }
90
+ }
91
+ exports.default = Writer;
@@ -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,33 @@
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podlite/schema",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "podlite schema",
5
5
  "main": "index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -24,21 +24,30 @@
24
24
  },
25
25
  "scripts": {
26
26
  "clean": "rm -rf lib tsconfig.tsbuildinfo",
27
- "build": "run-s build:ts build:ast",
27
+ "build": "run-s build:ts build:ast build:pegjs",
28
28
  "build:ast": "ts-node scripts/make-ast-scheme.ts",
29
29
  "build:ts": "yarn g:tsc --build $INIT_CWD",
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"
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; } });