@@ -26,13 +26,36 @@ const highlightStyles = [
2626 'solarized' ,
2727 'tango' ,
2828 'vim-dark' ,
29- 'zenburn'
29+ 'zenburn' ,
30+ // specific alias for light-dark test
31+ 'light-dark'
3032] ;
3133
3234const colorSchemes : Array < 'light' | 'dark' > = [ 'light' , 'dark' ] ;
3335
36+
37+ // This is a special case for light-dark theme
38+ // We test pygments and kate themes so we retrieve the colors from the themeConfig
39+ // in src\resources\pandoc\highlight-styles\*.theme
40+ const themeConfigLightDark = {
41+ light : {
42+ name : 'pygments' ,
43+ colors : {
44+ kw : '#007020' ,
45+ fu : '#06287e'
46+ }
47+ } ,
48+ dark : {
49+ name : 'kate' ,
50+ colors : {
51+ kw : '#1f1c1b' ,
52+ fu : '#644a9b'
53+ }
54+ }
55+ } ;
56+
3457for ( const style of highlightStyles ) {
35- test . describe ( `Code highlighting for ${ style } theme` , ( ) => {
58+ test . describe ( `Code highlighting for ' ${ style } ' theme` , ( ) => {
3659
3760 for ( const colorScheme of colorSchemes ) {
3861 test . describe ( `in ${ colorScheme } mode` , ( ) => {
@@ -62,6 +85,30 @@ for (const style of highlightStyles) {
6285
6386 await checkColor ( codeBlock , 'color' , hexToRgb ( keywordColor ) ) ;
6487 } ) ;
88+ if ( style === 'light-dark' ) {
89+ const themeUsed = themeConfigLightDark [ colorScheme ] . name ;
90+ const colorUsed = themeConfigLightDark [ colorScheme ] . colors ;
91+ test ( `[${ style } ] Code highlighting for Inline and CodeBlock are using '${ themeUsed } ' theme` , async ( { page } ) => {
92+ const funName = page . locator ( 'div pre.sourceCode code.julia span' ) . getByText ( 'function' ) ;
93+ const divideFloats = page . locator ( 'div pre.sourceCode code.julia span' ) . getByText ( 'divide_floats' ) ;
94+ // Get specific syntax elements to test for color
95+ // get the class on the span
96+ const classNameFun = await funName . getAttribute ( 'class' ) as string ;
97+ const classNameDivide = await divideFloats . getAttribute ( 'class' ) as string ;
98+ // error if not found
99+ if ( ! classNameFun || ! classNameDivide ) {
100+ test . fail ( true , 'Class name not found for code highlighting elements' ) ;
101+ }
102+ const funColor = colorUsed [ classNameFun ] ;
103+ const divideColor = colorUsed [ classNameDivide ] ;
104+ await checkColor ( funName , 'color' , hexToRgb ( funColor ) ) ;
105+ await checkColor ( divideFloats , 'color' , hexToRgb ( divideColor ) ) ;
106+ // check also root variable
107+ await checkColor ( page . locator ( 'body' ) , `--quarto-hl-${ classNameFun } -color` , funColor ) ;
108+ await checkColor ( page . locator ( 'body' ) , `--quarto-hl-${ classNameDivide } -color` , divideColor ) ;
109+ } ) ;
110+ }
111+
65112 } ) ;
66113 }
67114 } ) ;
0 commit comments