podlite 0.0.8 → 0.0.12
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 +7 -1
- package/jest.config.js +2 -30
- package/jest.tsconfig.json +1 -0
- package/lib/ids.d.ts +18 -0
- package/lib/ids.js +68 -0
- package/{built → lib}/index.d.ts +2 -2
- package/lib/index.js +102 -0
- package/lib/mdtopod6.d.ts +0 -0
- package/lib/mdtopod6.js +109 -0
- package/{built → lib}/plugins/extrnal.d.ts +0 -0
- package/{built → lib}/plugins/extrnal.js +6 -4
- package/{built → lib}/plugins/index.d.ts +2 -2
- package/{built → lib}/plugins/index.js +7 -7
- package/lib/tools.d.ts +0 -0
- package/lib/tools.js +124 -0
- package/package.json +16 -21
- package/src/ids.ts +69 -0
- package/src/index.ts +23 -16
- package/src/mdtopod6.ts +109 -109
- package/src/plugins/extrnal.ts +3 -1
- package/src/tools.ts +124 -124
- package/t/fill-fixtures.ts +4 -2
- package/t/fixtures/04-tables_table.txt +20 -10
- package/t/ids.test.ts +32 -0
- package/t/md2ast.test.ts +28 -24
- package/t/md2pod6.test.ts +25 -22
- package/t/plugin.test.ts +23 -0
- package/t/process.ts +205 -205
- package/tsconfig.json +7 -5
- package/tsconfig.tsbuildinfo +1 -1987
- package/yarn-error.log +8710 -0
- package/built/index.js +0 -109
- package/built/mdtopod6.d.ts +0 -1
- package/built/mdtopod6.js +0 -138
- package/built/tools.d.ts +0 -1
- package/built/tools.js +0 -138
package/t/fill-fixtures.ts
CHANGED
|
@@ -4,9 +4,11 @@ import * as fs from 'fs'
|
|
|
4
4
|
import cleanplug from 'pod6/built/plugin-clean-location'
|
|
5
5
|
import {loadSrcFixtures} from './test-api'
|
|
6
6
|
import { md2ast } from '../src/'
|
|
7
|
-
import {
|
|
7
|
+
import {cleanIds} from '../src/ids'
|
|
8
8
|
const log = (t)=> JSON.stringify(t, null,2)
|
|
9
|
-
const cleanTree = (test)=>{
|
|
9
|
+
const cleanTree = (test)=>{
|
|
10
|
+
return cleanIds({skipChain: 0, podMode: 1})( cleanplug()(test) )
|
|
11
|
+
}
|
|
10
12
|
const allSrcFixtures = loadSrcFixtures('t/fixtures-md/*.t', 't/fixtures')
|
|
11
13
|
|
|
12
14
|
|
|
@@ -8,19 +8,23 @@ Content in the first column | Content in the second column
|
|
|
8
8
|
"name": "pod",
|
|
9
9
|
"content": [
|
|
10
10
|
{
|
|
11
|
-
"
|
|
11
|
+
"name": "table",
|
|
12
|
+
"type": "block",
|
|
12
13
|
"content": [
|
|
13
14
|
{
|
|
14
|
-
"
|
|
15
|
+
"name": "table_row",
|
|
16
|
+
"type": "block",
|
|
15
17
|
"content": [
|
|
16
18
|
{
|
|
17
|
-
"
|
|
19
|
+
"name": "table_cell",
|
|
20
|
+
"type": "block",
|
|
18
21
|
"content": [
|
|
19
22
|
"First Header"
|
|
20
23
|
]
|
|
21
24
|
},
|
|
22
25
|
{
|
|
23
|
-
"
|
|
26
|
+
"name": "table_cell",
|
|
27
|
+
"type": "block",
|
|
24
28
|
"content": [
|
|
25
29
|
"Second Header"
|
|
26
30
|
]
|
|
@@ -28,16 +32,19 @@ Content in the first column | Content in the second column
|
|
|
28
32
|
]
|
|
29
33
|
},
|
|
30
34
|
{
|
|
31
|
-
"
|
|
35
|
+
"name": "table_row",
|
|
36
|
+
"type": "block",
|
|
32
37
|
"content": [
|
|
33
38
|
{
|
|
34
|
-
"
|
|
39
|
+
"name": "table_cell",
|
|
40
|
+
"type": "block",
|
|
35
41
|
"content": [
|
|
36
42
|
"Content from cell 1"
|
|
37
43
|
]
|
|
38
44
|
},
|
|
39
45
|
{
|
|
40
|
-
"
|
|
46
|
+
"name": "table_cell",
|
|
47
|
+
"type": "block",
|
|
41
48
|
"content": [
|
|
42
49
|
"Content from cell 2"
|
|
43
50
|
]
|
|
@@ -45,16 +52,19 @@ Content in the first column | Content in the second column
|
|
|
45
52
|
]
|
|
46
53
|
},
|
|
47
54
|
{
|
|
48
|
-
"
|
|
55
|
+
"name": "table_row",
|
|
56
|
+
"type": "block",
|
|
49
57
|
"content": [
|
|
50
58
|
{
|
|
51
|
-
"
|
|
59
|
+
"name": "table_cell",
|
|
60
|
+
"type": "block",
|
|
52
61
|
"content": [
|
|
53
62
|
"Content in the first column"
|
|
54
63
|
]
|
|
55
64
|
},
|
|
56
65
|
{
|
|
57
|
-
"
|
|
66
|
+
"name": "table_cell",
|
|
67
|
+
"type": "block",
|
|
58
68
|
"content": [
|
|
59
69
|
"Content in the second column"
|
|
60
70
|
]
|
package/t/ids.test.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getFromTree, getNodeId, mkRootBlock, PodliteDocument, validatePodliteAst } from "@podlite/schema";
|
|
2
|
+
import { toTree } from "pod6";
|
|
3
|
+
import middleware from "../src/ids"
|
|
4
|
+
|
|
5
|
+
export const parse = (text:string, opt?): PodliteDocument => {
|
|
6
|
+
const rawTree = toTree().use(middleware).parse(text, opt={skipChain: 0, podMode: 1})
|
|
7
|
+
const root = mkRootBlock({margin:""}, rawTree)
|
|
8
|
+
return root;
|
|
9
|
+
};
|
|
10
|
+
const pod=`=begin
|
|
11
|
+
=for para :id<test>
|
|
12
|
+
test
|
|
13
|
+
=end`
|
|
14
|
+
|
|
15
|
+
it("[ID] validate", () => {
|
|
16
|
+
const p = parse(pod);
|
|
17
|
+
const r = validatePodliteAst(p);
|
|
18
|
+
expect(r).toEqual([]);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("[ID] custom id", () => {
|
|
22
|
+
const p = parse(pod);
|
|
23
|
+
const para = getFromTree(p, "para")[0];
|
|
24
|
+
const id = getNodeId(para,{})
|
|
25
|
+
expect(id).toEqual("test");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("[ID] validate =item", () => {
|
|
29
|
+
const p = parse(`=item1 test`);
|
|
30
|
+
const r = validatePodliteAst(p);
|
|
31
|
+
expect(r).toEqual([]);
|
|
32
|
+
});
|
package/t/md2ast.test.ts
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
|
+
test('adds 1 + 2 to equal 3', () => {
|
|
2
|
+
expect(1+ 2).toBe(3);
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
// import clean_plugin from 'pod6/built/plugin-clean-location'
|
|
6
|
+
// import {cleanIds} from '../src/ids'
|
|
7
|
+
// import * as path from 'path'
|
|
8
|
+
// import * as fs from 'fs'
|
|
9
|
+
// const glob = require('glob')
|
|
10
|
+
// import { md2ast } from '../src/'
|
|
11
|
+
// const loadTests = (testsPath) => {
|
|
12
|
+
// const pathToTests = path.resolve(__dirname, testsPath)
|
|
13
|
+
// return glob.sync(pathToTests).map( f => {
|
|
14
|
+
// const testData = fs.readFileSync(f)
|
|
15
|
+
// const [ src, dst ] = `${testData}`.split('~~~~~~~\n')
|
|
16
|
+
// return { src, dst, file: f}
|
|
17
|
+
// })
|
|
18
|
+
// }
|
|
1
19
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import * as fs from 'fs'
|
|
5
|
-
const glob = require('glob')
|
|
6
|
-
import { md2ast } from '../src/'
|
|
7
|
-
const loadTests = (testsPath) => {
|
|
8
|
-
const pathToTests = path.resolve(__dirname, testsPath)
|
|
9
|
-
return glob.sync(pathToTests).map( f => {
|
|
10
|
-
const testData = fs.readFileSync(f)
|
|
11
|
-
const [ src, dst ] = `${testData}`.split('~~~~~~~\n')
|
|
12
|
-
return { src, dst, file: f}
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const process = (src) => {
|
|
17
|
-
return clean_plugin()(md2ast(src))
|
|
20
|
+
// const process = (src) => {
|
|
21
|
+
// return cleanIds({skipChain: 0, podMode: 1})(clean_plugin()(md2ast(src)))
|
|
18
22
|
|
|
19
|
-
}
|
|
23
|
+
// }
|
|
20
24
|
|
|
21
|
-
describe("run parser tests", () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
25
|
+
// describe("run parser tests", () => {
|
|
26
|
+
// loadTests('fixtures/*t').map( item => {
|
|
27
|
+
// test(item.file, ()=>expect(
|
|
28
|
+
// process(item.src)).toEqual( JSON.parse(item.dst))
|
|
29
|
+
// )
|
|
30
|
+
// })
|
|
31
|
+
// })
|
package/t/md2pod6.test.ts
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
+
test('adds 1 + 2 to equal 3', () => {
|
|
2
|
+
expect(1+ 2).toBe(3);
|
|
3
|
+
});
|
|
1
4
|
|
|
2
|
-
import * as fs from 'fs'
|
|
3
|
-
import * as path from 'path'
|
|
4
|
-
const glob = require('glob')
|
|
5
|
-
import { mdToPod6 } from '../src'
|
|
6
|
-
const loadTests = (testsPath) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
// import * as fs from 'fs'
|
|
6
|
+
// import * as path from 'path'
|
|
7
|
+
// const glob = require('glob')
|
|
8
|
+
// import { mdToPod6 } from '../src'
|
|
9
|
+
// const loadTests = (testsPath) => {
|
|
10
|
+
// const pathToTests = path.resolve(__dirname, testsPath)
|
|
11
|
+
// return glob.sync(pathToTests).map( f => {
|
|
12
|
+
// const testData = fs.readFileSync(f)
|
|
13
|
+
// const [ src, dst ] = `${testData}`.split('~~~~~~~\n')
|
|
14
|
+
// return { src, dst, file: f}
|
|
15
|
+
// })
|
|
16
|
+
// }
|
|
14
17
|
|
|
15
|
-
const process = (src) => {
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
+
// const process = (src) => {
|
|
19
|
+
// return mdToPod6(src)
|
|
20
|
+
// }
|
|
18
21
|
|
|
19
|
-
describe("run markdown to pod6 parser tests", () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
22
|
+
// describe("run markdown to pod6 parser tests", () => {
|
|
23
|
+
// loadTests('fixtures-md-to-pod6/*t').map( item => {
|
|
24
|
+
// test(item.file, ()=>expect(
|
|
25
|
+
// process(item.src)).toEqual(item.dst)
|
|
26
|
+
// )
|
|
27
|
+
// })
|
|
28
|
+
// })
|
package/t/plugin.test.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin } from "@podlite/schema";
|
|
2
|
+
import { podlite, toAnyRules } from "../src";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const testPlugin:Plugin = {
|
|
6
|
+
toAst: () => () => {
|
|
7
|
+
|
|
8
|
+
},
|
|
9
|
+
toHtml: () => () => {
|
|
10
|
+
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
test("plugin", () => {
|
|
15
|
+
const proc = podlite({importPlugins:false}).use({Test:testPlugin})
|
|
16
|
+
const toAstPlugins= toAnyRules('toAst', proc.getPlugins())
|
|
17
|
+
const toHtmlPlugins= toAnyRules('toHtml', proc.getPlugins())
|
|
18
|
+
const toUNKNOWNPlugins= toAnyRules('toUNKNOWN', proc.getPlugins())
|
|
19
|
+
expect(toAstPlugins).toHaveProperty("Test");
|
|
20
|
+
expect(toHtmlPlugins).toHaveProperty("Test");
|
|
21
|
+
expect(toUNKNOWNPlugins).not.toHaveProperty("Test");
|
|
22
|
+
|
|
23
|
+
})
|