podlite 0.0.26 → 0.0.28

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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Upcoming
4
4
 
5
+ ## 0.0.27
6
+
7
+ - update deps
8
+
5
9
  ## 0.0.26
6
10
 
7
11
  - move plugins object to @podlite/schema package
package/esm/ids.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { ParserPlugin } from '@podlite/schema';
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;
package/esm/ids.js ADDED
@@ -0,0 +1,69 @@
1
+ import { getTextContentFromNode, makeTransformer } from '@podlite/schema';
2
+ import { nanoid } from 'nanoid';
3
+ /**
4
+ * Clean ids from tree
5
+ * @returns
6
+ */
7
+ export const cleanIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
8
+ const transformerBlocks = makeTransformer({
9
+ '*': (node, ctx, visiter) => {
10
+ if ('id' in node) {
11
+ if ('content' in node) {
12
+ node.content = visiter(node.content, ctx);
13
+ }
14
+ const { id, ...rest } = node;
15
+ return { ...rest };
16
+ }
17
+ return node;
18
+ },
19
+ });
20
+ return transformerBlocks(tree, {});
21
+ };
22
+ /**
23
+ * Add set id to 'id' to each blocks
24
+ */
25
+ export const frozenIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
26
+ const transformerBlocks = makeTransformer({
27
+ '*': (node, ctx, visiter) => {
28
+ if ('id' in node) {
29
+ if ('content' in node) {
30
+ node.content = visiter(node.content, ctx);
31
+ }
32
+ const { id, ...rest } = node;
33
+ return { ...rest, id: 'id' };
34
+ }
35
+ return node;
36
+ },
37
+ });
38
+ return transformerBlocks(tree, {});
39
+ };
40
+ const middleware = () => tree => {
41
+ const transformerBlocks = makeTransformer({
42
+ '*': (node, ctx, visiter) => {
43
+ const addIdField = (node) => {
44
+ if (typeof node === 'object' && 'type' in node && node.type == 'block') {
45
+ if (node.name == 'caption') {
46
+ return node;
47
+ }
48
+ else if (node.name == 'head') {
49
+ return { ...node, id: getTextContentFromNode(node).trim() };
50
+ }
51
+ else {
52
+ return { ...node, id: nanoid() };
53
+ }
54
+ }
55
+ return node;
56
+ };
57
+ const processContent = (node) => {
58
+ if (typeof node === 'object' && 'content' in node) {
59
+ return { ...node, content: visiter(node.content, ctx) };
60
+ }
61
+ return node;
62
+ };
63
+ return processContent(addIdField(node));
64
+ },
65
+ });
66
+ return transformerBlocks(tree, {});
67
+ };
68
+ export default middleware;
69
+ //# sourceMappingURL=ids.js.map
package/esm/ids.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,sBAAsB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEpF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B;;;GAGG;AAEH,MAAM,CAAC,MAAM,QAAQ,GACnB,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CACvC,IAAI,CAAC,EAAE;IACL,MAAM,iBAAiB,GAAG,eAAe,CAAC;QACxC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;YAC1B,IAAI,IAAI,IAAI,IAAI,EAAE;gBAChB,IAAI,SAAS,IAAI,IAAI,EAAE;oBACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;iBAC1C;gBACD,MAA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AI,OAAO,EAAE;oBACtE,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,EAAE;wBAC1B,OAAO,IAAI,CAAA;qBACZ;yBAAM,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM,EAAE;wBAC9B,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAe,CAAA;qBACzE;yBAAM;wBACL,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAa,CAAA;qBAC5C;iBACF;gBACD,OAAO,IAAI,CAAA;YACb,CAAC,CAAA;YACD,MAAM,cAAc,GAAG,CAAC,IAAa,EAAW,EAAE;gBAChD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,IAAI,IAAI,EAAE;oBACjD,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAA;iBACxD;gBACD,OAAO,IAAI,CAAA;YACb,CAAC,CAAA;YACD,OAAO,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;QACzC,CAAC;KACF,CAAC,CAAA;IACF,OAAO,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC,CAAA;AACD,eAAe,UAAU,CAAA"}
package/esm/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { Podlite } from '@podlite/schema';
2
+ export interface PodliteOpt {
3
+ importPlugins: boolean;
4
+ }
5
+ export declare const podlite: ({ importPlugins }: PodliteOpt) => Podlite;
6
+ declare const VERSION: any;
7
+ export { VERSION as version };
package/esm/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { podlitePluggable } from '@podlite/schema';
2
+ import externalPlugins from './plugins/extrnal';
3
+ export const podlite = ({ importPlugins = true }) => {
4
+ let plugins = importPlugins ? externalPlugins : {};
5
+ return podlitePluggable({ plugins });
6
+ };
7
+ // Cannot be `import` as it's not under TS root dir
8
+ // https://stackoverflow.com/questions/51070138/how-to-import-package-json-into-typescript-file-without-including-it-in-the-comp
9
+ const { version: VERSION } = require('../package.json');
10
+ export { VERSION as version };
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAW,MAAM,iBAAiB,CAAA;AAC3D,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAK/C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,aAAa,GAAG,IAAI,EAAc,EAAW,EAAE;IACvE,IAAI,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAA;IAClD,OAAO,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;AACtC,CAAC,CAAA;AAED,mDAAmD;AACnD,gIAAgI;AAEhI,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AACvD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Plugins } from '@podlite/schema';
2
+ declare const external: Plugins;
3
+ export default external;
@@ -0,0 +1,12 @@
1
+ import { PluginRegister } from '@podlite/image';
2
+ import { PluginRegister as DiagramRegister } from '@podlite/diagram';
3
+ import { PluginRegister as MarkdownRegister } from '@podlite/markdown';
4
+ import { PluginRegister as TocRegister } from '@podlite/toc';
5
+ const external = {
6
+ ...DiagramRegister,
7
+ ...MarkdownRegister,
8
+ ...PluginRegister,
9
+ ...TocRegister,
10
+ };
11
+ export default external;
12
+ //# sourceMappingURL=extrnal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extrnal.js","sourceRoot":"","sources":["../../src/plugins/extrnal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACpE,OAAO,EAAE,cAAc,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAAE,cAAc,IAAI,WAAW,EAAE,MAAM,cAAc,CAAA;AAC5D,MAAM,QAAQ,GAAY;IACxB,GAAG,eAAe;IAClB,GAAG,gBAAgB;IACnB,GAAG,cAAc;IACjB,GAAG,WAAW;CACf,CAAA;AAED,eAAe,QAAQ,CAAA"}
package/package.json CHANGED
@@ -1,31 +1,41 @@
1
1
  {
2
2
  "name": "podlite",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "Podlite - a lightweight block-based markup language",
5
- "main": "./lib/index.js",
6
- "types": "./lib/index.d.ts",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "yarn g:jest --passWithNoTests",
9
- "build": "tsc",
9
+ "build": "yarn g:build",
10
10
  "watch": "run-p -r watch:*",
11
11
  "watch:ts": "tsc -w --pretty",
12
12
  "watch:tests": "jest --watch -t \"test\""
13
13
  },
