@@ -40,7 +40,6 @@ const kCardHeaderClass = "card-header";
4040const kCardFooterClass = "card-footer" ;
4141const kCardTitleClass = "card-title" ;
4242const kCardToolbarClass = "card-toolbar" ;
43- const kCardTitleToolbarClass = "card-title-toolbar" ;
4443
4544const kCardSidebarClass = "card-sidebar" ;
4645
@@ -152,17 +151,27 @@ export function processCards(doc: Document, dashboardMeta: DashboardMeta) {
152151 if ( cardHeaderEl ) {
153152 // Loose text gets grouped into a div for alignment purposes
154153 // Always place this element first no matter what else is going on
155- const looseText : string [ ] = [ ] ;
154+ const looseText : Node [ ] = [ ] ;
156155
157156 // See if there is a toolbar in the header
158157 const cardToolbarEl = cardHeaderEl . querySelector ( `.${ kCardToolbarClass } ` ) ;
159158
160- for ( const headerChildNode of cardHeaderEl . childNodes ) {
159+ const isText = ( node : Node ) => node . nodeType === Node . TEXT_NODE ;
160+ const isEmphasis = ( node : Node ) => node . nodeName === "EM" ;
161+ const isBold = ( node : Node ) => node . nodeName === "STRONG" ;
162+ const isMath = ( node : Node ) =>
163+ node . nodeName === "SPAN" &&
164+ ( node as Element ) . classList . contains ( "math" ) &&
165+ ( node as Element ) . classList . contains ( "inline" ) ;
166+
167+ for ( const headerChildNode of Array . from ( cardHeaderEl . childNodes ) ) {
161168 if (
162- headerChildNode . nodeType === Node . TEXT_NODE &&
163- headerChildNode . textContent . trim ( ) !== ""
169+ isText ( headerChildNode ) ||
170+ isEmphasis ( headerChildNode ) ||
171+ isBold ( headerChildNode ) ||
172+ isMath ( headerChildNode )
164173 ) {
165- looseText . push ( headerChildNode . textContent . trim ( ) ) ;
174+ looseText . push ( headerChildNode ) ;
166175 headerChildNode . parentNode ?. removeChild ( headerChildNode ) ;
167176 }
168177 }
@@ -172,7 +181,13 @@ export function processCards(doc: Document, dashboardMeta: DashboardMeta) {
172181 const classes = [ kCardTitleClass ] ;
173182
174183 const titleTextDiv = makeEl ( "DIV" , { classes } , doc ) ;
175- titleTextDiv . innerText = looseText . join ( " " ) ;
184+ const innerSpan = makeEl ( "SPAN" , {
185+ attributes : { style : "display: inline" } ,
186+ } , doc ) ;
187+ titleTextDiv . appendChild ( innerSpan ) ;
188+ for ( const node of looseText ) {
189+ innerSpan . appendChild ( node ) ;
190+ }
176191 if ( cardToolbarEl ) {
177192 cardToolbarEl . insertBefore ( titleTextDiv , cardToolbarEl . firstChild ) ;
178193 } else {
0 commit comments