File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ export default {
6161 const baseStyles = ` background-color:${bg };padding:16px;overflow:auto;white-space:pre;word-wrap:normal;word-break:normal;word-spacing:normal `
6262 const styles = [baseStyles , attrs .style ].filter (Boolean ).join (' ;' )
6363
64- const html = ` <table class="w-full"><tr><td class="${props .tdClass }"><pre class="${classes }" style="${styles }"><code>${codeContent }</code></pre></td></tr></table> `
64+ const html = ` <table class="w-full"><tr><td class="${props .tdClass }" style="background-color:${ bg }" ><pre class="${classes }" style="${styles }"><code>${codeContent }</code></pre></td></tr></table> `
6565
6666 return () => createStaticVNode (html , 1 )
6767 }
Original file line number Diff line number Diff line change @@ -74,13 +74,27 @@ describe('CodeBlock', () => {
7474 it ( 'uses default td-class' , async ( ) => {
7575 const html = await render ( { code : '<div>test</div>' } )
7676
77- expect ( html ) . toContain ( '<td class="max-w-0 mso-padding-alt-4"> ' )
77+ expect ( html ) . toContain ( '<td class="max-w-0 mso-padding-alt-4"' )
7878 } )
7979
8080 it ( 'accepts custom td-class' , async ( ) => {
8181 const html = await render ( { code : '<div>test</div>' , 'td-class' : 'custom-class' } )
8282
83- expect ( html ) . toContain ( '<td class="custom-class">' )
83+ expect ( html ) . toContain ( '<td class="custom-class"' )
84+ } )
85+
86+ it ( 'sets the shiki theme background on the wrapping td' , async ( ) => {
87+ const html = await render ( { code : '<div>test</div>' } )
88+
89+ // github-light bg is #fff — must appear on the td so Outlook's td
90+ // padding doesn't show through as white on a dark theme.
91+ expect ( html ) . toMatch ( / < t d [ ^ > ] * s t y l e = " b a c k g r o u n d - c o l o r : # f f f " / )
92+ } )
93+
94+ it ( 'uses the dark theme bg on the wrapping td' , async ( ) => {
95+ const html = await render ( { code : '<div>test</div>' , theme : 'github-dark' } )
96+
97+ expect ( html ) . toMatch ( / < t d [ ^ > ] * s t y l e = " b a c k g r o u n d - c o l o r : # 2 4 2 9 2 e " / )
8498 } )
8599 } )
86100
You can’t perform that action at this time.
0 commit comments