@@ -232,7 +232,69 @@ Content inside
232232 it ( 'should handle HTML-like elements' , async ( ) => {
233233 const input = '<div>Some content</div>'
234234 const result = await mdxToMd ( input )
235- expect ( typeof result ) . toBe ( 'string' ) // Should either convert or skip gracefully
235+ expect ( result ) . toContain ( '<div>Some content</div>' )
236+ } )
237+ } )
238+
239+ describe ( 'intrinsic HTML preservation regressions' , ( ) => {
240+ it ( 'preserves an unhandled intrinsic block with nested image markup' , async ( ) => {
241+ const input = `<p align="center">
242+ <img alt="logo" src="./src/app/icon.svg"
243+ width="138" />
244+ </p>`
245+
246+ const result = await mdxToMd ( input )
247+
248+ expect ( result ) . toContain ( '<p align="center">' )
249+ expect ( result ) . toContain ( '<img alt="logo" src="./src/app/icon.svg"' )
250+ expect ( result ) . toContain ( 'width="138" />' )
251+ expect ( result ) . toContain ( '</p>' )
252+ } )
253+
254+ it ( 'preserves an unhandled intrinsic block with inline formatting and links' , async ( ) => {
255+ const input = `<p align="right">
256+ <b>English</b> | <a href="./README_zh.md">简体中文</a>
257+ </p>`
258+
259+ const result = await mdxToMd ( input )
260+
261+ expect ( result ) . toContain ( '<p align="right">' )
262+ expect ( result ) . toContain ( '<b>English</b> | <a href="./README_zh.md">简体中文</a>' )
263+ expect ( result ) . toContain ( '</p>' )
264+ } )
265+
266+ it ( 'preserves the opening sample section without dropping intrinsic blocks' , async ( ) => {
267+ const input = `<p align="center">
268+ <img alt="logo" src="./src/app/icon.svg"
269+ width="138" />
270+ </p>
271+
272+ # China Unemployment Watch
273+
274+ <p align="right">
275+ <b>English</b> | <a href="./README_zh.md">简体中文</a>
276+ </p>`
277+
278+ const result = await mdxToMd ( input )
279+
280+ expect ( result ) . toContain ( '<p align="center">' )
281+ expect ( result ) . toContain ( '# China Unemployment Watch' )
282+ expect ( result ) . toContain ( '<p align="right">' )
283+ } )
284+
285+ it ( 'evaluates expressions and attribute expressions inside preserved intrinsic blocks' , async ( ) => {
286+ const input = '<p align={side}>{count}<img src={logo} width={width} /></p>'
287+
288+ const result = await mdxToMd ( input , {
289+ scope : {
290+ side : 'right' ,
291+ count : 2 ,
292+ logo : './logo.svg' ,
293+ width : 138
294+ }
295+ } )
296+
297+ expect ( result ) . toBe ( '<p align="right">2<img src="./logo.svg" width="138" /></p>' )
236298 } )
237299 } )
238300
@@ -283,6 +345,13 @@ Content inside
283345 expect ( result ) . toContain ( '[file.js]' )
284346 expect ( result ) . toContain ( '(https://example.com/path/to/file.js)' )
285347 } )
348+
349+ it ( 'should not collapse non-URL self-labeled links into autolinks' , async ( ) => {
350+ const input = '[README](README) and [#section](#section)'
351+ const result = await mdxToMd ( input )
352+
353+ expect ( result ) . toBe ( '[README](README) and [#section](#section)' )
354+ } )
286355 } )
287356
288357 describe ( 'yAML frontmatter preservation' , ( ) => {
0 commit comments