@@ -583,6 +583,56 @@ describe('HTML output', () => {
583583 expect ( result . html ) . toContain ( 'id="user-content-api"' )
584584 expect ( result . html ) . toContain ( 'id="user-content-api-1"' )
585585 } )
586+
587+ it ( 'preserves supported attributes on raw HTML headings' , async ( ) => {
588+ const md = '<h1 align="center">My Package</h1>'
589+ const result = await renderReadmeHtml ( md , 'test-pkg' )
590+
591+ expect ( result . html ) . toContain ( 'id="user-content-my-package"' )
592+ expect ( result . html ) . toContain ( 'align="center"' )
593+ } )
594+
595+ it ( 'preserves supported attributes on rewritten raw HTML anchors (renderer.html path)' , async ( ) => {
596+ const md = [
597+ '<div>' ,
598+ ' <a href="https://stackblitz.com/edit/my-demo" title="Open demo">Open in StackBlitz</a>' ,
599+ '</div>' ,
600+ ] . join ( '\n' )
601+ const result = await renderReadmeHtml ( md , 'test-pkg' )
602+
603+ expect ( result . html ) . toContain ( 'href="https://stackblitz.com/edit/my-demo"' )
604+ expect ( result . html ) . toContain ( 'title="Open demo"' )
605+ expect ( result . html ) . toContain ( 'rel="nofollow noreferrer noopener"' )
606+ expect ( result . html ) . toContain ( 'target="_blank"' )
607+ } )
608+
609+ it ( 'preserves title when it appears before href (renderer.html path)' , async ( ) => {
610+ const md = [
611+ '<div>' ,
612+ ' <a title="Open demo" href="https://stackblitz.com/edit/my-demo">Open in StackBlitz</a>' ,
613+ '</div>' ,
614+ ] . join ( '\n' )
615+ const result = await renderReadmeHtml ( md , 'test-pkg' )
616+
617+ expect ( result . html ) . toContain ( 'title="Open demo"' )
618+ expect ( result . html ) . toContain ( 'href="https://stackblitz.com/edit/my-demo"' )
619+ expect ( result . html ) . toContain ( 'rel="nofollow noreferrer noopener"' )
620+ expect ( result . html ) . toContain ( 'target="_blank"' )
621+ } )
622+
623+ it ( 'overrides existing rel and target instead of duplicating them (renderer.html path)' , async ( ) => {
624+ const md = [
625+ '<div>' ,
626+ ' <a href="https://stackblitz.com/edit/my-demo" rel="bookmark" target="_self" title="Open demo">Open in StackBlitz</a>' ,
627+ '</div>' ,
628+ ] . join ( '\n' )
629+ const result = await renderReadmeHtml ( md , 'test-pkg' )
630+
631+ expect ( result . html ) . toContain ( 'rel="nofollow noreferrer noopener"' )
632+ expect ( result . html ) . toContain ( 'target="_blank"' )
633+ expect ( result . html ) . not . toContain ( 'rel="bookmark"' )
634+ expect ( result . html ) . not . toContain ( 'target="_self"' )
635+ } )
586636} )
587637
588638/**
0 commit comments