@podlite/schema 0.0.12 → 0.0.14
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.
- package/CHANGELOG.md +38 -4
- package/README.md +40 -0
- package/lib/ast-helpers.js +1 -0
- package/lib/ast-inerator.d.ts +0 -1
- package/lib/ast-inerator.js +5 -13
- package/lib/blocks-helpers.d.ts +1 -1
- package/lib/blocks-helpers.js +15 -12
- package/lib/exportAny.js +14 -6
- package/lib/exportHtml.js +43 -36
- package/lib/grammar.js +30 -21
- package/lib/grammarfc.js +1099 -243
- package/lib/helpers/config.js +8 -3
- package/lib/helpers/corePlugins.d.ts +12 -0
- package/lib/helpers/corePlugins.js +26 -0
- package/lib/helpers/handlers.js +1 -0
- package/lib/helpers/ids.d.ts +18 -0
- package/lib/helpers/ids.js +74 -0
- package/lib/helpers/makeInterator.js +6 -3
- package/lib/helpers/makeQuery.js +5 -1
- package/lib/helpers/makeQuery.test.js +32 -22
- package/lib/helpers/makeTransformer.js +7 -10
- package/lib/helpers/plugins.d.ts +2 -0
- package/lib/helpers/plugins.js +27 -0
- package/lib/index.d.ts +24 -21
- package/lib/index.js +18 -8
- package/lib/pluggableParser.d.ts +27 -0
- package/lib/pluggableParser.js +80 -0
- package/lib/plugin-clean-location.js +6 -3
- package/lib/plugin-defn-fill-term.js +7 -4
- package/lib/plugin-formatting-codes.js +41 -12
- package/lib/plugin-group-defn.js +10 -10
- package/lib/plugin-group-items.js +22 -20
- package/lib/plugin-heading.js +6 -3
- package/lib/plugin-items.js +9 -6
- package/lib/plugin-tables.js +46 -31
- package/lib/plugin-vmargin.js +5 -3
- package/lib/query-helpers.js +9 -6
- package/lib/types.d.ts +78 -70
- package/lib/types.js +1 -0
- package/lib/writer.js +22 -7
- package/lib/writerHtml.js +3 -2
- package/package.json +9 -9
- package/schema/AstTree.json +116 -0
- package/schema/PodliteDocument.json +116 -0
- package/schema/index.d.ts +3 -3
- package/index.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,42 +1,76 @@
|
|
|
1
1
|
# @podlite/schema
|
|
2
2
|
|
|
3
3
|
## Upcoming
|
|
4
|
+
|
|
5
|
+
## 0.0.14
|
|
6
|
+
|
|
7
|
+
- fix parse `=alias` and `=config` directives
|
|
8
|
+
- improve brackets support for C<> and L<> codes
|
|
9
|
+
- support for `=toc` block
|
|
10
|
+
- support for `=markdown` block
|
|
11
|
+
|
|
12
|
+
## 0.0.13
|
|
13
|
+
|
|
14
|
+
- refactor
|
|
15
|
+
- add plugin functions
|
|
16
|
+
|
|
4
17
|
## 0.0.12
|
|
18
|
+
|
|
5
19
|
- add helpers,
|
|
6
20
|
- fix parser's grammars
|
|
7
21
|
- add tests
|
|
8
22
|
- update deps
|
|
23
|
+
|
|
9
24
|
## 0.0.11
|
|
25
|
+
|
|
10
26
|
- extend API by context for react component wrap function
|
|
27
|
+
|
|
11
28
|
## 0.0.10
|
|
29
|
+
|
|
12
30
|
- fix helper for mkBlock
|
|
13
31
|
- add Strikethrough inline element support
|
|
14
32
|
- add JSX handler for plugins
|
|
33
|
+
|
|
15
34
|
## 0.0.9
|
|
16
|
-
|
|
35
|
+
|
|
36
|
+
- fix null elements in
|
|
37
|
+
|
|
17
38
|
## 0.0.8
|
|
39
|
+
|
|
18
40
|
- fix null elements in AST
|
|
41
|
+
|
|
19
42
|
## 0.0.7
|
|
20
|
-
|
|
21
|
-
- add
|
|
43
|
+
|
|
44
|
+
- add ast interator module (ast-inerator)
|
|
45
|
+
- add AST nodes for image and caption objects, add mkImage and mkCaption helpers
|
|
22
46
|
- add mkBlockItem, getTextContentFromNode and query blocks from AST helpers
|
|
23
47
|
- add id prop to Node type
|
|
24
48
|
- toc elements support
|
|
49
|
+
|
|
25
50
|
## 0.0.6
|
|
51
|
+
|
|
26
52
|
- list of supported schemas is explicit now
|
|
27
53
|
- add support for create "blankline" blocks (mkBlankline)
|
|
28
54
|
- enhance debug
|
|
55
|
+
|
|
29
56
|
## 0.0.5
|
|
57
|
+
|
|
30
58
|
- update deps
|
|
59
|
+
|
|
31
60
|
## 0.0.4
|
|
61
|
+
|
|
32
62
|
- fix npm package
|
|
33
63
|
- add sometypes of blocks
|
|
34
64
|
- update schema
|
|
35
|
-
|
|
65
|
+
|
|
36
66
|
## 0.0.3
|
|
67
|
+
|
|
37
68
|
- update deps
|
|
69
|
+
|
|
38
70
|
## 0.0.2
|
|
71
|
+
|
|
39
72
|
- update deps
|
|
40
73
|
|
|
41
74
|
## 0.0.1
|
|
75
|
+
|
|
42
76
|
-- init import
|
package/README.md
CHANGED
|
@@ -1 +1,41 @@
|
|
|
1
1
|
# @podlite/schema
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[](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.
|
package/lib/ast-helpers.js
CHANGED
package/lib/ast-inerator.d.ts
CHANGED
package/lib/ast-inerator.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeInterator = exports.isSemanticBlock =
|
|
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 =
|
|
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
|
package/lib/blocks-helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AstTree, BlockCaption, BlockItem, Location, PodNode, RootBlock, Toc, TocItem, TocList, Node, Image } from
|
|
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;
|
package/lib/blocks-helpers.js
CHANGED
|
@@ -6,7 +6,7 @@ const mkNode = (attr) => {
|
|
|
6
6
|
return { ...attr };
|
|
7
7
|
};
|
|
8
8
|
exports.mkNode = mkNode;
|
|
9
|
-
const filterNulls =
|
|
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 =
|
|
17
|
+
const type = 'block';
|
|
18
18
|
const name = attrs.name;
|
|
19
|
-
const attributes = { id: (0, nanoid_1.nanoid)(), margin:
|
|
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 = () => {
|
|
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:
|
|
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 =
|
|
36
|
-
let res = (0, exports.mkNode)({ type: 'fcode', name:
|
|
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 =
|
|
41
|
-
return (0, exports.mkNode)({
|
|
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 =
|
|
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 ||
|
|
40
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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(
|
|
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: () => {
|
|
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
|
-
|
|
151
|
+
pod: handlers_1.content,
|
|
150
152
|
':code': (0, handlers_1.wrapContent)('<pre><code>', '</code></pre>'),
|
|
151
|
-
|
|
152
|
-
|
|
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(
|
|
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
|
-
|
|
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'
|
|
190
|
-
|
|
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
|
-
|
|
209
|
+
defn: (0, handlers_1.wrapContent)('', '</dd>'),
|
|
206
210
|
'term:para': (0, handlers_1.wrapContent)('<dt>', '</dt><dd>'),
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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 =
|
|
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 =
|
|
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(
|
|
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
|
-
})
|
|
281
|
+
})
|
|
282
|
+
.use(rules);
|
|
277
283
|
exports.default = toHtml;
|
|
284
|
+
//# sourceMappingURL=exportHtml.js.map
|
package/lib/grammar.js
CHANGED
|
@@ -134,7 +134,7 @@ function peg$parse(input, options) {
|
|
|
134
134
|
type: "boolean"
|
|
135
135
|
};
|
|
136
136
|
}, peg$c88 = function (isFalse, key, value) { return { name: key, ...value }; }, peg$c89 = function (first, rest) { return rest; }, peg$c90 = function (first, cont) { return flattenDeep([...first, ...cont]); }, peg$c91 = /^[^'"]/, peg$c92 = peg$classExpectation(["'", "\""], true, false), peg$c93 = function (text) { return text; }, peg$c94 = /^[0-9]/, peg$c95 = peg$classExpectation([["0", "9"]], false, false), peg$c96 = /^[\-+]/, peg$c97 = peg$classExpectation(["-", "+"], false, false), peg$c98 = "True", peg$c99 = peg$literalExpectation("True", false), peg$c100 = function () { return true; }, peg$c101 = "False", peg$c102 = peg$literalExpectation("False", false), peg$c103 = function () { return false; }, peg$c104 = ".", peg$c105 = peg$literalExpectation(".", false), peg$c106 = /^[eE]/, peg$c107 = peg$classExpectation(["e", "E"], false, false), peg$c108 = /^["]/, peg$c109 = peg$classExpectation(["\""], false, false), peg$c110 = /^[^"]/, peg$c111 = peg$classExpectation(["\""], true, false), peg$c112 = /^[']/, peg$c113 = peg$classExpectation(["'"], false, false), peg$c114 = /^[^']/, peg$c115 = peg$classExpectation(["'"], true, false), peg$c116 = function (numberFloat) { return parseFloat(numberFloat); }, peg$c117 = function (number) { return parseInt(number, 10); }, peg$c118 = function (vmargin, name, config) {
|
|
137
|
-
return ((name.match(/code|comment|output|input|data/))
|
|
137
|
+
return ((name.match(/code|comment|output|input|markdown|toc|data/))
|
|
138
138
|
||
|
|
139
139
|
isNamedBlock(name));
|
|
140
140
|
}, peg$c119 = function (vmargin, name, config, margins, ename) { return vmargin.length === margins.length && name === ename; }, peg$c120 = function (vmargin, name, config, margins, line) { return exludeVMargin(vmargin, `${margins}${line}`); }, peg$c121 = function (vmargin, name, config, content, vmargin2, ename) { return name === ename; }, peg$c122 = function (vmargin, name, config, content, vmargin2, ename) {
|
|
@@ -261,7 +261,7 @@ function peg$parse(input, options) {
|
|
|
261
261
|
location: location(),
|
|
262
262
|
};
|
|
263
263
|
}, peg$c150 = function () { return { empty: 1 }; }, peg$c151 = /^[s]/, peg$c152 = peg$classExpectation(["s"], false, false), peg$c153 = function (line) { return { text: text(), type: "ambient1" }; }, peg$c154 = function (vmargin, name) {
|
|
264
|
-
return ((name.match(/code|comment|output|input|data/))
|
|
264
|
+
return ((name.match(/code|comment|output|input|markdown|toc|data/))
|
|
265
265
|
||
|
|
266
266
|
isNamedBlock(name));
|
|
267
267
|
}, peg$c155 = function (vmargin, name, content) {
|
|
@@ -320,7 +320,7 @@ function peg$parse(input, options) {
|
|
|
320
320
|
margin: vmargin
|
|
321
321
|
};
|
|
322
322
|
}, peg$c168 = function (vmargin, marker, name, config) {
|
|
323
|
-
return ((name.match(/code|comment|output|input|data/))
|
|
323
|
+
return ((name.match(/code|comment|output|input|markdown|toc|data/))
|
|
324
324
|
||
|
|
325
325
|
isNamedBlock(name));
|
|
326
326
|
}, peg$c169 = function (vmargin, marker, name, config, content) {
|
|
@@ -1171,25 +1171,31 @@ function peg$parse(input, options) {
|
|
|
1171
1171
|
s2 = peg$currPos;
|
|
1172
1172
|
s3 = peg$parse_();
|
|
1173
1173
|
if (s3 !== peg$FAILED) {
|
|
1174
|
-
s4 = peg$
|
|
1175
|
-
s5 = peg$parsemarkers();
|
|
1176
|
-
if (s5 !== peg$FAILED) {
|
|
1177
|
-
s6 = peg$parsestrictIdentifier();
|
|
1178
|
-
if (s6 !== peg$FAILED) {
|
|
1179
|
-
s5 = [s5, s6];
|
|
1180
|
-
s4 = s5;
|
|
1181
|
-
}
|
|
1182
|
-
else {
|
|
1183
|
-
peg$currPos = s4;
|
|
1184
|
-
s4 = peg$FAILED;
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
else {
|
|
1188
|
-
peg$currPos = s4;
|
|
1189
|
-
s4 = peg$FAILED;
|
|
1190
|
-
}
|
|
1174
|
+
s4 = peg$parsemarkerConfig();
|
|
1191
1175
|
if (s4 === peg$FAILED) {
|
|
1192
|
-
s4 = peg$
|
|
1176
|
+
s4 = peg$parsemarkerAlias();
|
|
1177
|
+
if (s4 === peg$FAILED) {
|
|
1178
|
+
s4 = peg$currPos;
|
|
1179
|
+
s5 = peg$parsemarkers();
|
|
1180
|
+
if (s5 !== peg$FAILED) {
|
|
1181
|
+
s6 = peg$parsestrictIdentifier();
|
|
1182
|
+
if (s6 !== peg$FAILED) {
|
|
1183
|
+
s5 = [s5, s6];
|
|
1184
|
+
s4 = s5;
|
|
1185
|
+
}
|
|
1186
|
+
else {
|
|
1187
|
+
peg$currPos = s4;
|
|
1188
|
+
s4 = peg$FAILED;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
else {
|
|
1192
|
+
peg$currPos = s4;
|
|
1193
|
+
s4 = peg$FAILED;
|
|
1194
|
+
}
|
|
1195
|
+
if (s4 === peg$FAILED) {
|
|
1196
|
+
s4 = peg$parsemarkerAbbreviatedBlock();
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1193
1199
|
}
|
|
1194
1200
|
if (s4 !== peg$FAILED) {
|
|
1195
1201
|
s3 = [s3, s4];
|
|
@@ -6354,11 +6360,13 @@ function peg$parse(input, options) {
|
|
|
6354
6360
|
'head',
|
|
6355
6361
|
'input',
|
|
6356
6362
|
'item',
|
|
6363
|
+
'markdown',
|
|
6357
6364
|
'nested',
|
|
6358
6365
|
'output',
|
|
6359
6366
|
'para',
|
|
6360
6367
|
'pod',
|
|
6361
6368
|
'table',
|
|
6369
|
+
'toc',
|
|
6362
6370
|
].includes(name)
|
|
6363
6371
|
||
|
|
6364
6372
|
isSemanticBlock(name)
|
|
@@ -6393,3 +6401,4 @@ module.exports = {
|
|
|
6393
6401
|
SyntaxError: peg$SyntaxError,
|
|
6394
6402
|
parse: peg$parse
|
|
6395
6403
|
};
|
|
6404
|
+
//# sourceMappingURL=grammar.js.map
|