14
+ "files": [
15
+ "lib",
16
+ "esm",
17
+ "README.md",
18
+ "CHANGELOG.md",
19
+ "LICENSE"
20
+ ],
14
21
  "keywords": [
15
- "markdown",
16
- "pod6",
17
22
  "podlite",
18
23
  "markup",
19
- "markup-language"
24
+ "markup-language",
25
+ "markdown",
26
+ "pod6"
20
27
  ],
21
28
  "author": "Aliaksandr Zahatski",
22
29
  "license": "MIT",
30
+ "bugs": {
31
+ "url": "https://github.com/podlite/podlite/issues"
32
+ },
23
33
  "dependencies": {
24
- "@podlite/diagram": "^0.0.17",
25
- "@podlite/image": "^0.0.12",
26
- "@podlite/markdown": "0.0.6",
27
- "@podlite/schema": "^0.0.13",
28
- "@podlite/toc": "0.0.6",
34
+ "@podlite/diagram": "^0.0.19",
35
+ "@podlite/image": "^0.0.14",
36
+ "@podlite/markdown": "0.0.8",
37
+ "@podlite/schema": "^0.0.15",
38
+ "@podlite/toc": "0.0.8",
29
39
  "nanoid": "3.1.30"
30
40
  },
31
41
  "devDependencies": {
@@ -40,6 +50,9 @@
40
50
  },
