@@ -26,15 +26,19 @@ export const stringifyMDX = mdast =>
2626const paragraph = {
2727 match : node => node . object === 'block' && node . type === 'paragraph' ,
2828 matchMdast : node => node . type === 'paragraph' ,
29- fromMdast : ( node , index , parent , { visitChildren } ) => ( {
30- object : 'block' ,
31- type : 'paragraph' ,
32- nodes : visitChildren ( node )
33- } ) ,
34- toMdast : ( object , index , parent , { visitChildren } ) => ( {
35- type : 'paragraph' ,
36- children : visitChildren ( object )
37- } )
29+ fromMdast : ( node , _index , _parent , { visitChildren } ) => {
30+ return {
31+ object : 'block' ,
32+ type : 'paragraph' ,
33+ nodes : visitChildren ( node )
34+ }
35+ } ,
36+ toMdast : ( object , _index , _parent , { visitChildren } ) => {
37+ return {
38+ type : 'paragraph' ,
39+ children : visitChildren ( object )
40+ }
41+ }
3842}
3943
4044const image = {
@@ -75,6 +79,41 @@ const blockQuote = {
7579 } )
7680}
7781
82+ const bulletedList = {
83+ match : node => node . object === 'block' && node . type === 'bulleted-list' ,
84+ matchMdast : node => node . type === 'list' && ! node . ordered ,
85+ fromMdast : ( node , _index , _parent , { visitChildren } ) => ( {
86+ object : 'block' ,
87+ type : 'bulleted-list' ,
88+ nodes : visitChildren ( node )
89+ } ) ,
90+ toMdast : ( object , _index , _parent , { visitChildren } ) => {
91+ return {
92+ type : 'list' ,
93+ ordered : false ,
94+ children : visitChildren ( object )
95+ }
96+ }
97+ }
98+
99+ const listItem = {
100+ match : node => node . object === 'block' && node . type === 'list-item' ,
101+ matchMdast : node => node . type === 'listItem' ,
102+ fromMdast : ( node , index , parent , { visitChildren } ) => {
103+ return {
104+ object : 'block' ,
105+ type : 'list-item' ,
106+ nodes : visitChildren ( node )
107+ }
108+ } ,
109+ toMdast : ( object , _index , _parent , { visitChildren } ) => {
110+ return {
111+ type : 'listItem' ,
112+ children : visitChildren ( object )
113+ }
114+ }
115+ }
116+
78117const headings = [
79118 'heading-one' ,
80119 'heading-two' ,
@@ -111,10 +150,12 @@ const bold = {
111150 nodes : visitChildren ( node )
112151 }
113152 } ,
114- toMdast : ( mark , index , parent , { visitChildren } ) => ( {
115- type : 'strong' ,
116- children : visitChildren ( mark )
117- } )
153+ toMdast : ( mark , index , parent , { visitChildren } ) => {
154+ return {
155+ type : 'strong' ,
156+ children : visitChildren ( mark )
157+ }
158+ }
118159}
119160
120161const codeBlock = {
@@ -288,6 +329,8 @@ export const serializer = new MarkdownSerializer({
288329 jsxBlock ,
289330 codeBlock ,
290331 image ,
291- link
332+ link ,
333+ bulletedList ,
334+ listItem
292335 ] . concat ( headings )
293336} )
0 commit comments