podlite 0.0.25 → 0.0.27
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 +46 -1
- package/README.md +39 -0
- package/jest.config.js +0 -1
- package/jest.tsconfig.json +1 -1
- package/lib/ids.d.ts +1 -1
- package/lib/ids.js +8 -7
- package/lib/ids.js.map +1 -0
- package/lib/index.d.ts +1 -25
- package/lib/index.js +4 -88
- package/lib/index.js.map +1 -0
- package/lib/plugins/extrnal.js +1 -0
- package/lib/plugins/extrnal.js.map +1 -0
- package/package.json +23 -14
- package/src/ids.ts +51 -50
- package/src/index.ts +8 -124
- package/src/plugins/extrnal.ts +11 -11
- package/t/fill-fixtures-md-to-pod6.ts +21 -28
- package/t/process.ts +10 -16
- package/t/test-api.ts +28 -30
- package/tsconfig.json +14 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/index.js +0 -2
- package/lib/plugins/index.d.ts +0 -12
- package/lib/plugins/index.js +0 -25
- package/src/plugins/index.ts +0 -23
- package/t/ids.test.ts +0 -31
- package/t/plugin.test.ts +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,48 +1,93 @@
|
|
|
1
1
|
# @podlite
|
|
2
2
|
|
|
3
3
|
## Upcoming
|
|
4
|
+
|
|
5
|
+
## 0.0.27
|
|
6
|
+
|
|
7
|
+
- update deps
|
|
8
|
+
|
|
9
|
+
## 0.0.26
|
|
10
|
+
|
|
11
|
+
- move plugins object to @podlite/schema package
|
|
12
|
+
|
|
4
13
|
## 0.0.25
|
|
14
|
+
|
|
5
15
|
- improve blocks linking
|
|
16
|
+
|
|
6
17
|
## 0.0.24
|
|
18
|
+
|
|
7
19
|
- clean source
|
|
20
|
+
|
|
8
21
|
## 0.0.23
|
|
22
|
+
|
|
9
23
|
- update deps
|
|
24
|
+
|
|
10
25
|
## 0.0.22
|
|
26
|
+
|
|
11
27
|
- update deps
|
|
28
|
+
|
|
12
29
|
## 0.0.21
|
|
30
|
+
|
|
13
31
|
- add =Markdown plugin
|
|
32
|
+
|
|
14
33
|
## 0.0.20
|
|
34
|
+
|
|
15
35
|
- update deps
|
|
36
|
+
|
|
16
37
|
## 0.0.19
|
|
38
|
+
|
|
17
39
|
- update depends
|
|
40
|
+
|
|
18
41
|
## 0.0.18
|
|
42
|
+
|
|
19
43
|
- update depends
|
|
44
|
+
|
|
20
45
|
## 0.0.17
|
|
46
|
+
|
|
21
47
|
- update depends
|
|
48
|
+
|
|
22
49
|
## 0.0.16
|
|
50
|
+
|
|
23
51
|
- update depends
|
|
52
|
+
|
|
24
53
|
## 0.0.15
|
|
54
|
+
|
|
25
55
|
- update depends
|
|
56
|
+
|
|
26
57
|
## 0.0.14
|
|
58
|
+
|
|
27
59
|
- update depends
|
|
60
|
+
|
|
28
61
|
## 0.0.13
|
|
62
|
+
|
|
29
63
|
- fix npm
|
|
64
|
+
|
|
30
65
|
## 0.0.12
|
|
66
|
+
|
|
31
67
|
- add id prop to AST Schema
|
|
32
68
|
- add =Toc plugin
|
|
69
|
+
|
|
33
70
|
## 0.0.10
|
|
71
|
+
|
|
34
72
|
- update deps
|
|
73
|
+
|
|
35
74
|
## 0.0.9
|
|
75
|
+
|
|
36
76
|
- fix md transforms
|
|
77
|
+
|
|
37
78
|
## 0.0.8
|
|
79
|
+
|
|
38
80
|
- update deps
|
|
39
81
|
|
|
40
82
|
## 0.0.7
|
|
83
|
+
|
|
41
84
|
- update deps
|
|
42
85
|
|
|
43
86
|
## 0.0.6
|
|
87
|
+
|
|
44
88
|
- enable tests
|
|
45
89
|
- update deps
|
|
46
90
|
|
|
47
91
|
## 0.0.5
|
|
48
|
-
|
|
92
|
+
|
|
93
|
+
- import from original repo
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
[](https://podlite.org)
|
|
4
|
+
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
**Podlite is a lightweight block-based markup language designed for flexibility and ease of use.**
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
Podlite is not limited to any specific application domain, programming language, or concept.
|
|
12
|
+
|
|
13
|
+
In addition, the support for Markdown markup as a standard block adds convenience and allows for the use of familiar syntax for text formatting.
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
Its flexibility makes it an ideal tool for creating documentation, blogs, educational materials, and much more.
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
## Useful links
|
|
22
|
+
|
|
23
|
+
📖 _Project site_: [podlite.org](https://podlite.org)
|
|
24
|
+
|
|
25
|
+
📌 _Github_: [github.com/podlite](https://github.com/podlite/) 🤩
|
|
26
|
+
|
|
27
|
+
🖥️ _Online editor_: [pod6.in](https://pod6.in/)
|
|
28
|
+
|
|
29
|
+
🖥️ _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.
|
|
30
|
+
|
|
31
|
+
📚 _Podlite for web_ - static site generator: [github.com/podlite/podlite-web](https://github.com/podlite/podlite-web)
|
|
32
|
+
|
|
33
|
+
## AUTHOR
|
|
34
|
+
|
|
35
|
+
Copyright (c) 2021-2024 Aliaksandr Zahatski
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
Released under a MIT License.
|
package/jest.config.js
CHANGED
package/jest.tsconfig.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"extends": "../../jest.tsconfig.json"}
|
|
1
|
+
{ "extends": "../../jest.tsconfig.json" }
|
package/lib/ids.d.ts
CHANGED
package/lib/ids.js
CHANGED
|
@@ -7,7 +7,7 @@ const nanoid_1 = require("nanoid");
|
|
|
7
7
|
* Clean ids from tree
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
const cleanIds = (src = { skipChain: 0, podMode: 1 }) =>
|
|
10
|
+
const cleanIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
|
|
11
11
|
const transformerBlocks = (0, schema_1.makeTransformer)({
|
|
12
12
|
'*': (node, ctx, visiter) => {
|
|
13
13
|
if ('id' in node) {
|
|
@@ -15,10 +15,10 @@ const cleanIds = (src = { skipChain: 0, podMode: 1 }) => (tree) => {
|
|
|
15
15
|
node.content = visiter(node.content, ctx);
|
|
16
16
|
}
|
|
17
17
|
const { id, ...rest } = node;
|
|
18
|
-
return { ...rest
|
|
18
|
+
return { ...rest };
|
|
19
19
|
}
|
|
20
20
|
return node;
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
22
|
});
|
|
23
23
|
return transformerBlocks(tree, {});
|
|
24
24
|
};
|
|
@@ -26,7 +26,7 @@ exports.cleanIds = cleanIds;
|
|
|
26
26
|
/**
|
|
27
27
|
* Add set id to 'id' to each blocks
|
|
28
28
|
*/
|
|
29
|
-
const frozenIds = (src = { skipChain: 0, podMode: 1 }) =>
|
|
29
|
+
const frozenIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
|
|
30
30
|
const transformerBlocks = (0, schema_1.makeTransformer)({
|
|
31
31
|
'*': (node, ctx, visiter) => {
|
|
32
32
|
if ('id' in node) {
|
|
@@ -37,12 +37,12 @@ const frozenIds = (src = { skipChain: 0, podMode: 1 }) => (tree) => {
|
|
|
37
37
|
return { ...rest, id: 'id' };
|
|
38
38
|
}
|
|
39
39
|
return node;
|
|
40
|
-
}
|
|
40
|
+
},
|
|
41
41
|
});
|
|
42
42
|
return transformerBlocks(tree, {});
|
|
43
43
|
};
|
|
44
44
|
exports.frozenIds = frozenIds;
|
|
45
|
-
const middleware = () =>
|
|
45
|
+
const middleware = () => tree => {
|
|
46
46
|
const transformerBlocks = (0, schema_1.makeTransformer)({
|
|
47
47
|
'*': (node, ctx, visiter) => {
|
|
48
48
|
const addIdField = (node) => {
|
|
@@ -66,8 +66,9 @@ const middleware = () => (tree) => {
|
|
|
66
66
|
return node;
|
|
67
67
|
};
|
|
68
68
|
return processContent(addIdField(node));
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
70
|
});
|
|
71
71
|
return transformerBlocks(tree, {});
|
|
72
72
|
};
|
|
73
73
|
exports.default = middleware;
|
|
74
|
+
//# sourceMappingURL=ids.js.map
|
package/lib/ids.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"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"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { cleanIds, frozenIds } from './ids';
|
|
3
|
-
export { cleanIds, frozenIds };
|
|
1
|
+
import { Podlite } from '@podlite/schema';
|
|
4
2
|
export interface PodliteOpt {
|
|
5
3
|
importPlugins: boolean;
|
|
6
4
|
}
|
|
7
|
-
export interface PodliteExport {
|
|
8
|
-
errors: any;
|
|
9
|
-
toString: () => string;
|
|
10
|
-
valueOf: () => string;
|
|
11
|
-
indexingTerms: any;
|
|
12
|
-
annotations: any;
|
|
13
|
-
defenitions: any;
|
|
14
|
-
interator: any;
|
|
15
|
-
}
|
|
16
|
-
export interface Podlite {
|
|
17
|
-
toAstResult: (ast: PodliteDocument) => PodliteExport;
|
|
18
|
-
(): any;
|
|
19
|
-
use: (plugin: Plugins) => Podlite;
|
|
20
|
-
parse: (text: string, opt?: {
|
|
21
|
-
skipChain: number;
|
|
22
|
-
podMode: number;
|
|
23
|
-
}) => PodliteDocument;
|
|
24
|
-
toHtml: (ast: PodliteDocument) => string;
|
|
25
|
-
toAst: (ast: PodliteDocument) => PodliteDocument;
|
|
26
|
-
getPlugins: () => Array<Plugins>;
|
|
27
|
-
}
|
|
28
|
-
export declare const toAnyRules: (method: any, allplugins: Plugins[]) => {};
|
|
29
5
|
export declare const podlite: ({ importPlugins }: PodliteOpt) => Podlite;
|
|
30
6
|
declare const VERSION: any;
|
|
31
7
|
export { VERSION as version };
|
package/lib/index.js
CHANGED
|
@@ -3,100 +3,16 @@ 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.version = exports.podlite =
|
|
6
|
+
exports.version = exports.podlite = void 0;
|
|
7
7
|
const schema_1 = require("@podlite/schema");
|
|
8
|
-
const plugins_1 = __importDefault(require("./plugins"));
|
|
9
8
|
const extrnal_1 = __importDefault(require("./plugins/extrnal"));
|
|
10
|
-
const ids_1 = __importDefault(require("./ids"));
|
|
11
|
-
const ids_2 = require("./ids");
|
|
12
|
-
Object.defineProperty(exports, "cleanIds", { enumerable: true, get: function () { return ids_2.cleanIds; } });
|
|
13
|
-
Object.defineProperty(exports, "frozenIds", { enumerable: true, get: function () { return ids_2.frozenIds; } });
|
|
14
|
-
const toAnyRules = (method, allplugins) => {
|
|
15
|
-
// make uniq plugins
|
|
16
|
-
const resultMap = allplugins.reverse().reduce((result, plugins) => {
|
|
17
|
-
for (const plugin of Object.entries(plugins)) {
|
|
18
|
-
const [key, val] = plugin;
|
|
19
|
-
if (!(key in result)) {
|
|
20
|
-
result[key] = val;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
}, {});
|
|
25
|
-
let result = {};
|
|
26
|
-
// prepare plugins for export <method>
|
|
27
|
-
for (const plugin of Object.entries(resultMap)) {
|
|
28
|
-
const [key, val = {}] = plugin;
|
|
29
|
-
//@ts-ignore
|
|
30
|
-
if (method in val) {
|
|
31
|
-
result[key] = val[method];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
exports.toAnyRules = toAnyRules;
|
|
37
9
|
const podlite = ({ importPlugins = true }) => {
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
instance.use = (onj) => {
|
|
41
|
-
for (const plugin of Object.entries(onj)) {
|
|
42
|
-
const [key, val] = plugin;
|
|
43
|
-
if (typeof val === 'function') {
|
|
44
|
-
plugins.push({ [key]: { toAst: val } });
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
plugins.push({ [key]: val });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return instance;
|
|
51
|
-
};
|
|
52
|
-
instance.parse = (text, opt = { skipChain: 0, podMode: 1 }) => {
|
|
53
|
-
const rawTree = (0, schema_1.toTree)().use(ids_1.default).parse(text, opt);
|
|
54
|
-
const root = (0, schema_1.mkRootBlock)({ margin: "" }, rawTree);
|
|
55
|
-
return root;
|
|
56
|
-
};
|
|
57
|
-
instance.toAst = (ast) => {
|
|
58
|
-
return instance.toAstResult(ast).interator;
|
|
59
|
-
};
|
|
60
|
-
instance.toAstResult = (ast) => {
|
|
61
|
-
// get plugins for Ast
|
|
62
|
-
const toAstPlugins = (0, exports.toAnyRules)('toAst', instance.getPlugins());
|
|
63
|
-
const result = (0, schema_1.toAny)().use({
|
|
64
|
-
'*': () => (node, ctx, interator) => {
|
|
65
|
-
if ('content' in node) {
|
|
66
|
-
node.content = interator(node.content, ctx);
|
|
67
|
-
}
|
|
68
|
-
return node;
|
|
69
|
-
}
|
|
70
|
-
}).use(toAstPlugins).run(ast);
|
|
71
|
-
// add second pass
|
|
72
|
-
const toAstAfterPlugins = (0, exports.toAnyRules)('toAstAfter', instance.getPlugins());
|
|
73
|
-
if (Object.keys(toAstAfterPlugins).length) {
|
|
74
|
-
const resultAfter = (0, schema_1.toAny)().use({
|
|
75
|
-
'*': () => (node, ctx, interator) => {
|
|
76
|
-
if ('content' in node) {
|
|
77
|
-
node.content = interator(node.content, ctx);
|
|
78
|
-
}
|
|
79
|
-
return node;
|
|
80
|
-
}
|
|
81
|
-
}).use(toAstAfterPlugins).run(ast);
|
|
82
|
-
return resultAfter;
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
};
|
|
86
|
-
instance.toHtml = (ast) => {
|
|
87
|
-
const toHtmlPlugins = (0, exports.toAnyRules)('toHtml', instance.getPlugins());
|
|
88
|
-
return (0, schema_1.toHtml)({}).use(toHtmlPlugins).run(ast, null);
|
|
89
|
-
};
|
|
90
|
-
instance.getPlugins = () => plugins;
|
|
91
|
-
// init core plugins
|
|
92
|
-
instance.use(plugins_1.default);
|
|
93
|
-
if (importPlugins) {
|
|
94
|
-
instance.use(extrnal_1.default);
|
|
95
|
-
}
|
|
96
|
-
return instance;
|
|
10
|
+
let plugins = importPlugins ? extrnal_1.default : {};
|
|
11
|
+
return (0, schema_1.podlitePluggable)({ plugins });
|
|
97
12
|
};
|
|
98
13
|
exports.podlite = podlite;
|
|
99
14
|
// Cannot be `import` as it's not under TS root dir
|
|
100
15
|
// https://stackoverflow.com/questions/51070138/how-to-import-package-json-into-typescript-file-without-including-it-in-the-comp
|
|
101
16
|
const { version: VERSION } = require('../package.json');
|
|
102
17
|
exports.version = VERSION;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA2D;AAC3D,gEAA+C;AAKxC,MAAM,OAAO,GAAG,CAAC,EAAE,aAAa,GAAG,IAAI,EAAc,EAAW,EAAE;IACvE,IAAI,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,iBAAe,CAAC,CAAC,CAAC,EAAE,CAAA;IAClD,OAAO,IAAA,yBAAgB,EAAC,EAAE,OAAO,EAAE,CAAC,CAAA;AACtC,CAAC,CAAA;AAHY,QAAA,OAAO,WAGnB;AAED,mDAAmD;AACnD,gIAAgI;AAEhI,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AACnC,0BAAO"}
|
package/lib/plugins/extrnal.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extrnal.js","sourceRoot":"","sources":["../../src/plugins/extrnal.ts"],"names":[],"mappings":";;AACA,0CAA+C;AAC/C,8CAAoE;AACpE,gDAAsE;AACtE,sCAA4D;AAC5D,MAAM,QAAQ,GAAY;IACxB,GAAG,wBAAe;IAClB,GAAG,yBAAgB;IACnB,GAAG,sBAAc;IACjB,GAAG,oBAAW;CACf,CAAA;AAED,kBAAe,QAAQ,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podlite",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Podlite - a block-based
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "
|
|
3
|
+
"version": "0.0.27",
|
|
4
|
+
"description": "Podlite - a lightweight block-based markup language",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "yarn g:jest --passWithNoTests",
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"watch": "run-p -r watch:*",
|
|
11
11
|
"watch:ts": "tsc -w --pretty",
|
|
12
|
-
"watch:tests": "jest --watch -t \"test\""
|
|
12
|
+
"watch:tests": "jest --watch -t \"test\"",
|
|
13
|
+
"set-linked": "yarn g:set-linked",
|
|
14
|
+
"set-unlinked": "yarn g:set-unlinked"
|
|
13
15
|
},
|
|
14
16
|
"keywords": [
|
|
15
|
-
"markdown",
|
|
16
|
-
"pod6",
|
|
17
17
|
"podlite",
|
|
18
18
|
"markup",
|
|
19
|
-
"markup-language"
|
|
19
|
+
"markup-language",
|
|
20
|
+
"markdown",
|
|
21
|
+
"pod6"
|
|
20
22
|
],
|
|
21
23
|
"author": "Aliaksandr Zahatski",
|
|
22
24
|
"license": "MIT",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/podlite/podlite/issues"
|
|
27
|
+
},
|
|
23
28
|
"dependencies": {
|
|
24
|
-
"@podlite/diagram": "^0.0.
|
|
25
|
-
"@podlite/image": "^0.0.
|
|
26
|
-
"@podlite/markdown": "0.0.
|
|
27
|
-
"@podlite/schema": "^0.0.
|
|
28
|
-
"@podlite/toc": "0.0.
|
|
29
|
+
"@podlite/diagram": "^0.0.18",
|
|
30
|
+
"@podlite/image": "^0.0.13",
|
|
31
|
+
"@podlite/markdown": "0.0.7",
|
|
32
|
+
"@podlite/schema": "^0.0.14",
|
|
33
|
+
"@podlite/toc": "0.0.7",
|
|
29
34
|
"nanoid": "3.1.30"
|
|
30
35
|
},
|
|
31
36
|
"devDependencies": {
|
|
@@ -34,8 +39,12 @@
|
|
|
34
39
|
"npm-run-all": "^4.1.5",
|
|
35
40
|
"typescript": "4.5.5"
|
|
36
41
|
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "^16.0.0 || ^17.0.0",
|
|
44
|
+
"react-dom": "^16.0.0 || ^17.0.0"
|
|
45
|
+
},
|
|
37
46
|
"publishConfig": {
|
|
38
47
|
"access": "public",
|
|
39
|
-
"main": "index.js"
|
|
48
|
+
"main": "lib/index.js"
|
|
40
49
|
}
|
|
41
50
|
}
|
package/src/ids.ts
CHANGED
|
@@ -1,75 +1,76 @@
|
|
|
1
|
-
import {BlockHead, getTextContentFromNode, makeTransformer} from
|
|
2
|
-
import { ParserPlugin
|
|
1
|
+
import { BlockHead, getTextContentFromNode, makeTransformer } from '@podlite/schema'
|
|
2
|
+
import { ParserPlugin } from '@podlite/schema'
|
|
3
3
|
import { nanoid } from 'nanoid'
|
|
4
|
-
import {
|
|
4
|
+
import { PodNode } from '@podlite/schema'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Clean ids from tree
|
|
8
|
-
* @returns
|
|
7
|
+
* Clean ids from tree
|
|
8
|
+
* @returns
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export const cleanIds =
|
|
11
|
+
export const cleanIds =
|
|
12
|
+
(src = { skipChain: 0, podMode: 1 }) =>
|
|
13
|
+
tree => {
|
|
12
14
|
const transformerBlocks = makeTransformer({
|
|
13
15
|
'*': (node, ctx, visiter) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
const {id, ...rest} = node
|
|
19
|
-
return { ...rest, }
|
|
16
|
+
if ('id' in node) {
|
|
17
|
+
if ('content' in node) {
|
|
18
|
+
node.content = visiter(node.content, ctx)
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const { id, ...rest } = node
|
|
21
|
+
return { ...rest }
|
|
22
|
+
}
|
|
23
|
+
return node
|
|
24
|
+
},
|
|
23
25
|
})
|
|
24
|
-
return transformerBlocks(tree,{})
|
|
26
|
+
return transformerBlocks(tree, {})
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* Add set id to 'id' to each blocks
|
|
29
31
|
*/
|
|
30
|
-
export const frozenIds =
|
|
32
|
+
export const frozenIds =
|
|
33
|
+
(src = { skipChain: 0, podMode: 1 }) =>
|
|
34
|
+
tree => {
|
|
31
35
|
const transformerBlocks = makeTransformer({
|
|
32
36
|
'*': (node, ctx, visiter) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
const {id, ...rest} = node
|
|
38
|
-
return { ...rest, id: 'id' }
|
|
37
|
+
if ('id' in node) {
|
|
38
|
+
if ('content' in node) {
|
|
39
|
+
node.content = visiter(node.content, ctx)
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const { id, ...rest } = node
|
|
42
|
+
return { ...rest, id: 'id' }
|
|
43
|
+
}
|
|
44
|
+
return node
|
|
45
|
+
},
|
|
42
46
|
})
|
|
43
|
-
return transformerBlocks(tree,{})
|
|
44
|
-
}
|
|
45
|
-
|
|
47
|
+
return transformerBlocks(tree, {})
|
|
48
|
+
}
|
|
46
49
|
|
|
47
|
-
const middleware:ParserPlugin = () =>
|
|
48
|
-
|
|
50
|
+
const middleware: ParserPlugin = () => tree => {
|
|
49
51
|
const transformerBlocks = makeTransformer({
|
|
50
52
|
'*': (node, ctx, visiter) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
return node
|
|
68
|
-
}
|
|
69
|
-
return processContent( addIdField(node) )
|
|
53
|
+
const addIdField = (node: PodNode): PodNode => {
|
|
54
|
+
if (typeof node === 'object' && 'type' in node && node.type == 'block') {
|
|
55
|
+
if (node.name == 'caption') {
|
|
56
|
+
return node
|
|
57
|
+
} else if (node.name == 'head') {
|
|
58
|
+
return { ...node, id: getTextContentFromNode(node).trim() } as BlockHead
|
|
59
|
+
} else {
|
|
60
|
+
return { ...node, id: nanoid() } as PodNode
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return node
|
|
64
|
+
}
|
|
65
|
+
const processContent = (node: PodNode): PodNode => {
|
|
66
|
+
if (typeof node === 'object' && 'content' in node) {
|
|
67
|
+
return { ...node, content: visiter(node.content, ctx) }
|
|
70
68
|
}
|
|
69
|
+
return node
|
|
70
|
+
}
|
|
71
|
+
return processContent(addIdField(node))
|
|
72
|
+
},
|
|
71
73
|
})
|
|
72
|
-
return transformerBlocks(tree,{})
|
|
74
|
+
return transformerBlocks(tree, {})
|
|
73
75
|
}
|
|
74
76
|
export default middleware
|
|
75
|
-
|