podlite 0.0.9 → 0.0.13

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/src/ids.ts ADDED
@@ -0,0 +1,69 @@
1
+ import makeTransformer, {isNamedBlock} from 'pod6/built/helpers/makeTransformer'
2
+ import { Plugin, Node, nPara , AST, nText, nVerbatim } from 'pod6/built/'
3
+ import { nanoid } from 'nanoid'
4
+ import { BlockPod, PodNode } from '@podlite/schema'
5
+
6
+ /**
7
+ * Clean ids from tree
8
+ * @returns
9
+ */
10
+
11
+ export const cleanIds = (src = {skipChain: 0, podMode: 1}) =>( tree )=>{
12
+ const transformerBlocks = makeTransformer({
13
+ '*': (node, ctx, visiter) => {
14
+ if ('id' in node) {
15
+ if ( 'content' in node ) {
16
+ node.content = visiter(node.content, ctx)
17
+ }
18
+ const {id, ...rest} = node
19
+ return { ...rest, }
20
+ }
21
+ return node
22
+ }
23
+ })
24
+ return transformerBlocks(tree,{})
25
+ }
26
+
27
+ /**
28
+ * Add set id to 'id' to each blocks
29
+ */
30
+ export const frozenIds = (src = {skipChain: 0, podMode: 1}) =>( tree )=>{
31
+ const transformerBlocks = makeTransformer({
32
+ '*': (node, ctx, visiter) => {
33
+ if ('id' in node) {
34
+ if ( 'content' in node ) {
35
+ node.content = visiter(node.content, ctx)
36
+ }
37
+ const {id, ...rest} = node
38
+ return { ...rest, id: 'id' }
39
+ }
40
+ return node
41
+ }
42
+ })
43
+ return transformerBlocks(tree,{})
44
+ }
45
+
46
+
47
+ const middleware:Plugin = () =>( tree )=>{
48
+
49
+ const transformerBlocks = makeTransformer({
50
+ '*': (node, ctx, visiter) => {
51
+ const addIdField = (node:PodNode):PodNode => {
52
+ if (typeof node === 'object' && 'type' in node && node.type =='block') {
53
+ return { ...node, id: nanoid() }
54
+ }
55
+ return node
56
+ }
57
+ const processContent = (node:PodNode):PodNode => {
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
+
package/src/index.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { toTree, toHtml } from 'pod6';
2
2
  import toAny from 'pod6/built/exportAny'
3
3
  import { AstTree, Plugins, mkRootBlock, PodliteDocument } from '@podlite/schema';
4
- export * from './mdtopod6';
5
- export * from './tools'
4
+ // export * from './mdtopod6';
5
+ // export * from './tools'
6
6
  import core from './plugins';
7
7
  import externalPlugins from './plugins/extrnal'
8
-
8
+ import idMiddleware from "./ids"
9
+ import { cleanIds, frozenIds } from './ids'
10
+ export {cleanIds, frozenIds}
9
11
 
10
12
  export interface PodliteOpt {
11
13
  importPlugins: boolean
@@ -46,7 +48,8 @@ export const toAnyRules =(method, allplugins:Plugins[])=>{
46
48
  let result = {}
47
49
  // prepare plugins for export <method>
48
50
  for ( const plugin of Object.entries(resultMap) ) {
49
- const [ key, val ] = plugin
51
+ const [ key, val = {} ] = plugin
52
+ //@ts-ignore
50
53
  if ( method in val ) {
51
54
  result[key] = val[method]
52
55
  }
@@ -72,23 +75,13 @@ export const podlite = ({ importPlugins = true }:PodliteOpt):Podlite => {
72
75
  }
73
76
 
74
77
  instance.parse = ( text, opt?) => {
75
- const rawTree = toTree().parse(text, opt={skipChain: 0, podMode: 1})
78
+ const rawTree = toTree().use(idMiddleware).parse(text, opt={skipChain: 0, podMode: 1})
76
79
  const root = mkRootBlock({margin:""}, rawTree)
77
80
  return root;
78
81
  }
79
82
 
80
83
  instance.toAst = (ast) =>{
81
- // get plugins for Ast
82
- const toAstPlugins= toAnyRules('toAst', instance.getPlugins())
83
- const result = toAny().use({
84
- '*':( )=>( node, ctx, interator )=>{
85
- if ( 'content' in node ) {
86
- node.content = interator(node.content, ctx)
87
- }
88
- return node
89
- }
90
- }).use(toAstPlugins).run(ast)
91
- return <PodliteDocument>result.interator
84
+ return <PodliteDocument>instance.toAstResult(ast).interator
92
85
  }
93
86
 
94
87
  instance.toAstResult = (ast) =>{
@@ -102,6 +95,20 @@ export const podlite = ({ importPlugins = true }:PodliteOpt):Podlite => {
102
95
  return node
103
96
  }
104
97
  }).use(toAstPlugins).run(ast)
98
+ // add second pass
99
+ const toAstAfterPlugins= toAnyRules('toAstAfter', instance.getPlugins())
100
+ if (Object.keys(toAstAfterPlugins).length) {
101
+ const resultAfter:PodliteExport = toAny().use({
102
+ '*':( )=>( node, ctx, interator )=>{
103
+ if ( 'content' in node ) {
104
+ node.content = interator(node.content, ctx)
105
+ }
106
+ return node
107
+ }
108
+ }).use(toAstAfterPlugins).run(ast)
109
+ return resultAfter
110
+ }
111
+
105
112
  return result
106
113
  }
107
114
 
package/src/mdtopod6.ts CHANGED
@@ -1,113 +1,113 @@
1
- import unified from 'unified'
2
- import markdown from 'remark-parse'
3
- import toAny from 'pod6/built/exportAny'
1
+ // import unified from 'unified'
2
+ // import markdown from 'remark-parse'
3
+ // import toAny from 'pod6/built/exportAny'
4
4
 
5
- export const mdToPod6 = (src, extraRules? ) => {
6
- const md_tree = unified().use(markdown).parse(src)
7
- let definitionMap = {}
8
- toAny({processor:1})
9
- .use({'*:*':( writer, processor )=>( node, ctx, interator )=>{
10
- if (node.children) interator(node.children, { ...ctx})
11
- }})
12
- .use({':definition' : ( writer, processor )=>( node, ctx, interator )=>{
13
- definitionMap[node.identifier] = node
14
- }}).run(md_tree)
15
- const res = toAny({processor:1})
16
- .use({'*:*':( writer, processor )=>( node, ctx, interator )=>{
17
- console.warn(node)
18
- if (node.children) interator(node.children, { ...ctx})
19
- }})
5
+ // export const mdToPod6 = (src, extraRules? ) => {
6
+ // const md_tree = unified().use(markdown).parse(src)
7
+ // let definitionMap = {}
8
+ // toAny({processor:1})
9
+ // .use({'*:*':( writer, processor )=>( node, ctx, interator )=>{
10
+ // if (node.children) interator(node.children, { ...ctx})
11
+ // }})
12
+ // .use({':definition' : ( writer, processor )=>( node, ctx, interator )=>{
13
+ // definitionMap[node.identifier] = node
14
+ // }}).run(md_tree)
15
+ // const res = toAny({processor:1})
16
+ // .use({'*:*':( writer, processor )=>( node, ctx, interator )=>{
17
+ // console.warn(node)
18
+ // if (node.children) interator(node.children, { ...ctx})
19
+ // }})
20
20
 
21
- .use({
22
- ':root': ( writer, processor )=>( node, ctx, interator )=>{
23
- // handle text with content
24
- const { children, position, ...attr} = node
25
- writer.write( "=begin pod\n")
26
- interator( children, ctx )
27
- writer.write( "=end pod\n")
21
+ // .use({
22
+ // ':root': ( writer, processor )=>( node, ctx, interator )=>{
23
+ // // handle text with content
24
+ // const { children, position, ...attr} = node
25
+ // writer.write( "=begin pod\n")
26
+ // interator( children, ctx )
27
+ // writer.write( "=end pod\n")
28
28
 
29
- },
30
- ':heading' : ( writer, processor )=>( node, ctx, interator )=>{
31
- const { children, position, ...attr} = node
32
- writer.write( `=head${node.depth} `)
33
- if (children) interator( children, ctx )
34
- writer.write( "\n")
29
+ // },
30
+ // ':heading' : ( writer, processor )=>( node, ctx, interator )=>{
31
+ // const { children, position, ...attr} = node
32
+ // writer.write( `=head${node.depth} `)
33
+ // if (children) interator( children, ctx )
34
+ // writer.write( "\n")
35
35
 
36
- },
37
- ':text' : ( writer, processor )=>( node, ctx, interator )=>{
38
- const { children, position, ...attr} = node
39
- writer.writeRaw(node.value)
40
- if (children) interator( children, ctx )
41
- },
42
- ':list' : ( writer, processor )=>( node, ctx, interator )=>{
43
- // console.error(node)
44
- const savedListLevel = ctx['listLevel'] || 0
45
- const newctx = { ...ctx, listLevel:savedListLevel+1, ordered: node.ordered ? 'ordered' : 'itemized'}
46
- const { children, position, ...attr} = node
47
- if (children) interator( children, newctx )
48
- },
49
- ':listItem' : ( writer, processor )=>( node, ctx, interator )=>{
50
- const { children, position, ...attr} = node
51
- // console.error(node)
52
- writer.write(`=begin item${ctx['listLevel']} ${ctx.ordered ? ":numbered" : ''} \n`)
53
- if (children) { interator( children, ctx ) }
54
- writer.write(`=end item${ctx['listLevel']}\n`)
55
- },
56
- ':paragraph' : ( writer, processor )=>( node, ctx, interator )=>{
57
- const { children, position, ...attr} = node
58
- writer.write(`=begin para\n`)
59
- if (children) { interator( children, ctx ) }
60
- writer.write(`\n=end para\n`)
61
- },
62
- ':linkReference' : ( writer, processor )=>( node, ctx, interator )=>{
63
- // console.log(log(node))
64
- const { children, position, ...attr} = node
65
- const definition = definitionMap[attr.identifier]
66
- const meta = definition?.url || ''
67
- writer.write(`L<`)
68
- if (children) { interator( children, ctx ) }
69
- writer.write(`|${meta}>`)
70
- },
71
- ':definition' : ( writer, processor )=>( node, ctx, interator )=>{
72
- return null
73
- },
74
- ':inlineCode' : ( writer, processor )=>( node, ctx, interator )=>{
75
- const { children, position, ...attr} = node
76
- writer.write(`C<${node.value}>`)
77
- },
78
- ':strong' : ( writer, processor )=>( node, ctx, interator )=>{
79
- const { children, position, ...attr} = node
80
- writer.write(`B<`)
81
- if (children) { interator( children, ctx ) }
82
- writer.write(`>`)
83
- },
84
- ':link': ( writer, processor )=>( node, ctx, interator )=>{
85
- const { children, position, ...attr} = node
86
- writer.write(`L<`)
87
- if (children) { interator( children, ctx ) }
88
- writer.write(`|${node.url}>`)
89
- },
90
- ':image': ( writer, processor )=>( node, ctx, interator )=>{
91
- const { children, position, ...attr} = node
92
- writer.write(`=begin Image :title('${node.title}') :alt('${node.alt}')\n`)
93
- writer.write(node.url)
94
- writer.write(`\n=end Image\n`)
95
- },
96
- ':html': ( writer, processor )=>( node, ctx, interator )=>{
97
- const { children, position, ...attr} = node
98
- writer.write(`=begin Html\n`)
99
- writer.write(`${node.value}`)
100
- writer.write(`\n=end Html\n`)
101
- },
102
- ':code' : ( writer, processor )=>( node, ctx, interator )=>{
103
- // console.log(JSON.stringify(node,null,2))
104
- const { children, position, lang, ...attr} = node
105
- writer.write(`=begin code ${lang ? ':lang(\''+lang+'\')' : ""}\n`)
106
- writer.write(`${node.value}`)
107
- writer.write(`\n=end code\n`)
108
- },
109
- ...extraRules
110
- },
111
- ).run(md_tree)
112
- return res.toString()
113
- }
36
+ // },
37
+ // ':text' : ( writer, processor )=>( node, ctx, interator )=>{
38
+ // const { children, position, ...attr} = node
39
+ // writer.writeRaw(node.value)
40
+ // if (children) interator( children, ctx )
41
+ // },
42
+ // ':list' : ( writer, processor )=>( node, ctx, interator )=>{
43
+ // // console.error(node)
44
+ // const savedListLevel = ctx['listLevel'] || 0
45
+ // const newctx = { ...ctx, listLevel:savedListLevel+1, ordered: node.ordered ? 'ordered' : 'itemized'}
46
+ // const { children, position, ...attr} = node
47
+ // if (children) interator( children, newctx )
48
+ // },
49
+ // ':listItem' : ( writer, processor )=>( node, ctx, interator )=>{
50
+ // const { children, position, ...attr} = node
51
+ // // console.error(node)
52
+ // writer.write(`=begin item${ctx['listLevel']} ${ctx.ordered ? ":numbered" : ''} \n`)
53
+ // if (children) { interator( children, ctx ) }
54
+ // writer.write(`=end item${ctx['listLevel']}\n`)
55
+ // },
56
+ // ':paragraph' : ( writer, processor )=>( node, ctx, interator )=>{
57
+ // const { children, position, ...attr} = node
58
+ // writer.write(`=begin para\n`)
59
+ // if (children) { interator( children, ctx ) }
60
+ // writer.write(`\n=end para\n`)
61
+ // },
62
+ // ':linkReference' : ( writer, processor )=>( node, ctx, interator )=>{
63
+ // // console.log(log(node))
64
+ // const { children, position, ...attr} = node
65
+ // const definition = definitionMap[attr.identifier]
66
+ // const meta = definition?.url || ''
67
+ // writer.write(`L<`)
68
+ // if (children) { interator( children, ctx ) }
69
+ // writer.write(`|${meta}>`)
70
+ // },
71
+ // ':definition' : ( writer, processor )=>( node, ctx, interator )=>{
72
+ // return null
73
+ // },
74
+ // ':inlineCode' : ( writer, processor )=>( node, ctx, interator )=>{
75
+ // const { children, position, ...attr} = node
76
+ // writer.write(`C<${node.value}>`)
77
+ // },
78
+ // ':strong' : ( writer, processor )=>( node, ctx, interator )=>{
79
+ // const { children, position, ...attr} = node
80
+ // writer.write(`B<`)
81
+ // if (children) { interator( children, ctx ) }
82
+ // writer.write(`>`)
83
+ // },
84
+ // ':link': ( writer, processor )=>( node, ctx, interator )=>{
85
+ // const { children, position, ...attr} = node
86
+ // writer.write(`L<`)
87
+ // if (children) { interator( children, ctx ) }
88
+ // writer.write(`|${node.url}>`)
89
+ // },
90
+ // ':image': ( writer, processor )=>( node, ctx, interator )=>{
91
+ // const { children, position, ...attr} = node
92
+ // writer.write(`=begin Image :title('${node.title}') :alt('${node.alt}')\n`)
93
+ // writer.write(node.url)
94
+ // writer.write(`\n=end Image\n`)
95
+ // },
96
+ // ':html': ( writer, processor )=>( node, ctx, interator )=>{
97
+ // const { children, position, ...attr} = node
98
+ // writer.write(`=begin Html\n`)
99
+ // writer.write(`${node.value}`)
100
+ // writer.write(`\n=end Html\n`)
101
+ // },
102
+ // ':code' : ( writer, processor )=>( node, ctx, interator )=>{
103
+ // // console.log(JSON.stringify(node,null,2))
104
+ // const { children, position, lang, ...attr} = node
105
+ // writer.write(`=begin code ${lang ? ':lang(\''+lang+'\')' : ""}\n`)
106
+ // writer.write(`${node.value}`)
107
+ // writer.write(`\n=end code\n`)
108
+ // },
109
+ // ...extraRules
110
+ // },
111
+ // ).run(md_tree)
112
+ // return res.toString()
113
+ // }
@@ -1,9 +1,11 @@
1
1
  import {Plugins} from '@podlite/schema'
2
2
  import Image from '@podlite/image'
3
3
  import { plugin as Diagram } from '@podlite/diagram';
4
+ import Toc from '@podlite/toc';
4
5
  const external:Plugins = {
5
6
  "Image":Image,
6
- Diagram
7
+ Diagram,
8
+ Toc
7
9
  }
8
10
 
9
11
  export default external
package/src/tools.ts CHANGED
@@ -1,126 +1,126 @@
1
- import unified from 'unified'
2
- import markdown from 'remark-parse'
3
- import toAny from 'pod6/built/exportAny'
4
- import { AstTree, BlockImage, Location, mkBlock, mkFomattingCode, mkFomattingCodeL, mkVerbatim } from '@podlite/schema'
1
+ // import unified from 'unified'
2
+ // import markdown from 'remark-parse'
3
+ // import toAny from 'pod6/built/exportAny'
4
+ // import { AstTree, BlockImage, Location, mkBlock, mkFomattingCode, mkFomattingCodeL, mkVerbatim } from '@podlite/schema'
5
5
 
6
- export const md2ast = ( src, extraRules? ) :AstTree => {
7
- // first convert mardown to ast
8
- const md_tree = unified().use(markdown).parse(src)
9
- // first pass : collect linkRefs
10
- let definitionMap = {}
11
- toAny({processor:1})
12
- .use({'*:*':( writer, processor )=>( node, ctx, interator )=>{
13
- if (node.children) interator(node.children, { ...ctx})
14
- }})
15
- .use({':definition' : ( writer, processor )=>( node, ctx, interator )=>{
16
- definitionMap[node.identifier] = node
17
- }}).run(md_tree)
6
+ // export const md2ast = ( src, extraRules? ) :AstTree => {
7
+ // // first convert mardown to ast
8
+ // const md_tree = unified().use(markdown).parse(src)
9
+ // // first pass : collect linkRefs
10
+ // let definitionMap = {}
11
+ // toAny({processor:1})
12
+ // .use({'*:*':( writer, processor )=>( node, ctx, interator )=>{
13
+ // if (node.children) interator(node.children, { ...ctx})
14
+ // }})
15
+ // .use({':definition' : ( writer, processor )=>( node, ctx, interator )=>{
16
+ // definitionMap[node.identifier] = node
17
+ // }}).run(md_tree)
18
18
 
19
- // second stage - make Universal AST nodes
20
- const uast = []
21
- const res = toAny({processor:1})
22
- .use({'*:*':( writer, processor )=>( node, ctx, interator )=>{
23
- console.warn('[Podlite]')
24
- console.warn(JSON.stringify(node,null,2))
25
- if (node.children) interator(node.children, { ...ctx})
26
- }})
27
- .use({
28
- ':root' : ( writer, processor )=>( node, ctx, interator )=>{
29
- const { children, position, ...attr} = node
30
- return mkBlock({name:"pod", location:position}, interator(children, ctx))
31
- },
32
- ':heading' : ( writer, processor )=>( node, ctx, interator )=>{
33
- const { children, position, ...attr} = node
34
- return mkBlock({type:'block', level:node.depth,name:'head', location:position}, interator(children, ctx));
35
- },
36
- ':text' : ( writer, processor )=>( node, ctx, interator )=>{
37
- const { children, position, ...attr} = node
38
- return node.value
39
- // return mkNode({type:"text", value: node.value})
40
- },
41
- ':list' : ( writer, processor )=>( node, ctx, interator )=>{
42
- const savedListLevel = ctx['listLevel'] || 0
43
- const { children, position, ...attr} = node
44
- return mkBlock( { type:'list', level:savedListLevel+1, list: node.ordered ? 'ordered' : 'itemized' }, interator(children, { ...ctx, listLevel : savedListLevel + 1, ordered: node.ordered}))
45
- },
46
- ':listItem' : ( writer, processor )=>( node, ctx, interator )=>{
47
- const savedListLevel = ctx['listLevel'] || 0
48
- const { children, position, ...attr} = node
49
- return mkBlock({name: 'item', type:'block', level:ctx['listLevel'], location:position}, interator(children, { ...ctx, listLevel : savedListLevel , ordered: node.ordered}))
50
- },
51
- ':paragraph' : ( writer, processor )=>( node, ctx, interator )=>{
52
- const { children, position, ...attr} = node
53
- return mkBlock({type:'para', location:position}, interator(children, { ...ctx}))
54
- },
55
- ':linkReference' : ( writer, processor )=>( node, ctx, interator )=>{
56
- const { children, position, ...attr} = node
57
- const definition = definitionMap[attr.identifier]
58
- const meta = definition?.url || ''
59
- return mkFomattingCodeL({ meta}, interator(children, { ...ctx}))
60
- },
61
- ':definition' : ( writer, processor )=>( node, ctx, interator )=>{
62
- return null
63
- },
64
- ':inlineCode' : ( writer, processor )=>( node, ctx, interator )=>{
65
- const { children, position, ...attr} = node
66
- return mkFomattingCode({name:"C", location:position}, [node.value])
67
- },
68
- ':strong' : ( writer, processor )=>( node, ctx, interator )=>{
69
- const { children, position, ...attr} = node
70
- return mkFomattingCode({name:"B", location:position}, interator(children, { ...ctx}))
71
- },
72
- ':emphasis' : ( writer, processor )=>( node, ctx, interator )=>{
73
- const { children, position, ...attr} = node
74
- return mkFomattingCode({name:"I", location:position}, interator(children, { ...ctx}))
75
- },
76
- ':link': ( writer, processor )=>( node, ctx, interator )=>{
77
- const { children, position, ...attr} = node
78
- return mkFomattingCodeL({ meta:node.url,location:position}, interator(children, { ...ctx}))
79
- },
80
- ':html': ( writer, processor )=>( node, ctx, interator )=>{
81
- const { children, position, ...attr} = node
82
- return mkBlock({type:'block', name:'Html', location:position},[mkVerbatim(node.value)]);
83
- },
84
- ':code' : ( writer, processor )=>( node, ctx, interator )=>{
85
- const { children, position, lang, ...attr} = node
86
- let config = {}
87
- if (lang) { config = { name: 'lang', value:"lang"}}
88
- return mkBlock({type:'block', name:'code', config, location:position},[mkVerbatim(node.value)]);
89
- },
90
- ':image': ( writer, processor )=>( node, ctx, interator )=>{
91
- const { title, alt, url, position, ...attr} = node
92
- let config = []
93
- if (!!title) { config.push({ name: 'title', value:title}) }
94
- if (!!alt) { config.push({ name: 'alt', value:alt}) }
95
- return mkBlock({type:'block', name:'Image', config, location:position},[mkVerbatim(url)]);
96
- },
97
- ':thematicBreak': ( writer, processor )=>( node, ctx, interator )=>{
98
- return null
99
- },
100
- ':blockquote' : ( writer, processor )=>( node, ctx, interator )=>{
101
- const { children, position, ...attr} = node
102
- return mkBlock({type:'nested'}, interator(children, { ...ctx}))
103
- },
104
- //table section
105
- ':table' : ( writer, processor )=>( node, ctx, interator )=>{
106
- const { children, position, ...attr} = node
107
- return mkBlock({name:'table', location:position}, interator(children, { ...ctx}))
108
- },
109
- ':tableRow' : ( writer, processor )=>( node, ctx, interator )=>{
110
- const { children, position, ...attr} = node
111
- return mkBlock({name:'table_row', location:position}, interator(children, { ...ctx}))
112
- },
113
- ':tableCell' : ( writer, processor )=>( node, ctx, interator )=>{
114
- const { children, position, ...attr} = node
115
- return mkBlock({name:'table_cell', location:position}, interator(children, { ...ctx}))
116
- },
117
- ':delete': ( writer, processor )=>( node, ctx, interator )=>{
118
- return null
119
- },
120
- ':break': ( writer, processor )=>( node, ctx, interator )=>{
121
- return null
122
- },
123
- ...extraRules
124
- }).run(md_tree)
125
- return res.interator
126
- }
19
+ // // second stage - make Universal AST nodes
20
+ // const uast = []
21
+ // const res = toAny({processor:1})
22
+ // .use({'*:*':( writer, processor )=>( node, ctx, interator )=>{
23
+ // console.warn('[Podlite]')
24
+ // console.warn(JSON.stringify(node,null,2))
25
+ // if (node.children) interator(node.children, { ...ctx})
26
+ // }})
27
+ // .use({
28
+ // ':root' : ( writer, processor )=>( node, ctx, interator )=>{
29
+ // const { children, position, ...attr} = node
30
+ // return mkBlock({name:"pod", location:position}, interator(children, ctx))
31
+ // },
32
+ // ':heading' : ( writer, processor )=>( node, ctx, interator )=>{
33
+ // const { children, position, ...attr} = node
34
+ // return mkBlock({type:'block', level:node.depth,name:'head', location:position}, interator(children, ctx));
35
+ // },
36
+ // ':text' : ( writer, processor )=>( node, ctx, interator )=>{
37
+ // const { children, position, ...attr} = node
38
+ // return node.value
39
+ // // return mkNode({type:"text", value: node.value})
40
+ // },
41
+ // ':list' : ( writer, processor )=>( node, ctx, interator )=>{
42
+ // const savedListLevel = ctx['listLevel'] || 0
43
+ // const { children, position, ...attr} = node
44
+ // return mkBlock( { type:'list', level:savedListLevel+1, list: node.ordered ? 'ordered' : 'itemized' }, interator(children, { ...ctx, listLevel : savedListLevel + 1, ordered: node.ordered}))
45
+ // },
46
+ // ':listItem' : ( writer, processor )=>( node, ctx, interator )=>{
47
+ // const savedListLevel = ctx['listLevel'] || 0
48
+ // const { children, position, ...attr} = node
49
+ // return mkBlock({name: 'item', type:'block', level:ctx['listLevel'], location:position}, interator(children, { ...ctx, listLevel : savedListLevel , ordered: node.ordered}))
50
+ // },
51
+ // ':paragraph' : ( writer, processor )=>( node, ctx, interator )=>{
52
+ // const { children, position, ...attr} = node
53
+ // return mkBlock({type:'para', location:position}, interator(children, { ...ctx}))
54
+ // },
55
+ // ':linkReference' : ( writer, processor )=>( node, ctx, interator )=>{
56
+ // const { children, position, ...attr} = node
57
+ // const definition = definitionMap[attr.identifier]
58
+ // const meta = definition?.url || ''
59
+ // return mkFomattingCodeL({ meta}, interator(children, { ...ctx}))
60
+ // },
61
+ // ':definition' : ( writer, processor )=>( node, ctx, interator )=>{
62
+ // return null
63
+ // },
64
+ // ':inlineCode' : ( writer, processor )=>( node, ctx, interator )=>{
65
+ // const { children, position, ...attr} = node
66
+ // return mkFomattingCode({name:"C", location:position}, [node.value])
67
+ // },
68
+ // ':strong' : ( writer, processor )=>( node, ctx, interator )=>{
69
+ // const { children, position, ...attr} = node
70
+ // return mkFomattingCode({name:"B", location:position}, interator(children, { ...ctx}))
71
+ // },
72
+ // ':emphasis' : ( writer, processor )=>( node, ctx, interator )=>{
73
+ // const { children, position, ...attr} = node
74
+ // return mkFomattingCode({name:"I", location:position}, interator(children, { ...ctx}))
75
+ // },
76
+ // ':link': ( writer, processor )=>( node, ctx, interator )=>{
77
+ // const { children, position, ...attr} = node
78
+ // return mkFomattingCodeL({ meta:node.url,location:position}, interator(children, { ...ctx}))
79
+ // },
80
+ // ':html': ( writer, processor )=>( node, ctx, interator )=>{
81
+ // const { children, position, ...attr} = node
82
+ // return mkBlock({type:'block', name:'Html', location:position},[mkVerbatim(node.value)]);
83
+ // },
84
+ // ':code' : ( writer, processor )=>( node, ctx, interator )=>{
85
+ // const { children, position, lang, ...attr} = node
86
+ // let config = {}
87
+ // if (lang) { config = { name: 'lang', value:"lang"}}
88
+ // return mkBlock({type:'block', name:'code', config, location:position},[mkVerbatim(node.value)]);
89
+ // },
90
+ // ':image': ( writer, processor )=>( node, ctx, interator )=>{
91
+ // const { title, alt, url, position, ...attr} = node
92
+ // let config = []
93
+ // if (!!title) { config.push({ name: 'title', value:title}) }
94
+ // if (!!alt) { config.push({ name: 'alt', value:alt}) }
95
+ // return mkBlock({type:'block', name:'Image', config, location:position},[mkVerbatim(url)]);
96
+ // },
97
+ // ':thematicBreak': ( writer, processor )=>( node, ctx, interator )=>{
98
+ // return null
99
+ // },
100
+ // ':blockquote' : ( writer, processor )=>( node, ctx, interator )=>{
101
+ // const { children, position, ...attr} = node
102
+ // return mkBlock({type:'nested'}, interator(children, { ...ctx}))
103
+ // },
104
+ // //table section
105
+ // ':table' : ( writer, processor )=>( node, ctx, interator )=>{
106
+ // const { children, position, ...attr} = node
107
+ // return mkBlock({name:'table', location:position}, interator(children, { ...ctx}))
108
+ // },
109
+ // ':tableRow' : ( writer, processor )=>( node, ctx, interator )=>{
110
+ // const { children, position, ...attr} = node
111
+ // return mkBlock({name:'table_row', location:position}, interator(children, { ...ctx}))
112
+ // },
113
+ // ':tableCell' : ( writer, processor )=>( node, ctx, interator )=>{
114
+ // const { children, position, ...attr} = node
115
+ // return mkBlock({name:'table_cell', location:position}, interator(children, { ...ctx}))
116
+ // },
117
+ // ':delete': ( writer, processor )=>( node, ctx, interator )=>{
118
+ // return null
119
+ // },
120
+ // ':break': ( writer, processor )=>( node, ctx, interator )=>{
121
+ // return null
122
+ // },
123
+ // ...extraRules
124
+ // }).run(md_tree)
125
+ // return res.interator
126
+ // }