Skip to content

Commit 67e1fc2

Browse files
committed
fix: handle kbd element and preserve component inline children order
1 parent f168464 commit 67e1fc2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/runtime/stringify/mdc-remark.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,15 @@ const mdcRemarkNodeHandlers = {
163163
}
164164
}
165165

166+
let children = state.all(node)
167+
if (children.every(child => [mdastTextComponentType, 'text'].includes(child.type))) {
168+
children = [{ type: 'paragraph', children: children }] as unknown as typeof children
169+
}
166170
return {
167171
type: 'containerComponent',
168172
name: node.tagName,
169173
attributes: node.properties,
170-
children: state.all(node),
174+
children,
171175
}
172176
},
173177
}
@@ -270,6 +274,7 @@ const mdcRemarkHandlers: Record<string, (state: State, node: Parents, parent: Pa
270274
return createTextComponent('button')(state, node)
271275
},
272276
'span': createTextComponent('span'),
277+
'kbd': createTextComponent('kbd'),
273278
'binding': createTextComponent('binding'),
274279
'iframe': createTextComponent('iframe'),
275280
'video': createTextComponent('video'),

0 commit comments

Comments
 (0)