@@ -196,14 +196,7 @@ const mdcRemarkHandlers: Record<string, (state: State, node: Parents) => unknown
196
196
meta
197
197
}
198
198
} ,
199
- binding : ( state : State , node : Parents ) => {
200
- return {
201
- type : 'textComponent' ,
202
- name : 'binding' ,
203
- attributes : node . properties ,
204
- children : state . toFlow ( state . all ( node ) )
205
- }
206
- } ,
199
+
207
200
span : ( state : State , node : Parents ) => {
208
201
const result = {
209
202
type : 'textComponent' ,
@@ -216,30 +209,12 @@ const mdcRemarkHandlers: Record<string, (state: State, node: Parents) => unknown
216
209
217
210
return result
218
211
} ,
219
- video : ( state : State , node : Parents ) => {
220
- return {
221
- type : 'textComponent' ,
222
- name : 'video' ,
223
- attributes : node . properties ,
224
- children : state . toFlow ( state . all ( node ) )
225
- }
226
- } ,
227
- 'nuxt-img' : ( state : State , node : Parents ) => {
228
- return {
229
- type : 'textComponent' ,
230
- name : 'nuxt-img' ,
231
- attributes : node . properties ,
232
- children : state . toFlow ( state . all ( node ) )
233
- }
234
- } ,
235
- 'nuxt-picture' : ( state : State , node : Parents ) => {
236
- return {
237
- type : 'textComponent' ,
238
- name : 'nuxt-picture' ,
239
- attributes : node . properties ,
240
- children : state . toFlow ( state . all ( node ) )
241
- }
242
- } ,
212
+ binding : createTextComponent ( 'binding' ) ,
213
+ iframe : createTextComponent ( 'iframe' ) ,
214
+ video : createTextComponent ( 'video' ) ,
215
+ 'nuxt-img' : createTextComponent ( 'nuxt-img' ) ,
216
+ 'nuxt-picture' : createTextComponent ( 'nuxt-picture' ) ,
217
+ br : createTextComponent ( 'br' ) ,
243
218
table : ( state : State , node : Parents ) => {
244
219
visit ( node , ( node ) => {
245
220
// @ts -expect-error: custom type
@@ -303,12 +278,16 @@ const mdcRemarkHandlers: Record<string, (state: State, node: Parents) => unknown
303
278
304
279
state . patch ( node , result )
305
280
return result
306
- } ,
307
- br ( state : State , node : Parents ) {
281
+ }
282
+ }
283
+
284
+ function createTextComponent ( name : string ) {
285
+ return ( state : State , node : Parents ) => {
308
286
return {
309
287
type : 'textComponent' ,
310
- name : 'br' ,
311
- attributes : node . properties
288
+ name,
289
+ attributes : node . properties ,
290
+ children : node . children ? state . toFlow ( state . all ( node ) ) : undefined
312
291
}
313
292
}
314
293
}
0 commit comments