@podlite/schema 0.0.12 → 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 (44) hide show
  1. package/CHANGELOG.md +31 -4
  2. package/README.md +40 -0
  3. package/lib/ast-helpers.js +1 -0
  4. package/lib/ast-inerator.d.ts +0 -1
  5. package/lib/ast-inerator.js +5 -13
  6. package/lib/blocks-helpers.d.ts +1 -1
  7. package/lib/blocks-helpers.js +15 -12
  8. package/lib/exportAny.js +14 -6
  9. package/lib/exportHtml.js +43 -36
  10. package/lib/grammar.js +1 -0
  11. package/lib/grammarfc.js +1 -0
  12. package/lib/helpers/config.js +8 -3
  13. package/lib/helpers/corePlugins.d.ts +12 -0
  14. package/lib/helpers/corePlugins.js +26 -0
  15. package/lib/helpers/handlers.js +1 -0
  16. package/lib/helpers/ids.d.ts +18 -0
  17. package/lib/helpers/ids.js +74 -0
  18. package/lib/helpers/makeInterator.js +6 -3
  19. package/lib/helpers/makeQuery.js +5 -1
  20. package/lib/helpers/makeQuery.test.js +32 -22
  21. package/lib/helpers/makeTransformer.js +7 -10
  22. package/lib/helpers/plugins.d.ts +2 -0
  23. package/lib/helpers/plugins.js +27 -0
  24. package/lib/index.d.ts +24 -21
  25. package/lib/index.js +18 -8
  26. package/lib/pluggableParser.d.ts +27 -0
  27. package/lib/pluggableParser.js +80 -0
  28. package/lib/plugin-clean-location.js +6 -3
  29. package/lib/plugin-defn-fill-term.js +7 -4
  30. package/lib/plugin-formatting-codes.js +39 -11
  31. package/lib/plugin-group-defn.js +10 -10
  32. package/lib/plugin-group-items.js +22 -20
  33. package/lib/plugin-heading.js +6 -3
  34. package/lib/plugin-items.js +9 -6
  35. package/lib/plugin-tables.js +46 -31
  36. package/lib/plugin-vmargin.js +5 -3
  37. package/lib/query-helpers.js +9 -6
  38. package/lib/types.d.ts +69 -69
  39. package/lib/types.js +1 -0
  40. package/lib/writer.js +22 -7
  41. package/lib/writerHtml.js +3 -2
  42. package/package.json +7 -8
  43. package/schema/index.d.ts +3 -3
  44. package/index.js +0 -2
package/CHANGELOG.md CHANGED
@@ -1,42 +1,69 @@
1
1
  # @podlite/schema
2
2
 
3
3
  ## Upcoming
4
+
5
+ ## 0.0.13
6
+
7
+ - refactor
8
+ - add plugin functions
9
+
4
10
  ## 0.0.12
11
+
5
12
  - add helpers,
6
13
  - fix parser's grammars
7
14
  - add tests
8
15
  - update deps
16
+
9
17
  ## 0.0.11
18
+
10
19
  - extend API by context for react component wrap function
20
+
11
21
  ## 0.0.10
22
+
12
23
  - fix helper for mkBlock
13
24
  - add Strikethrough inline element support
14
25
  - add JSX handler for plugins
26
+
15
27
  ## 0.0.9
16
- - fix null elements in
28
+
29
+ - fix null elements in
30
+
17
31
  ## 0.0.8
32
+
18
33
  - fix null elements in AST
34
+
19
35
  ## 0.0.7
20
- - add ast interator module (ast-inerator)
21
- - 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
22
39
  - add mkBlockItem, getTextContentFromNode and query blocks from AST helpers
23
40
  - add id prop to Node type
24
41
  - toc elements support
42
+
25
43
  ## 0.0.6
44
+
26
45
  - list of supported schemas is explicit now
27
46
  - add support for create "blankline" blocks (mkBlankline)
28
47
  - enhance debug
48
+
29
49
  ## 0.0.5
50
+
30
51
  - update deps
52
+
31
53
  ## 0.0.4
54
+
32
55
  - fix npm package
33
56
  - add sometypes of blocks
34
57
  - update schema
35
-
58
+
36
59
  ## 0.0.3
60
+
37
61
  - update deps
62
+
38
63
  ## 0.0.2
64
+
39
65
  - update deps
40
66
 
41
67
  ## 0.0.1
