@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/CHANGELOG.md CHANGED
@@ -1,37 +1,69 @@
1
1
  # @podlite/schema
2
2
 
3
3
  ## Upcoming
4
+
5
+ ## 0.0.13
6
+
7
+ - refactor
8
+ - add plugin functions
9
+
10
+ ## 0.0.12
11
+
12
+ - add helpers,
13
+ - fix parser's grammars
14
+ - add tests
15
+ - update deps
16
+
4
17
  ## 0.0.11
18
+
5
19
  - extend API by context for react component wrap function
20
+
6
21
  ## 0.0.10
22
+
7
23
  - fix helper for mkBlock
8
24
  - add Strikethrough inline element support
9
25
  - add JSX handler for plugins
26
+
10
27
  ## 0.0.9
11
- - fix null elements in
28
+
29
+ - fix null elements in
30
+
12
31
  ## 0.0.8
32
+
13
33
  - fix null elements in AST
34
+
14
35
  ## 0.0.7
15
- - add ast interator module (ast-inerator)
16
- - add AST nodes for image and caption objects, add mkImage and mkCaption helpers
36
+
37
+ - add ast interator module (ast-inerator)
38
+ - add AST nodes for image and caption objects, add mkImage and mkCaption helpers
17
39
  - add mkBlockItem, getTextContentFromNode and query blocks from AST helpers
18
40
  - add id prop to Node type
19
41
  - toc elements support
42
+
20
43
  ## 0.0.6
44
+
21
45
  - list of supported schemas is explicit now
22
46
  - add support for create "blankline" blocks (mkBlankline)
23
47
  - enhance debug
48
+
24
49
  ## 0.0.5
50
+
25
51
  - update deps
52
+
26
53
  ## 0.0.4
54
+
27
55
  - fix npm package
28
56
  - add sometypes of blocks
29
57
  - update schema
30
-
58
+
31
59
  ## 0.0.3
60
+
32
61
  - update deps
62
+
33
63
  ## 0.0.2
64
+
34
65
  - update deps
35
66
 
36
67
  ## 0.0.1
68
+
37
69
  -- init import
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Alexandr Zahatski
3
+ Copyright © 2021-2024 Aliaksandr Zahatski
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1 +1,41 @@
1
1
  # @podlite/schema
