@@ -96,6 +96,7 @@ const ALLOW_TAGS = new Set([
9696 'body' ,
9797 'html' ,
9898 'g-emoji' ,
99+ 'input' , // [type=checkbox], for task list
99100] ) ;
100101
101102const ALLOW_CLASS = new Set ( [
@@ -104,6 +105,9 @@ const ALLOW_CLASS = new Set([
104105 '.highlight' ,
105106 '.octicon' ,
106107 '.octicon-link' ,
108+ '.contains-task-list' ,
109+ '.task-list-item' ,
110+ '.task-list-item-checkbox' ,
107111] ) ;
108112
109113function extractStyles ( styles , ast ) {
@@ -134,14 +138,29 @@ function extractStyles(styles, ast) {
134138 return true ;
135139 }
136140
141+ const klass = selector . match ( / ^ \. [ - \w ] + / ) ;
142+ if ( klass ) {
143+ return ALLOW_CLASS . has ( klass [ 0 ] ) ;
144+ }
145+
137146 return false ;
138147 }
139148
149+ function fix ( selector ) {
150+ if ( selector . startsWith ( 'html ' ) || selector . startsWith ( 'body ' ) ) {
151+ return selector . slice ( 5 ) ;
152+ }
153+
154+ return selector ;
155+ }
156+
140157 for ( const rule of walkRules ( ast ) ) {
141158 if ( rule . declarations . some ( ( { value} ) => value . includes ( 'prettylights' ) ) ) {
142159 styles . push ( rule ) ;
143160 } else {
144- rule . selectors = rule . selectors . filter ( selector => select ( selector ) ) ;
161+ rule . selectors = rule . selectors
162+ . filter ( selector => select ( selector ) )
163+ . map ( selector => fix ( selector ) ) ;
145164 if ( rule . selectors . length > 0 ) {
146165 styles . push ( rule ) ;
147166 }
@@ -259,7 +278,12 @@ async function getCSS({light = 'light', dark = 'dark', list = false} = {}) {
259278 let rules = [ ] ;
260279
261280 for ( const [ url , cssText ] of zip ( links , contents ) ) {
262- const [ name ] = url . match ( / (?< = \/ ) \w + (? = - \w + \. c s s $ ) / ) ;
281+ const match = url . match ( / (?< = \/ ) \w + (? = - \w + \. c s s $ ) / ) ;
282+ if ( ! match ) {
283+ continue ;
284+ }
285+
286+ const [ name ] = match ;
263287 const ast = css . parse ( cssText ) ;
264288
265289 if ( / ^ ( l i g h t | d a r k ) / . test ( name ) ) {
0 commit comments