68
+
42
69
  -- init import
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.
@@ -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;
3
+ exports.makeInterator = exports.isSemanticBlock = void 0;
4
4
  const makeQuery_1 = require("./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;
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) {
@@ -42,7 +33,7 @@ const makeInterator = (rule) => {
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
package/lib/exportAny.js CHANGED
@@ -17,8 +17,7 @@ const toAny = (options = {}, plugins = []) => {
17
17
  chain.run = run;
18
18
  chain.getPlugins = () => fns;
19
19
  return chain;
20
- function chain(root) {
21
- }
20
+ function chain(root) { }
22
21
  function use(key, fn) {
23
22
  if (key instanceof Array) {
24
23
  return (0, exports.toAny)(options, [...fns, ...fn]);
@@ -36,10 +35,18 @@ const toAny = (options = {}, plugins = []) => {
36
35
  }
37
36
  function run(src, opt_writer) {
38
37
  let res = '';
39
- const _tmp_writer = opt_writer || _writer || new writer_1.default((s) => { res = res + s; });
40
- const writer = ('function' === typeof _tmp_writer) ? new _tmp_writer((s) => { res = res + s; }) : _tmp_writer;
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;
41
48
  // src may be preparsed tree
42
- const tree = ("string" === typeof src) ? processor(src) : src;
49
+ const tree = 'string' === typeof src ? processor(src) : src;
43
50
  // make new instance of HTML with initialized plugins
44
51
  // reverse init
45
52
  let newFns = fns.slice();
@@ -56,9 +63,10 @@ const toAny = (options = {}, plugins = []) => {
56
63
  indexingTerms: writer.INDEXTERMS,
57
64
  annotations: writer.FOOTNOTES,
58
65
  defenitions: writer.DEFINITIONS,
59
- interator: result
66
+ interator: result,
60
67
  };
61
68
  }
62
69
  };
63
70
  exports.toAny = toAny;
64
71
  exports.default = exports.toAny;
72
+ //# sourceMappingURL=exportAny.js.map
package/lib/exportHtml.js CHANGED
@@ -59,7 +59,7 @@ const rules = {
59
59
  'I<>': (0, handlers_1.wrapContent)('<em>', '</em>'),
60
60
  'R<>': (0, handlers_1.wrapContent)('<var>', '</var>'),
61
61
  'K<>': (0, handlers_1.wrapContent)('<kbd>', '</kbd>'),
62
- "L<>": (0, handlers_1.setFn)((node, ctx) => {
62
+ 'L<>': (0, handlers_1.setFn)((node, ctx) => {
63
63
  let { meta } = node;
64
64
  if (meta === null) {
65
65
  meta = node.content;
@@ -67,17 +67,17 @@ const rules = {
67
67
  return (0, handlers_1.wrapContent)(`<a href="${meta}">`, `</a>`);
68
68
  }),
69
69
  /**
70
- * CSS rules for footnotes
71
-
72
- .footnote a {
73
- text-decoration: none;
74
- }
75
- .footnotes {
76
- border-top-style: solid;
77
- border-top-width: 1px;
78
- border-top-color: #eee;
79
- }
80
- */
70
+ * CSS rules for footnotes
71
+
72
+ .footnote a {
73
+ text-decoration: none;
74
+ }
75
+ .footnotes {
76
+ border-top-style: solid;
77
+ border-top-width: 1px;
78
+ border-top-color: #eee;
79
+ }
80
+ */
81
81
  'N<>': (writer, processor) => {
82
82
  writer.addListener('end', () => {
83
83
  if (!writer.hasOwnProperty('FOOTNOTES')) {
@@ -88,7 +88,7 @@ const rules = {
88
88
  return;
89
89
  } // if empty footnotes
90
90
  writer.writeRaw(`<div class="footnotes">`);
91
- footnotes.map((footnote) => {
91
+ footnotes.map(footnote => {
92
92
  writer.writeRaw(`<p><sup id="${footnote.fnId}" class="footnote"><a href="#${footnote.fnRefId}">[${footnote.gid}]</a></sup> `);
93
93
  footnote.make();
94
94
  writer.writeRaw(`</p>`);
@@ -115,7 +115,9 @@ const rules = {
115
115
  gid,
116
116
  fnRefId,
117
117
  fnId,
118
- make: () => { interator(node.content, ctx); }
118
+ make: () => {
119
+ interator(node.content, ctx);
120
+ },
119
121
  });
120
122
  };
121
123
  },
@@ -142,23 +144,23 @@ const rules = {
142
144
  writer.INDEXTERMS = [];
143
145
  }
144
146
  writer.INDEXTERMS.push({
145
- entry
147
+ entry,
146
148
  });
147
149
  },
148
150
  'Z<>': handlers_1.emptyContent,
149
- 'pod': handlers_1.content,
151
+ pod: handlers_1.content,
150
152
  ':code': (0, handlers_1.wrapContent)('<pre><code>', '</code></pre>'),
151
- 'code': (0, handlers_1.handleNested)((0, handlers_1.wrapContent)('<pre><code>', '</code></pre>')),
152
- 'data': handlers_1.emptyContent,
153
+ code: (0, handlers_1.handleNested)((0, handlers_1.wrapContent)('<pre><code>', '</code></pre>')),
154
+ data: handlers_1.emptyContent,
153
155
  ':verbatim': (writer, processor) => (node, ctx, interator) => {
154
156
  if (node.error) {
155
- writer.emit("errors", node.location);
157
+ writer.emit('errors', node.location);
156
158
  }
157
159
  interator(node.value);
158
160
  },
159
161
  ':blankline': handlers_1.emptyContent,
160
162
  ':ambient': handlers_1.emptyContent,
161
- // Directives
163
+ // Directives
162
164
  ':config': (0, handlers_1.setFn)((node, ctx) => {
163
165
  // setup context
164
166
  if (!ctx.hasOwnProperty('config'))
@@ -176,7 +178,7 @@ const rules = {
176
178
  return handlers_1.emptyContent;
177
179
  }),
178
180
  // block =para
179
- 'para': (0, handlers_1.handleNested)(handlers_1.content),
181
+ para: (0, handlers_1.handleNested)(handlers_1.content),
180
182
  ':para': (0, handlers_1.wrapContent)('<p>', '</p>'),
181
183
  'head:block': (0, handlers_1.subUse)({
182
184
  // inside head don't wrap into <p>
@@ -186,8 +188,10 @@ const rules = {
186
188
  const id = (0, ast_helpers_1.getNodeId)(node, ctx);
187
189
  return (0, handlers_1.wrapContent)(`<h${level}${id ? ` id="${id}"` : ''}>`, `</h${level}>`);
188
190
  })),
189
- ':list': (0, handlers_1.setFn)((node, ctx) => node.list === 'ordered' ? (0, handlers_1.wrapContent)('<ol>', '</ol>')
190
- : node.list === 'variable' ? (0, handlers_1.wrapContent)('<dl>', '</dl>')
191
+ ':list': (0, handlers_1.setFn)((node, ctx) => node.list === 'ordered'
192
+ ? (0, handlers_1.wrapContent)('<ol>', '</ol>')
193
+ : node.list === 'variable'
194
+ ? (0, handlers_1.wrapContent)('<dl>', '</dl>')
191
195
  : (0, handlers_1.wrapContent)('<ul>', '</ul>')),
192
196
  'item:block': (writer, processor) => (node, ctx, interator) => {
193
197
  // make text from first para
@@ -202,11 +206,11 @@ const rules = {
202
206
  writer.writeRaw('</li>');
203
207
  },
204
208
  'comment:block': handlers_1.emptyContent,
205
- 'defn': (0, handlers_1.wrapContent)('', '</dd>'),
209
+ defn: (0, handlers_1.wrapContent)('', '</dd>'),
206
210
  'term:para': (0, handlers_1.wrapContent)('<dt>', '</dt><dd>'),
207
- 'nested': (0, handlers_1.handleNested)(handlers_1.content, 1),
208
- 'output': (0, handlers_1.handleNested)((0, handlers_1.wrapContent)('<pre><samp>', '</samp></pre>'), 1),
209
- 'input': (0, handlers_1.handleNested)((0, handlers_1.wrapContent)('<pre><kbd>', '</kbd></pre>'), 1),
211
+ nested: (0, handlers_1.handleNested)(handlers_1.content, 1),
212
+ output: (0, handlers_1.handleNested)((0, handlers_1.wrapContent)('<pre><samp>', '</samp></pre>'), 1),
213
+ input: (0, handlers_1.handleNested)((0, handlers_1.wrapContent)('<pre><kbd>', '</kbd></pre>'), 1),
210
214
  // table section
211
215
  'table:block': (0, handlers_1.handleNested)((writer, processor) => (node, ctx, interator) => {
212
216
  const conf = (0, config_1.default)(node, ctx);
@@ -220,10 +224,10 @@ const rules = {
220
224
  writer.writeRaw('</table>');
221
225
  }),
222
226
  ':separator': handlers_1.emptyContent,
223
- 'table_row': (0, handlers_1.wrapContent)('<tr>', '</tr>'),
224
- 'table_cell': (0, handlers_1.wrapContent)('<td>', '</td>'),
225
- 'table_head': (0, handlers_1.subUse)({
226
- 'table_cell': (0, handlers_1.wrapContent)('<th>', '</th>')
227
+ table_row: (0, handlers_1.wrapContent)('<tr>', '</tr>'),
228
+ table_cell: (0, handlers_1.wrapContent)('<td>', '</td>'),
229
+ table_head: (0, handlers_1.subUse)({
230
+ table_cell: (0, handlers_1.wrapContent)('<th>', '</th>'),
227
231
  }, (0, handlers_1.wrapContent)('<tr>', '</tr>')),
228
232
  // Toc
229
233
  ':toc': (writer, processor) => (node, ctx, interator) => {
@@ -243,12 +247,13 @@ const rules = {
243
247
  ':toc-item': (0, handlers_1.setFn)((node, ctx) => (0, handlers_1.wrapContent)('<li class="toc-item">', '</li>')),
244
248
  ':image': (writer, processor) => (node, ctx, interator) => {
245
249
  writer.writeRaw(`<img src="${node.src}" alt="${node.alt}"/>`);
246
- }
250
+ },
247
251
  };
248
- const toHtml = (opt) => (0, exportAny_1.default)({ writer: writerHtml_1.default, ...opt }).use('*', (writer, processor) => {
252
+ const toHtml = opt => (0, exportAny_1.default)({ writer: writerHtml_1.default, ...opt })
253
+ .use('*', (writer, processor) => {
249
254
  return (node, ctx, interator) => {
250
255
  // skip warnings for semantic blocks
251
- const isSemanticBlock = (node) => {
256
+ const isSemanticBlock = node => {
252
257
  const name = node.name || '';
253
258
  const isTypeBlock = (node.type || '') === 'block';
254
259
  return isTypeBlock && name === name.toUpperCase();
@@ -267,11 +272,13 @@ const toHtml = (opt) => (0, exportAny_1.default)({ writer: writerHtml_1.default,
267
272
  writer.writeRaw('</h1>');
268
273
  }
269
274
  else {
270
- console.warn("[pod6] Unhandled node" + JSON.stringify(node, null, 2));
275
+ console.warn('[pod6] Unhandled node' + JSON.stringify(node, null, 2));
271
276
  }
272
277
  if (node.hasOwnProperty('content')) {
273
278
  interator(node.content, ctx);
274
279
  }
275
280
  };
276
- }).use(rules);
281
+ })
282
+ .use(rules);
277
283
  exports.default = toHtml;
284
+ //# sourceMappingURL=exportHtml.js.map
package/lib/grammar.js CHANGED
@@ -6393,3 +6393,4 @@ module.exports = {
6393
6393
  SyntaxError: peg$SyntaxError,
6394
6394
  parse: peg$parse
6395
6395
  };
6396
+ //# sourceMappingURL=grammar.js.map
package/lib/grammarfc.js CHANGED
@@ -3360,3 +3360,4 @@ module.exports = {
3360
3360
  SyntaxError: peg$SyntaxError,
3361
3361
  parse: peg$parse
3362
3362
  };
3363
+ //# sourceMappingURL=grammarfc.js.map
@@ -26,19 +26,23 @@ const makeAttrs = (node, ctx = {}) => {
26
26
  *
27
27
  * for example: attrs.exists('caption')
28
28
  */
29
- resfn.exists = (name) => result.hasOwnProperty(name);
29
+ resfn.exists = name => result.hasOwnProperty(name);
30
30
  /**
31
31
  * return array for prop
32
32
  *
33
33
  * for example: attrs.getAllValues('caption')
34
34
  */
35
- resfn.getAllValues = (name) => { return resfn.exists(name) ? result[name] : []; };
35
+ resfn.getAllValues = name => {
36
+ return resfn.exists(name) ? result[name] : [];
37
+ };
36
38
  /**
37
39
  * return first value or undefined if prop don't exists
38
40
  *
39
41
  * for example: attrs.exists('caption')
40
42
  */
41
- resfn.getFirstValue = (name) => { return resfn.exists(name) ? resfn.getAllValues(name)[0] : undefined; };
43
+ resfn.getFirstValue = name => {
44
+ return resfn.exists(name) ? resfn.getAllValues(name)[0] : undefined;
45
+ };
42
46
  /**
43
47
  * return key: val
44
48
  *
@@ -49,3 +53,4 @@ const makeAttrs = (node, ctx = {}) => {
49
53
  };
50
54
  exports.makeAttrs = makeAttrs;
51
55
  exports.default = exports.makeAttrs;
56
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,12 @@
1
+ export declare const core: {
2
+ ':image': {
3
+ toHtml: (writer: any) => (node: any) => void;
4
+ };
5
+ image: {
6
+ toHtml: import("./makeQuery").RuleHandler<any>;
7
+ };
8
+ root: {
9
+ toHtml: import("./makeQuery").RuleHandler<any>;
10
+ };
11
+ };
12
+ export default core;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.core = void 0;
4
+ const __1 = require("..");
5
+ exports.core = {
6
+ ':image': {
7
+ toHtml: writer => node => {
8
+ if (typeof node !== 'string' && 'type' in node && node.type === 'image') {
9
+ writer.writeRaw(`<img`);
10
+ writer.writeRaw(` src="${node.src}"`);
11
+ if (node.alt) {
12
+ writer.writeRaw(` alt="${node.alt}"`);
13
+ }
14
+ writer.writeRaw(`/>`);
15
+ }
16
+ },
17
+ },
18
+ image: {
19
+ toHtml: __1.content,
20
+ },
21
+ root: {
22
+ toHtml: __1.content,
23
+ },
24
+ };
25
+ exports.default = exports.core;
26
+ //# sourceMappingURL=corePlugins.js.map
@@ -117,3 +117,4 @@ const handleNested = (defaultHandler, implicitLevel) => {
117
117
  };
118
118
  };
119
119
  exports.handleNested = handleNested;
120
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1,18 @@
1
+ import { ParserPlugin } from '..';
2
+ /**
3
+ * Clean ids from tree
4
+ * @returns
5
+ */
6
+ export declare const cleanIds: (src?: {
7
+ skipChain: number;
8
+ podMode: number;
9
+ }) => (tree: any) => any;
10
+ /**
11
+ * Add set id to 'id' to each blocks
12
+ */
13
+ export declare const frozenIds: (src?: {
14
+ skipChain: number;
15
+ podMode: number;
16
+ }) => (tree: any) => any;
17
+ declare const middleware: ParserPlugin;
18
+ export default middleware;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.frozenIds = exports.cleanIds = void 0;
4
+ const __1 = require("..");
5
+ const nanoid_1 = require("nanoid");
6
+ /**
7
+ * Clean ids from tree
8
+ * @returns
9
+ */
10
+ const cleanIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
11
+ const transformerBlocks = (0, __1.makeTransformer)({
12
+ '*': (node, ctx, visiter) => {
13
+ if ('id' in node) {
14
+ if ('content' in node) {
15
+ node.content = visiter(node.content, ctx);
16
+ }
17
+ const { id, ...rest } = node;
18
+ return { ...rest };
19
+ }
20
+ return node;
21
+ },
22
+ });
23
+ return transformerBlocks(tree, {});
24
+ };
25
+ exports.cleanIds = cleanIds;
26
+ /**
27
+ * Add set id to 'id' to each blocks
28
+ */
29
+ const frozenIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
30
+ const transformerBlocks = (0, __1.makeTransformer)({
31
+ '*': (node, ctx, visiter) => {
32
+ if ('id' in node) {
33
+ if ('content' in node) {
34
+ node.content = visiter(node.content, ctx);
35
+ }
36
+ const { id, ...rest } = node;
37
+ return { ...rest, id: 'id' };
38
+ }
39
+ return node;
40
+ },
41
+ });
42
+ return transformerBlocks(tree, {});
43
+ };
44
+ exports.frozenIds = frozenIds;
45
+ const middleware = () => tree => {
46
+ const transformerBlocks = (0, __1.makeTransformer)({
47
+ '*': (node, ctx, visiter) => {
48
+ const addIdField = (node) => {
49
+ if (typeof node === 'object' && 'type' in node && node.type == 'block') {
50
+ if (node.name == 'caption') {
51
+ return node;
52
+ }
53
+ else if (node.name == 'head') {
54
+ return { ...node, id: (0, __1.getTextContentFromNode)(node).trim() };
55
+ }
56
+ else {
57
+ return { ...node, id: (0, nanoid_1.nanoid)() };
58
+ }
59
+ }
60
+ return node;
61
+ };
62
+ const processContent = (node) => {
63
+ if (typeof node === 'object' && 'content' in node) {
64
+ return { ...node, content: visiter(node.content, ctx) };
65
+ }
66
+ return node;
67
+ };
68
+ return processContent(addIdField(node));
69
+ },
70
+ });
71
+ return transformerBlocks(tree, {});
72
+ };
73
+ exports.default = middleware;
74
+ //# sourceMappingURL=ids.js.map