@@ -752,4 +752,52 @@ describe('parseHtmlToMdxAst with markdown processor', () => {
752752 ] )
753753 } )
754754 } )
755+
756+ test ( 'block-level HTML elements as direct children of root should be flow elements' , ( ) => {
757+ // Test that wrapper outer HTML elements that are direct children of root
758+ // should be flow elements, not text elements
759+ const htmlWithNestedBlocks = htmlToMdxAst ( {
760+ html : `<div class="wrapper">
761+ <h1>Title</h1>
762+ <p>Some content</p>
763+ <section>
764+ <h2>Subtitle</h2>
765+ </section>
766+ </div>
767+ <article>
768+ <header>Header</header>
769+ <main>Content</main>
770+ </article>` ,
771+ parentType : 'root'
772+ } )
773+
774+ // All block-level elements at root should be flow elements
775+ expect ( htmlWithNestedBlocks ) . toHaveLength ( 2 )
776+
777+ // First element: div wrapper
778+ expect ( htmlWithNestedBlocks [ 0 ] ) . toMatchObject ( {
779+ type : 'mdxJsxFlowElement' ,
780+ name : 'div'
781+ } )
782+
783+ // Second element: article
784+ expect ( htmlWithNestedBlocks [ 1 ] ) . toMatchObject ( {
785+ type : 'mdxJsxFlowElement' ,
786+ name : 'article'
787+ } )
788+
789+ // Test with various block-level tags
790+ const blockTags = [ 'div' , 'article' , 'section' , 'header' , 'main' , 'footer' , 'aside' , 'nav' ]
791+ blockTags . forEach ( tag => {
792+ const result = htmlToMdxAst ( {
793+ html : `<${ tag } >Content</${ tag } >` ,
794+ parentType : 'root'
795+ } )
796+ expect ( result ) . toHaveLength ( 1 )
797+ expect ( result [ 0 ] ) . toMatchObject ( {
798+ type : 'mdxJsxFlowElement' ,
799+ name : tag
800+ } )
801+ } )
802+ } )
755803} )
0 commit comments