File tree 1 file changed +21
-10
lines changed 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
37
37
'table' ,
38
38
'tbody' ,
39
39
'td' ,
40
- 'th'
40
+ 'th' ,
41
+ 'tr' ,
42
+ 'ul'
41
43
] ;
42
44
43
45
task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' ] ) ;
@@ -57,15 +59,7 @@ task('markdown-docs', () => {
57
59
}
58
60
} ) )
59
61
. pipe ( transform ( transformMarkdownFiles ) )
60
- . pipe ( dom ( function ( ) {
61
- MARKDOWN_TAGS_TO_CLASS_ALIAS . forEach ( ( tag ) => {
62
- Array . prototype . slice . call ( this . querySelectorAll ( tag ) ) . forEach ( ( el : any ) => {
63
- el . classList . add ( `docs-markdown-${ tag } ` ) ;
64
- } ) ;
65
- } ) ;
66
-
67
- return this ;
68
- } ) )
62
+ . pipe ( dom ( createTagNameAliaser ( 'docs-markdown' ) ) )
69
63
. pipe ( dest ( 'dist/docs/markdown' ) ) ;
70
64
} ) ;
71
65
@@ -123,3 +117,20 @@ function fixMarkdownDocLinks(link: string, filePath: string): string {
123
117
// guides can be loaded in the Material docs.
124
118
return `guide/${ baseName } ` ;
125
119
}
120
+
121
+ /**
122
+ * Returns a function to be called with an HTML document as its context that aliases HTML tags by
123
+ * adding a class consisting of a prefix + the tag name.
124
+ * @param classPrefix The prefix to use for the alias class.
125
+ */
126
+ function createTagNameAliaser ( classPrefix : string ) {
127
+ return function ( ) {
128
+ MARKDOWN_TAGS_TO_CLASS_ALIAS . forEach ( ( tag ) => {
129
+ for ( let el of this . querySelectorAll ( tag ) ) {
130
+ el . classList . add ( `${ classPrefix } -${ tag } ` ) ;
131
+ }
132
+ } ) ;
133
+
134
+ return this ;
135
+ } ;
136
+ }
You can’t perform that action at this time.
0 commit comments