File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Expand file tree Collapse file tree 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 = [
3737 'table' ,
3838 'tbody' ,
3939 'td' ,
40- 'th'
40+ 'th' ,
41+ 'tr' ,
42+ 'ul'
4143] ;
4244
4345task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' ] ) ;
@@ -57,15 +59,7 @@ task('markdown-docs', () => {
5759 }
5860 } ) )
5961 . 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' ) ) )
6963 . pipe ( dest ( 'dist/docs/markdown' ) ) ;
7064} ) ;
7165
@@ -123,3 +117,20 @@ function fixMarkdownDocLinks(link: string, filePath: string): string {
123117 // guides can be loaded in the Material docs.
124118 return `guide/${ baseName } ` ;
125119}
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