@@ -498,34 +498,43 @@ function generateThemeCssClasses(
498498 Record < string , unknown >
499499 > ;
500500 if ( textStyles ) {
501- const lines : string [ ] = [ ] ;
501+ const otherLines : string [ ] = [ ] ;
502+ const tokenCssLines : string [ ] = [ ] ;
503+
504+ const toCSS = function ( abbr : string , cssValues : string [ ] ) {
505+ tokenCssLines . push ( `\ncode span${ abbr !== "" ? `.${ abbr } ` : "" } {` ) ;
506+ cssValues . forEach ( ( value ) => {
507+ tokenCssLines . push ( ` ${ value } ` ) ;
508+ } ) ;
509+ tokenCssLines . push ( "}\n" ) ;
510+ } ;
502511
503512 Object . keys ( textStyles ) . forEach ( ( styleName ) => {
504513 const abbr = kAbbrevs [ styleName ] ;
505514 if ( abbr !== undefined ) {
506515 const textValues = textStyles [ styleName ] ;
507516 const cssValues = generateCssKeyValues ( textValues ) ;
508517
509- if ( abbr !== "" ) {
510- lines . push ( `\ncode span. ${ abbr } {` ) ;
511- lines . push ( ... cssValues ) ;
512- lines . push ( "}\n" ) ;
513- } else {
518+ tokenCssLines . push ( `/* ${ styleName } */` ) ;
519+
520+ toCSS ( abbr , cssValues ) ;
521+
522+ if ( abbr == "" ) {
514523 [
515524 "pre > code.sourceCode > span" ,
516- "code span" ,
517525 "code.sourceCode > span" ,
518526 "div.sourceCode,\ndiv.sourceCode pre.sourceCode" ,
519527 ]
520528 . forEach ( ( selector ) => {
521- lines . push ( `\n${ selector } {` ) ;
522- lines . push ( ...cssValues ) ;
523- lines . push ( "}\n" ) ;
529+ otherLines . push ( `\n${ selector } {` ) ;
530+ otherLines . push ( ...cssValues ) ;
531+ otherLines . push ( "}\n" ) ;
524532 } ) ;
525533 }
526534 }
527535 } ) ;
528- return lines ;
536+ // return otherLines followed by tokenCssLines
537+ return otherLines . concat ( tokenCssLines ) ;
529538 }
530539 return undefined ;
531540}
0 commit comments