@podlite/schema 0.0.24 → 0.0.26
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 +10 -0
- package/README.md +54 -6
- package/esm/ast-helpers.d.ts +2 -0
- package/esm/ast-helpers.js +1 -0
- package/esm/ast-helpers.js.map +1 -1
- package/esm/blocks-helpers.d.ts +1 -1
- package/esm/blocks-helpers.js +2 -2
- package/esm/blocks-helpers.js.map +1 -1
- package/esm/grammar.js +44 -3
- package/esm/grammar.js.map +1 -1
- package/esm/types.d.ts +5 -1
- package/lib/ast-helpers.d.ts +2 -0
- package/lib/ast-helpers.js +3 -1
- package/lib/blocks-helpers.d.ts +1 -1
- package/lib/blocks-helpers.js +2 -2
- package/lib/grammar.js +44 -3
- package/lib/types.d.ts +5 -1
- package/package.json +5 -1
- package/schema/AstTree.json +58 -0
- package/schema/PodliteDocument.json +58 -0
package/esm/types.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export interface RulesStrict {
|
|
|
54
54
|
nested: RuleHandler<BlockNested>;
|
|
55
55
|
output: RuleHandler<BlockOutput>;
|
|
56
56
|
input: RuleHandler<BlockInput>;
|
|
57
|
+
include: RuleHandler<BlockInclude>;
|
|
57
58
|
picture: RuleHandler<BlockPicture>;
|
|
58
59
|
image: RuleHandler<BlockImage>;
|
|
59
60
|
':image': RuleHandler<Image>;
|
|
@@ -310,6 +311,9 @@ export interface BlockOutput extends Block {
|
|
|
310
311
|
export interface BlockInput extends Block {
|
|
311
312
|
name: 'input';
|
|
312
313
|
}
|
|
314
|
+
export interface BlockInclude extends Block {
|
|
315
|
+
name: 'include';
|
|
316
|
+
}
|
|
313
317
|
export interface BlockPara extends Block {
|
|
314
318
|
name: 'para';
|
|
315
319
|
}
|
|
@@ -378,7 +382,7 @@ export interface BlockFormula extends Omit<BlockNamed, 'content'> {
|
|
|
378
382
|
content: [Verbatim];
|
|
379
383
|
}
|
|
380
384
|
export declare type FormattingCodes = FormattingCodeA | FormattingCodeC | FormattingCodeB | FormattingCodeD | FormattingCodeE | FormattingCodeF | FormattingCodeI | FormattingCodeL | FormattingCodeN | FormattingCodeX | FormattingCodeZ | FormattingCodeV | FormattingCodeS | FormattingCodeAny;
|
|
381
|
-
export declare type PodNode = Ambient | BlockPod | BlockData | BlockFormula | BlockCode | BlankLine | BlockNested | BlockMarkdown | BlockOutput | BlockInput | BlockPara | BlockHead | BlockComment | BlockDefn | string | Para | Text | Code | BlockNamed | BlockAny | Verbatim | BlockTable | List | BlockConfig | BlockItem | Alias | BlockToc | BlockPicture | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
|
|
385
|
+
export declare type PodNode = Ambient | BlockPod | BlockData | BlockFormula | BlockCode | BlankLine | BlockNested | BlockMarkdown | BlockOutput | BlockInput | BlockInclude | BlockPara | BlockHead | BlockComment | BlockDefn | string | Para | Text | Code | BlockNamed | BlockAny | Verbatim | BlockTable | List | BlockConfig | BlockItem | Alias | BlockToc | BlockPicture | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
|
|
382
386
|
export declare type Node = PodNode;
|
|
383
387
|
export declare type AstTree = Array<PodNode>;
|
|
384
388
|
export declare type PodliteDocument = RootBlock;
|
package/lib/ast-helpers.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { Node } from './types';
|
|
1
2
|
export declare const getNodeId: (node: any, ctx: any) => any;
|
|
3
|
+
export declare const getSafeNodeId: (node: Node, ctx: any) => string | null;
|
|
2
4
|
export declare const makeAttrs: (node: any, ctx?: import("./helpers/config").Context) => import("./helpers/config").Attr;
|
package/lib/ast-helpers.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.makeAttrs = exports.getNodeId = void 0;
|
|
6
|
+
exports.makeAttrs = exports.getSafeNodeId = exports.getNodeId = void 0;
|
|
7
7
|
const config_1 = __importDefault(require("./helpers/config"));
|
|
8
8
|
const getNodeId = (node, ctx) => {
|
|
9
9
|
const conf = (0, config_1.default)(node, ctx);
|
|
@@ -13,5 +13,7 @@ const getNodeId = (node, ctx) => {
|
|
|
13
13
|
return node.id;
|
|
14
14
|
};
|
|
15
15
|
exports.getNodeId = getNodeId;
|
|
16
|
+
const getSafeNodeId = (node, ctx) => (0, exports.getNodeId)(node, ctx)?.toString().replace(/\s/g, '-');
|
|
17
|
+
exports.getSafeNodeId = getSafeNodeId;
|
|
16
18
|
exports.makeAttrs = config_1.default;
|
|
17
19
|
//# sourceMappingURL=ast-helpers.js.map
|
package/lib/blocks-helpers.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const mkVerbatim: (text: any) => {
|
|
|
17
17
|
type: string;
|
|
18
18
|
value: any;
|
|
19
19
|
};
|
|
20
|
-
export declare const mkToc: (content: TocList, title?: string) => Toc;
|
|
20
|
+
export declare const mkToc: (content: TocList, title?: string, location?: Location) => Toc;
|
|
21
21
|
export declare const mkTocList: (content: Array<TocItem | TocList>, level: number) => TocList;
|
|
22
22
|
export declare const mkTocItem: (content: PodNode) => TocItem;
|
|
23
23
|
export declare const mkCaption: (content: Array<Node>) => BlockCaption;
|
package/lib/blocks-helpers.js
CHANGED
|
@@ -46,8 +46,8 @@ const mkVerbatim = text => {
|
|
|
46
46
|
};
|
|
47
47
|
exports.mkVerbatim = mkVerbatim;
|
|
48
48
|
// Table of contents helpers
|
|
49
|
-
const mkToc = (content, title) => {
|
|
50
|
-
return (0, exports.mkNode)({ type: 'toc', title, content });
|
|
49
|
+
const mkToc = (content, title, location) => {
|
|
50
|
+
return (0, exports.mkNode)({ type: 'toc', title, content, location });
|
|
51
51
|
};
|
|
52
52
|
exports.mkToc = mkToc;
|
|
53
53
|
const mkTocList = (content, level) => {
|
package/lib/grammar.js
CHANGED
|
@@ -283,7 +283,8 @@ function peg$parse(input, options) {
|
|
|
283
283
|
config: [],
|
|
284
284
|
location: location()
|
|
285
285
|
};
|
|
286
|
-
}, peg$c159 = function (vmargin, name,
|
|
286
|
+
}, peg$c159 = function (vmargin, name, first_line, content_rest) {
|
|
287
|
+
const content = (first_line === "\n" ? "" : first_line) + content_rest;
|
|
287
288
|
return {
|
|
288
289
|
margin: vmargin,
|
|
289
290
|
type: 'block',
|
|
@@ -1263,6 +1264,45 @@ function peg$parse(input, options) {
|
|
|
1263
1264
|
}
|
|
1264
1265
|
return s0;
|
|
1265
1266
|
}
|
|
1267
|
+
function peg$parseraw_text_until_eol() {
|
|
1268
|
+
var s0, s1, s2, s3;
|
|
1269
|
+
s0 = peg$currPos;
|
|
1270
|
+
s1 = peg$currPos;
|
|
1271
|
+
s2 = [];
|
|
1272
|
+
s3 = peg$parseText();
|
|
1273
|
+
if (s3 !== peg$FAILED) {
|
|
1274
|
+
while (s3 !== peg$FAILED) {
|
|
1275
|
+
s2.push(s3);
|
|
1276
|
+
s3 = peg$parseText();
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
s2 = peg$FAILED;
|
|
1281
|
+
}
|
|
1282
|
+
if (s2 !== peg$FAILED) {
|
|
1283
|
+
s1 = input.substring(s1, peg$currPos);
|
|
1284
|
+
}
|
|
1285
|
+
else {
|
|
1286
|
+
s1 = s2;
|
|
1287
|
+
}
|
|
1288
|
+
if (s1 !== peg$FAILED) {
|
|
1289
|
+
s2 = peg$parseEOL();
|
|
1290
|
+
if (s2 !== peg$FAILED) {
|
|
1291
|
+
peg$savedPos = s0;
|
|
1292
|
+
s1 = peg$c34();
|
|
1293
|
+
s0 = s1;
|
|
1294
|
+
}
|
|
1295
|
+
else {
|
|
1296
|
+
peg$currPos = s0;
|
|
1297
|
+
s0 = peg$FAILED;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
else {
|
|
1301
|
+
peg$currPos = s0;
|
|
1302
|
+
s0 = peg$FAILED;
|
|
1303
|
+
}
|
|
1304
|
+
return s0;
|
|
1305
|
+
}
|
|
1266
1306
|
function peg$parseerror_para() {
|
|
1267
1307
|
var s0, s1, s2, s3, s4, s5;
|
|
1268
1308
|
s0 = peg$currPos;
|
|
@@ -5406,7 +5446,7 @@ function peg$parse(input, options) {
|
|
|
5406
5446
|
if (s4 !== peg$FAILED) {
|
|
5407
5447
|
s5 = peg$parseemptyline();
|
|
5408
5448
|
if (s5 === peg$FAILED) {
|
|
5409
|
-
s5 =
|
|
5449
|
+
s5 = peg$parseraw_text_until_eol();
|
|
5410
5450
|
}
|
|
5411
5451
|
if (s5 !== peg$FAILED) {
|
|
5412
5452
|
s6 = peg$currPos;
|
|
@@ -5476,7 +5516,7 @@ function peg$parse(input, options) {
|
|
|
5476
5516
|
}
|
|
5477
5517
|
if (s6 !== peg$FAILED) {
|
|
5478
5518
|
peg$savedPos = s0;
|
|
5479
|
-
s1 = peg$c159(s1, s3, s6);
|
|
5519
|
+
s1 = peg$c159(s1, s3, s5, s6);
|
|
5480
5520
|
s0 = s1;
|
|
5481
5521
|
}
|
|
5482
5522
|
else {
|
|
@@ -6359,6 +6399,7 @@ function peg$parse(input, options) {
|
|
|
6359
6399
|
'defn',
|
|
6360
6400
|
'formula',
|
|
6361
6401
|
'head',
|
|
6402
|
+
'include',
|
|
6362
6403
|
'input',
|
|
6363
6404
|
'item',
|
|
6364
6405
|
'markdown',
|
package/lib/types.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export interface RulesStrict {
|
|
|
54
54
|
nested: RuleHandler<BlockNested>;
|
|
55
55
|
output: RuleHandler<BlockOutput>;
|
|
56
56
|
input: RuleHandler<BlockInput>;
|
|
57
|
+
include: RuleHandler<BlockInclude>;
|
|
57
58
|
picture: RuleHandler<BlockPicture>;
|
|
58
59
|
image: RuleHandler<BlockImage>;
|
|
59
60
|
':image': RuleHandler<Image>;
|
|
@@ -310,6 +311,9 @@ export interface BlockOutput extends Block {
|
|
|
310
311
|
export interface BlockInput extends Block {
|
|
311
312
|
name: 'input';
|
|
312
313
|
}
|
|
314
|
+
export interface BlockInclude extends Block {
|
|
315
|
+
name: 'include';
|
|
316
|
+
}
|
|
313
317
|
export interface BlockPara extends Block {
|
|
314
318
|
name: 'para';
|
|
315
319
|
}
|
|
@@ -378,7 +382,7 @@ export interface BlockFormula extends Omit<BlockNamed, 'content'> {
|
|
|
378
382
|
content: [Verbatim];
|
|
379
383
|
}
|
|
380
384
|
export declare type FormattingCodes = FormattingCodeA | FormattingCodeC | FormattingCodeB | FormattingCodeD | FormattingCodeE | FormattingCodeF | FormattingCodeI | FormattingCodeL | FormattingCodeN | FormattingCodeX | FormattingCodeZ | FormattingCodeV | FormattingCodeS | FormattingCodeAny;
|
|
381
|
-
export declare type PodNode = Ambient | BlockPod | BlockData | BlockFormula | BlockCode | BlankLine | BlockNested | BlockMarkdown | BlockOutput | BlockInput | BlockPara | BlockHead | BlockComment | BlockDefn | string | Para | Text | Code | BlockNamed | BlockAny | Verbatim | BlockTable | List | BlockConfig | BlockItem | Alias | BlockToc | BlockPicture | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
|
|
385
|
+
export declare type PodNode = Ambient | BlockPod | BlockData | BlockFormula | BlockCode | BlankLine | BlockNested | BlockMarkdown | BlockOutput | BlockInput | BlockInclude | BlockPara | BlockHead | BlockComment | BlockDefn | string | Para | Text | Code | BlockNamed | BlockAny | Verbatim | BlockTable | List | BlockConfig | BlockItem | Alias | BlockToc | BlockPicture | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
|
|
382
386
|
export declare type Node = PodNode;
|
|
383
387
|
export declare type AstTree = Array<PodNode>;
|
|
384
388
|
export declare type PodliteDocument = RootBlock;
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podlite/schema",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"description": "AST tools for Podlite markup language",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"funding": {
|
|
8
|
+
"type": "opencollective",
|
|
9
|
+
"url": "https://opencollective.com/podlite"
|
|
10
|
+
},
|
|
7
11
|
"files": [
|
|
8
12
|
"lib/**/*.js",
|
|
9
13
|
"lib/**/*.d.ts",
|
package/schema/AstTree.json
CHANGED
|
@@ -141,6 +141,9 @@
|
|
|
141
141
|
{
|
|
142
142
|
"$ref": "#/definitions/BlockInput"
|
|
143
143
|
},
|
|
144
|
+
{
|
|
145
|
+
"$ref": "#/definitions/BlockInclude"
|
|
146
|
+
},
|
|
144
147
|
{
|
|
145
148
|
"$ref": "#/definitions/BlockPara"
|
|
146
149
|
},
|
|
@@ -740,6 +743,58 @@
|
|
|
740
743
|
"type"
|
|
741
744
|
]
|
|
742
745
|
},
|
|
746
|
+
"BlockInclude": {
|
|
747
|
+
"type": "object",
|
|
748
|
+
"properties": {
|
|
749
|
+
"name": {
|
|
750
|
+
"type": "string",
|
|
751
|
+
"enum": [
|
|
752
|
+
"include"
|
|
753
|
+
]
|
|
754
|
+
},
|
|
755
|
+
"type": {
|
|
756
|
+
"type": "string",
|
|
757
|
+
"enum": [
|
|
758
|
+
"block"
|
|
759
|
+
]
|
|
760
|
+
},
|
|
761
|
+
"location": {
|
|
762
|
+
"$ref": "#/definitions/Location"
|
|
763
|
+
},
|
|
764
|
+
"content": {
|
|
765
|
+
"type": "array",
|
|
766
|
+
"items": {
|
|
767
|
+
"$ref": "#/definitions/PodNode"
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
"margin": {
|
|
771
|
+
"type": "string"
|
|
772
|
+
},
|
|
773
|
+
"config": {
|
|
774
|
+
"type": "array",
|
|
775
|
+
"items": {
|
|
776
|
+
"anyOf": [
|
|
777
|
+
{
|
|
778
|
+
"$ref": "#/definitions/BrokenConfigItem"
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
"$ref": "#/definitions/ConfigItem"
|
|
782
|
+
}
|
|
783
|
+
]
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
"id": {
|
|
787
|
+
"type": "string"
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
"required": [
|
|
791
|
+
"content",
|
|
792
|
+
"location",
|
|
793
|
+
"margin",
|
|
794
|
+
"name",
|
|
795
|
+
"type"
|
|
796
|
+
]
|
|
797
|
+
},
|
|
743
798
|
"BlockPara": {
|
|
744
799
|
"type": "object",
|
|
745
800
|
"properties": {
|
|
@@ -1007,6 +1062,9 @@
|
|
|
1007
1062
|
{
|
|
1008
1063
|
"$ref": "#/definitions/BlockInput"
|
|
1009
1064
|
},
|
|
1065
|
+
{
|
|
1066
|
+
"$ref": "#/definitions/BlockInclude"
|
|
1067
|
+
},
|
|
1010
1068
|
{
|
|
1011
1069
|
"$ref": "#/definitions/BlockPara"
|
|
1012
1070
|
},
|
|
@@ -141,6 +141,9 @@
|
|
|
141
141
|
{
|
|
142
142
|
"$ref": "#/definitions/BlockInput"
|
|
143
143
|
},
|
|
144
|
+
{
|
|
145
|
+
"$ref": "#/definitions/BlockInclude"
|
|
146
|
+
},
|
|
144
147
|
{
|
|
145
148
|
"$ref": "#/definitions/BlockPara"
|
|
146
149
|
},
|
|
@@ -740,6 +743,58 @@
|
|
|
740
743
|
"type"
|
|
741
744
|
]
|
|
742
745
|
},
|
|
746
|
+
"BlockInclude": {
|
|
747
|
+
"type": "object",
|
|
748
|
+
"properties": {
|
|
749
|
+
"name": {
|
|
750
|
+
"type": "string",
|
|
751
|
+
"enum": [
|
|
752
|
+
"include"
|
|
753
|
+
]
|
|
754
|
+
},
|
|
755
|
+
"type": {
|
|
756
|
+
"type": "string",
|
|
757
|
+
"enum": [
|
|
758
|
+
"block"
|
|
759
|
+
]
|
|
760
|
+
},
|
|
761
|
+
"location": {
|
|
762
|
+
"$ref": "#/definitions/Location"
|
|
763
|
+
},
|
|
764
|
+
"content": {
|
|
765
|
+
"type": "array",
|
|
766
|
+
"items": {
|
|
767
|
+
"$ref": "#/definitions/PodNode"
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
"margin": {
|
|
771
|
+
"type": "string"
|
|
772
|
+
},
|
|
773
|
+
"config": {
|
|
774
|
+
"type": "array",
|
|
775
|
+
"items": {
|
|
776
|
+
"anyOf": [
|
|
777
|
+
{
|
|
778
|
+
"$ref": "#/definitions/BrokenConfigItem"
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
"$ref": "#/definitions/ConfigItem"
|
|
782
|
+
}
|
|
783
|
+
]
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
"id": {
|
|
787
|
+
"type": "string"
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
"required": [
|
|
791
|
+
"content",
|
|
792
|
+
"location",
|
|
793
|
+
"margin",
|
|
794
|
+
"name",
|
|
795
|
+
"type"
|
|
796
|
+
]
|
|
797
|
+
},
|
|
743
798
|
"BlockPara": {
|
|
744
799
|
"type": "object",
|
|
745
800
|
"properties": {
|
|
@@ -1007,6 +1062,9 @@
|
|
|
1007
1062
|
{
|
|
1008
1063
|
"$ref": "#/definitions/BlockInput"
|
|
1009
1064
|
},
|
|
1065
|
+
{
|
|
1066
|
+
"$ref": "#/definitions/BlockInclude"
|
|
1067
|
+
},
|
|
1010
1068
|
{
|
|
1011
1069
|
"$ref": "#/definitions/BlockPara"
|
|
1012
1070
|
},
|