@@ -458,7 +458,7 @@ function removeStyleDeclaration(style: string, property: string, value: string):
458458 . join ( ";" ) ;
459459}
460460
461- function canCompactInheritedFontSize ( tagName : string ) : boolean {
461+ function canCompactInheritedProseStyle ( tagName : string ) : boolean {
462462 return tagName === "table" || tagName === "div" || tagName === "section" ;
463463}
464464
@@ -473,19 +473,24 @@ function compactInheritedProseStyles(html: string, options: DcExportOptions): st
473473 ( _match , tagName : string , beforeStyle : string , rawStyle : string ) => {
474474 let style = rawStyle ;
475475 const normalizedTagName = tagName . toLowerCase ( ) ;
476+ const preservesCellStyle = normalizedTagName === "td" || normalizedTagName === "th" ;
477+ const isCompactableWrapper = canCompactInheritedProseStyle ( normalizedTagName ) ;
476478
477479 if ( styleHasDeclaration ( style , "font-family" , inheritedFontFamily ) ) {
478- if ( keptInheritedFontFamilyCount >= 2 ) {
480+ if ( ! preservesCellStyle && keptInheritedFontFamilyCount >= 2 ) {
479481 style = removeStyleDeclaration ( style , "font-family" , inheritedFontFamily ) ;
480- } else {
482+ } else if (
483+ keptInheritedFontFamilyCount < 2 &&
484+ ( preservesCellStyle || isCompactableWrapper )
485+ ) {
481486 keptInheritedFontFamilyCount += 1 ;
482487 }
483488 }
484489
485490 if ( styleHasDeclaration ( style , "font-size" , inheritedFontSize ) ) {
486- if ( keptInheritedFontSizeCount >= 2 ) {
491+ if ( ! preservesCellStyle && keptInheritedFontSizeCount >= 2 ) {
487492 style = removeStyleDeclaration ( style , "font-size" , inheritedFontSize ) ;
488- } else if ( canCompactInheritedFontSize ( normalizedTagName ) ) {
493+ } else if ( keptInheritedFontSizeCount < 2 && ( preservesCellStyle || isCompactableWrapper ) ) {
489494 keptInheritedFontSizeCount += 1 ;
490495 }
491496 }
@@ -521,6 +526,7 @@ function renderAttributionFooter(options: DcExportOptions): string {
521526
522527function renderDcTableBlock ( {
523528 body,
529+ options,
524530 backgroundColor,
525531 fallbackBackground,
526532 borderColor,
@@ -530,6 +536,7 @@ function renderDcTableBlock({
530536 padding = "12px 14px" ,
531537} : {
532538 body : string ;
539+ options : DcExportOptions ;
533540 backgroundColor : string ;
534541 fallbackBackground : string ;
535542 borderColor ?: string ;
@@ -551,6 +558,7 @@ function renderDcTableBlock({
551558 const cellStyle = joinStyle ( {
552559 padding,
553560 "background-color" : backgroundColor ,
561+ "font-size" : safeBodyFontSize ( options ) ,
554562 } ) ;
555563
556564 return `<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="${ fallbackBackground } " style="${ tableStyle } "><tbody><tr><td style="${ cellStyle } ">${ body } </td></tr></tbody></table>` ;
@@ -825,7 +833,6 @@ async function renderList(
825833 color : palette . text ,
826834 "font-family" : proseFontFamily ,
827835 "font-size" : bodyFontSize ,
828- "font-weight" : 400 ,
829836 "line-height" : 1.7 ,
830837 "text-align" : ordered ? "right" : "center" ,
831838 "vertical-align" : "top" ,
@@ -835,7 +842,6 @@ async function renderList(
835842 color : palette . text ,
836843 "font-family" : proseFontFamily ,
837844 "font-size" : bodyFontSize ,
838- "font-weight" : 400 ,
839845 "line-height" : 1.7 ,
840846 "white-space" : "nowrap" ,
841847 } ) ;
@@ -844,15 +850,13 @@ async function renderList(
844850 color : palette . text ,
845851 "font-family" : proseFontFamily ,
846852 "font-size" : bodyFontSize ,
847- "font-weight" : 400 ,
848853 "line-height" : 1.7 ,
849854 "vertical-align" : "top" ,
850855 } ) ;
851856 const bodyTextStyle = joinStyle ( {
852857 color : palette . text ,
853858 "font-family" : proseFontFamily ,
854859 "font-size" : bodyFontSize ,
855- "font-weight" : 400 ,
856860 "line-height" : 1.7 ,
857861 } ) ;
858862 const rows = await Promise . all (
@@ -1007,6 +1011,7 @@ async function renderCallout(
10071011 if ( isDcTableStructure ( options ) ) {
10081012 return renderDcTableBlock ( {
10091013 body : content ,
1014+ options,
10101015 backgroundColor : palette . background ,
10111016 fallbackBackground : calloutFallbackBackground ( kind , options , node ) ,
10121017 borderColor : palette . border ,
@@ -1094,6 +1099,7 @@ async function renderLinkBox(node: JSONContent, options: DcExportOptions): Promi
10941099 if ( isDcTableStructure ( options ) ) {
10951100 return renderDcTableBlock ( {
10961101 body : content ,
1102+ options,
10971103 backgroundColor : boxBackground ,
10981104 fallbackBackground : isDarkEditorial ? "#0b0b0b" : dcTableFallbackColors . referenceBackground ,
10991105 border : `1px solid ${ boxBorder } ` ,
@@ -1159,6 +1165,7 @@ async function renderBlockquote(node: JSONContent, options: DcExportOptions): Pr
11591165 if ( isDcTableStructure ( options ) ) {
11601166 return renderDcTableBlock ( {
11611167 body : content ,
1168+ options,
11621169 backgroundColor : quoteBackground ( quoteStyle , palette ) ,
11631170 fallbackBackground : quoteFallbackBackground ( options ) ,
11641171 border : quoteStyle === "pull" ? undefined : quoteTableBorder ( quoteStyle , palette ) ,
@@ -1361,6 +1368,7 @@ async function renderSectionHeading(node: JSONContent, options: DcExportOptions)
13611368 if ( isDcTableStructure ( options ) ) {
13621369 return renderDcTableBlock ( {
13631370 body,
1371+ options,
13641372 backgroundColor : palette . articleBackground ,
13651373 fallbackBackground : palette . fallbackBackground ,
13661374 borderColor : palette . sectionAccent ,
0 commit comments