41
51
  "publishConfig": {
42
52
  "access": "public",
43
- "main": "./lib/index.js"
44
- }
53
+ "main": "lib/index.js",
54
+ "types": "./lib/index.d.ts",
55
+ "module": "./esm/index.js"
56
+ },
57
+ "module": "./esm/index.js"
45
58
  }
package/jest.config.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('../../jest.config')
@@ -1 +0,0 @@
1
- { "extends": "../../jest.tsconfig.json" }
package/src/ids.ts DELETED
@@ -1,76 +0,0 @@
1
- import { BlockHead, getTextContentFromNode, makeTransformer } from '@podlite/schema'
2
- import { ParserPlugin } from '@podlite/schema'
3
- import { nanoid } from 'nanoid'
4
- import { PodNode } from '@podlite/schema'
5
-
6
- /**
7
- * Clean ids from tree
8
- * @returns
9
- */
10
-
11
- export const cleanIds =
12
- (src = { skipChain: 0, podMode: 1 }) =>
13
- tree => {
14
- const transformerBlocks = makeTransformer({
15
- '*': (node, ctx, visiter) => {
16
- if ('id' in node) {
17
- if ('content' in node) {
18
- node.content = visiter(node.content, ctx)
19
- }
20
- const { id, ...rest } = node
21
- return { ...rest }
22
- }
23
- return node
24
- },
25
- })
26
- return transformerBlocks(tree, {})
27
- }
28
-
29
- /**
30
- * Add set id to 'id' to each blocks
31
- */
32
- export const frozenIds =
33
- (src = { skipChain: 0, podMode: 1 }) =>
34
- tree => {
35
- const transformerBlocks = makeTransformer({
36
- '*': (node, ctx, visiter) => {
37
- if ('id' in node) {
38
- if ('content' in node) {
39
- node.content = visiter(node.content, ctx)
40
- }
41
- const { id, ...rest } = node
42
- return { ...rest, id: 'id' }
43
- }
44
- return node
45
- },
46
- })
47
- return transformerBlocks(tree, {})
48
- }
49
-
50
- const middleware: ParserPlugin = () => tree => {
51
- const transformerBlocks = makeTransformer({
52
- '*': (node, ctx, visiter) => {
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) }
68
- }
69
- return node
70
- }
71
- return processContent(addIdField(node))
72
- },
73
- })
74
- return transformerBlocks(tree, {})
75
- }
76
- export default middleware
package/src/index.ts DELETED
@@ -1,16 +0,0 @@
1
- import { podlitePluggable, Podlite } from '@podlite/schema'
2
- import externalPlugins from './plugins/extrnal'
3
- export interface PodliteOpt {
4
- importPlugins: boolean
5
- }
6
-
7
- export const podlite = ({ importPlugins = true }: PodliteOpt): Podlite => {
8
- let plugins = importPlugins ? externalPlugins : {}
9
- return podlitePluggable({ plugins })
10
- }
11
-
12
- // Cannot be `import` as it's not under TS root dir
13
- // https://stackoverflow.com/questions/51070138/how-to-import-package-json-into-typescript-file-without-including-it-in-the-comp
14
-
15
- const { version: VERSION } = require('../package.json')
16
- export { VERSION as version }
@@ -1,13 +0,0 @@
1
- import { Plugins } from '@podlite/schema'
2
- import { PluginRegister } from '@podlite/image'
3
- import { PluginRegister as DiagramRegister } from '@podlite/diagram'
4
- import { PluginRegister as MarkdownRegister } from '@podlite/markdown'
5
- import { PluginRegister as TocRegister } from '@podlite/toc'
6
- const external: Plugins = {
7
- ...DiagramRegister,
8
- ...MarkdownRegister,
9
- ...PluginRegister,
10
- ...TocRegister,
11
- }
12
-
13
- export default external
@@ -1,28 +0,0 @@
1
- import * as fs from 'fs'
2
-
3
- import { loadSrcFixtures } from './test-api'
4
- import { mdToPod6 } from '../src'
5
- const log = t => JSON.stringify(t, null, 2)
6
- const allSrcFixtures = loadSrcFixtures('t/fixtures-md/*.t', 't/fixtures-md-to-pod6')
7
-
8
- const notExistsTests = allSrcFixtures.filter(r => !fs.existsSync(r.testFile))
9
- const byName = allSrcFixtures.filter(r => r.testFile === 't/fixtures/00-main_links.txt1')
10
-
11
- // get fixture to test
12
- const fixture = byName[0] ? byName[0] : notExistsTests && notExistsTests[0] ? notExistsTests[0] : null
13
- if (1 && fixture) {
14
- console.log([fixture.testFile, '\n.\n', fixture.text, '.\n'].join(''))
15
- const test = mdToPod6(fixture.text, {})
16
- if (fixture.testFile === 't/fixtures-md-to-pod6/01-node-api_1.txt') {
17
- console.log('s')
18
- const saveTest = (filename, src, tree) => {
19
- fs.writeFileSync(filename, [src, tree].join('~~~~~~~\n'))
20
- }
21
- // saveTest(fixture.testFile, fixture.text, test)
22
- console.log('sadasd')
23
- }
24
- console.log(test)
25
- // console.log(JSON.stringify(test ,null, 2))
26
- } else {
27
- console.log('no new fixtures')
28
- }
@@ -1,12 +0,0 @@
1
- ## build
2
-
3
- Generate JavaScript documentation as a list of parsed JSDoc
4
- comments, given a root file as a path.
5
- ~~~~~~~
6
- =begin pod
7
- =head2 build
8
- =begin para
9
- Generate JavaScript documentation as a list of parsed JSDoc
10
- comments, given a root file as a path.
11
- =end para
12
- =end pod
@@ -1,18 +0,0 @@
1
- ### Parameters
2
-
3
- - `comments` **[Array][17]<[Object][19]>** parsed comments
4
- - `args` **[Object][19]** Options that can customize the output
5
- ~~~~~~~
6
- =begin pod
7
- =head3 Parameters
8
- =begin item1 :numbered
9
- =begin para
10
- C<comments> B<L<Array|><L<Object|>>> parsed comments
11
- =end para
12
- =end item1
13
- =begin item1 :numbered
14
- =begin para
15
- C<args> B<L<Object|>> Options that can customize the output
16
- =end para
17
- =end item1
18
- =end pod
@@ -1,10 +0,0 @@
1
- ![foo](/url "title")
2
- ~~~~~~~
3
- =begin pod
4
- =begin para
5
- =begin Image :title('title') :alt('foo')
6
- /url
7
- =end Image
8
-
9
- =end para
10
- =end pod
@@ -1,7 +0,0 @@
1
- [#raku IRC channel](https://raku.org/community/irc)
2
- ~~~~~~~
3
- =begin pod
4
- =begin para
5
- L<#raku IRC channel|https://raku.org/community/irc>
6
- =end para
7
- =end pod
@@ -1,24 +0,0 @@
1
-
2
- ### Table of Contents
3
-
4
- - [lint][1]
5
- - [Parameters][2]
6
-
7
-
8
- [1]: #lint
9
-
10
- [2]: #parameters
11
- ~~~~~~~
12
- =begin pod
13
- =head3 Table of Contents
14
- =begin item1 :numbered
15
- =begin para
16
- L<lint|#lint>
17
- =end para
18
- =begin item2 :numbered
19
- =begin para
20
- L<Parameters|#parameters>
21
- =end para
22
- =end item2
23
- =end item1
24
- =end pod