Skip to content

Commit 421d7b7

Browse files
committed
addressed comments
1 parent ea84c7f commit 421d7b7

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

tools/gulp/tasks/docs.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff 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

4345
task('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+
}

0 commit comments

Comments
 (0)