2
+
3
+ <div align="center">
4
+
5
+ [![Podlite](https://github.com/zag/specs/raw/podlite-specification/assets/podlite_logo_256x256.png)](https://podlite.org)
6
+
7
+ </div>
8
+
9
+ **Podlite is a lightweight block-based markup language designed for flexibility and ease of use.**
10
+
11
+ Unbound by any specific domain, programming language, or concept, Podlite stands out as a universal markup language. It's versatile enough to be successfully implemented across various development fields, from web development to scientific research.
12
+
13
+ Podlite is not limited to any specific application domain, programming language, or concept.
14
+
15
+ In addition, the support for Markdown markup as a standard block adds convenience and allows for the use of familiar syntax for text formatting.
16
+
17
+ One of the key features of Podlite is its extensibility. This allows for defining unique and domain-specific blocks and expanding the language's functionality according to the requirements of your project.
18
+
19
+ Its flexibility makes it an ideal tool for creating documentation, blogs, educational materials, and much more.
20
+
21
+ Podlite aims to provide users with a means for creativity and expressing ideas in a structured form, while ensuring ease of use and high flexibility in content creation.
22
+
23
+ ## Useful links
24
+
25
+ 📖 _Project site_: [podlite.org](https://podlite.org)
26
+
27
+ 📌 _Github_: [github.com/podlite](https://github.com/podlite/) 🤩
28
+
29
+ 🖥️ _Online editor_: [pod6.in](https://pod6.in/)
30
+
31
+ 🖥️ _Desktop editor/viewer_: [github.com/podlite/podlite-desktop](https://github.com/podlite/podlite-desktop) - the viewer and editor of `.podlite` and `.pod6` files for Windows, Linux and Mac.
32
+
33
+ 📚 _Podlite for web_ - static site generator: [github.com/podlite/podlite-web](https://github.com/podlite/podlite-web)
34
+
35
+ ## AUTHOR
36
+
37
+ Copyright (c) 2021-2024 Aliaksandr Zahatski
38
+
39
+ ## License
40
+
41
+ Released under a MIT License.
@@ -1,2 +1,2 @@
1
1
  export declare const getNodeId: (node: any, ctx: any) => any;
2
- export declare const makeAttrs: (node: any, ctx?: import("pod6/built/helpers/config").Context) => import("pod6/built/helpers/config").Attr;
2
+ export declare const makeAttrs: (node: any, ctx?: import("./helpers/config").Context) => import("./helpers/config").Attr;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeAttrs = exports.getNodeId = void 0;
7
- const config_1 = __importDefault(require("pod6/built/helpers/config"));
7
+ const config_1 = __importDefault(require("./helpers/config"));
8
8
  const getNodeId = (node, ctx) => {
9
9
  const conf = (0, config_1.default)(node, ctx);
10
10
  if (conf.exists('id')) {
@@ -14,3 +14,4 @@ const getNodeId = (node, ctx) => {
14
14
  };
15
15
  exports.getNodeId = getNodeId;
16
16
  exports.makeAttrs = config_1.default;
17
+ //# sourceMappingURL=ast-helpers.js.map
@@ -1,4 +1,3 @@
1
- export declare function isNamedBlock(name: any): boolean;
2
1
  export declare function isSemanticBlock(node: any): boolean;
3
2
  export declare const makeInterator: (rule: any) => {
4
3
  (node: any, context?: any): any;
@@ -1,16 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeInterator = exports.isSemanticBlock = exports.isNamedBlock = void 0;
4
- const { makeRule, makePlug } = require('pod6/built/helpers/makeQuery');
5
- // the following names: MyBlock, myBlock are use for extending pod6
6
- function isNamedBlock(name) {
7
- return (name
8
- &&
9
- name !== name.toLowerCase()
10
- &&
11
- name !== name.toUpperCase());
12
- }
13
- exports.isNamedBlock = isNamedBlock;
3
+ exports.makeInterator = exports.isSemanticBlock = void 0;
4
+ const makeQuery_1 = require("./helpers/makeQuery");
14
5
  // skip warnings for semantic blocks
15
6
  function isSemanticBlock(node) {
16
7
  const name = node.name || '';
@@ -19,9 +10,9 @@ function isSemanticBlock(node) {
19
10
  }
20
11
  exports.isSemanticBlock = isSemanticBlock;
21
12
  function flattenDeep(arr) {
22
- return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), []);
13
+ return arr.reduce((acc, val) => (Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val)), []);
23
14
  }
24
- const makeInterator = (rule) => {
15
+ const makeInterator = rule => {
25
16
  let rules = [];
26
17
  function use(key, fn) {
27
18
  if (key instanceof Array) {
@@ -35,14 +26,14 @@ const makeInterator = (rule) => {
35
26
  }
36
27
  return [];
37
28
  }
38
- rules.push(makeRule(makePlug(key), fn));
29
+ rules.push((0, makeQuery_1.makeRule)((0, makeQuery_1.makePlug)(key), fn));
39
30
  }
40
31
  function visiter(node, context = {}) {
41
32
  if (node instanceof Array) {
42
33
  return flattenDeep(node.map(item => visiter(item, context))).filter(Boolean);
43
34
  }
44
35
  if ('string' === typeof node) {
45
- // convert string to lex node with type
36
+ // convert string to lex node with type
46
37
  return visiter({ type: 'text', value: node }, context);
47
38
  return node;
48
39
  }
@@ -68,3 +59,4 @@ const makeInterator = (rule) => {
68
59
  };
69
60
  exports.makeInterator = makeInterator;
70
61
  exports.default = exports.makeInterator;
62
+ //# sourceMappingURL=ast-inerator.js.map
@@ -1,4 +1,4 @@
1
- import { AstTree, BlockCaption, BlockItem, Location, PodNode, RootBlock, Toc, TocItem, TocList, Node, Image } from "./types";
1
+ import { AstTree, BlockCaption, BlockItem, Location, PodNode, RootBlock, Toc, TocItem, TocList, Node, Image } from './types';
2
2
  export declare const mkNode: <P extends Record<string, any>>(attr: P) => P;
3
3
  export declare const filterNulls: (content: any) => any[];
4
4
  export declare const mkBlock: (attrs: any, content: any) => any;
@@ -6,7 +6,7 @@ const mkNode = (attr) => {
6
6
  return { ...attr };
7
7
  };
8
8
  exports.mkNode = mkNode;
9
- const filterNulls = (content) => {
9
+ const filterNulls = content => {
10
10
  if (Array.isArray(content)) {
11
11
  return content.filter(i => i);
12
12
  }
@@ -14,31 +14,33 @@ const filterNulls = (content) => {
14
14
  };
15
15
  exports.filterNulls = filterNulls;
16
16
  const mkBlock = (attrs, content) => {
17
- const type = "block";
17
+ const type = 'block';
18
18
  const name = attrs.name;
19
- const attributes = { id: (0, nanoid_1.nanoid)(), margin: "", ...attrs };
19
+ const attributes = { id: (0, nanoid_1.nanoid)(), margin: '', ...attrs };
20
20
  var result = (0, exports.mkNode)({ type, ...attributes, content: (0, exports.filterNulls)(content) });
21
21
  return result;
22
22
  };
23
23
  exports.mkBlock = mkBlock;
24
- const mkBlankline = () => { return (0, exports.mkNode)({ type: 'blankline' }); };
24
+ const mkBlankline = () => {
25
+ return (0, exports.mkNode)({ type: 'blankline' });
26
+ };
25
27
  exports.mkBlankline = mkBlankline;
26
28
  const mkFomattingCode = (attrs, content) => {
27
29
  return (0, exports.mkNode)({ type: 'fcode', ...attrs, content });
28
30
  };
29
31
  exports.mkFomattingCode = mkFomattingCode;
30
32
  const mkFomattingCodeL = (attrs, content) => {
31
- let res = (0, exports.mkNode)({ ...attrs, type: 'fcode', name: "L", content: (0, exports.filterNulls)(content) });
33
+ let res = (0, exports.mkNode)({ ...attrs, type: 'fcode', name: 'L', content: (0, exports.filterNulls)(content) });
32
34
  return res;
33
35
  };
34
36
  exports.mkFomattingCodeL = mkFomattingCodeL;
35
- const mkFomattingCodeDelete = (content) => {
36
- let res = (0, exports.mkNode)({ type: 'fcode', name: "Delete", content: (0, exports.filterNulls)(content) });
37
+ const mkFomattingCodeDelete = content => {
38
+ let res = (0, exports.mkNode)({ type: 'fcode', name: 'Delete', content: (0, exports.filterNulls)(content) });
37
39
  return res;
38
40
  };
39
41
  exports.mkFomattingCodeDelete = mkFomattingCodeDelete;
40
- const mkVerbatim = (text) => {
41
- return (0, exports.mkNode)({ "type": "verbatim", "value": text });
42
+ const mkVerbatim = text => {
43
+ return (0, exports.mkNode)({ type: 'verbatim', value: text });
42
44
  };
43
45
  exports.mkVerbatim = mkVerbatim;
44
46
  // Table of contents helpers
@@ -58,7 +60,7 @@ const mkCaption = (content) => {
58
60
  return {
59
61
  type: 'block',
60
62
  name: 'caption',
61
- content
63
+ content,
62
64
  };
63
65
  };
64
66
  exports.mkCaption = mkCaption;
@@ -66,11 +68,11 @@ const mkImage = (src, alt) => {
66
68
  return {
67
69
  type: 'image',
68
70
  src,
69
- alt
71
+ alt,
70
72
  };
71
73
  };
72
74
  exports.mkImage = mkImage;
73
- const mkRootBlock = ({ margin = "" }, content) => {
75
+ const mkRootBlock = ({ margin = '' }, content) => {
74
76
  return (0, exports.mkBlock)({ name: 'root', margin }, content);
75
77
  };
76
78
  exports.mkRootBlock = mkRootBlock;
@@ -78,3 +80,4 @@ const mkItemBlock = ({ level, location, margin }, content) => {
78
80
  return (0, exports.mkBlock)({ name: 'item', level, margin, location }, content);
79
81
  };
80
82
  exports.mkItemBlock = mkItemBlock;
83
+ //# sourceMappingURL=blocks-helpers.js.map
@@ -0,0 +1,19 @@
1
+ export declare type Options = {
2
+ processor?: any;
3
+ writer?: any;
4
+ };
5
+ export declare const toAny: (options?: Options, plugins?: any[]) => {
6
+ (root: any): void;
7
+ use: (key: any, fn?: any) => any;
8
+ run: (src: any, opt_writer?: any) => {
9
+ errors: any;
10
+ toString: () => string;
11
+ valueOf: () => string;
12
+ indexingTerms: any;
13
+ annotations: any;
14
+ defenitions: any;
15
+ interator: any;
16
+ };
17
+ getPlugins(): any[];
18
+ };
19
+ export default toAny;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.toAny = void 0;
7
+ const makeQuery_1 = require("./helpers/makeQuery");
8
+ const makeInterator_1 = __importDefault(require("./helpers/makeInterator"));
9
+ const writer_1 = __importDefault(require("./writer"));
10
+ const _1 = require("./");
11
+ const toAny = (options = {}, plugins = []) => {
12
+ let fns = plugins;
13
+ // setup pod6 processor
14
+ const processor = options.processor || _1.parse;
15
+ const _writer = options.writer;
16
+ chain.use = use;
17
+ chain.run = run;
18
+ chain.getPlugins = () => fns;
19
+ return chain;
20
+ function chain(root) { }
21
+ function use(key, fn) {
22
+ if (key instanceof Array) {
23
+ return (0, exports.toAny)(options, [...fns, ...fn]);
24
+ }
25
+ if (key instanceof Object) {
26
+ for (var prop in key) {
27
+ if (key.hasOwnProperty(prop)) {
28
+ use(prop, key[prop]);
29
+ }
30
+ }
31
+ return chain;
32
+ }
33
+ fns.push((0, makeQuery_1.makeRule)((0, makeQuery_1.makePlug)(key), fn));
34
+ return chain;
35
+ }
36
+ function run(src, opt_writer) {
37
+ let res = '';
38
+ const _tmp_writer = opt_writer ||
39
+ _writer ||
40
+ new writer_1.default(s => {
41
+ res = res + s;
42
+ });
43
+ const writer = 'function' === typeof _tmp_writer
44
+ ? new _tmp_writer(s => {
45
+ res = res + s;
46
+ })
47
+ : _tmp_writer;
48
+ // src may be preparsed tree
49
+ const tree = 'string' === typeof src ? processor(src) : src;
50
+ // make new instance of HTML with initialized plugins
51
+ // reverse init
52
+ let newFns = fns.slice();
53
+ newFns.reverse();
54
+ const interator = (0, makeInterator_1.default)(newFns.map(rule => (0, makeQuery_1.makeRule)(rule.rule, rule.fn(writer, processor, tree))).reverse());
55
+ const context = {};
56
+ writer.startWrite(tree);
57
+ const result = interator(tree, context);
58
+ writer.endWrite();
59
+ return {
60
+ errors: writer.errors,
61
+ toString: () => res,
62
+ valueOf: () => res,
63
+ indexingTerms: writer.INDEXTERMS,
64
+ annotations: writer.FOOTNOTES,
65
+ defenitions: writer.DEFINITIONS,
66
+ interator: result,
67
+ };
68
+ }
69
+ };
70
+ exports.toAny = toAny;
71
+ exports.default = exports.toAny;
72
+ //# sourceMappingURL=exportAny.js.map
@@ -0,0 +1,15 @@
1
+ declare const toHtml: (opt: any) => {
2
+ (root: any): void;
3
+ use: (key: any, fn?: any) => any;
4
+ run: (src: any, opt_writer?: any) => {
5
+ errors: any;
6
+ toString: () => string;
7
+ valueOf: () => string;
8
+ indexingTerms: any;
9
+ annotations: any;
10
+ defenitions: any;
11
+ interator: any;
12
+ };
13
+ getPlugins(): any[];
14
+ };
15
+ export default toHtml;