@@ -9,6 +9,7 @@ const highlight = require('gulp-highlight-files');
9
9
const rename = require ( 'gulp-rename' ) ;
10
10
const flatten = require ( 'gulp-flatten' ) ;
11
11
const hljs = require ( 'highlight.js' ) ;
12
+ const dom = require ( 'gulp-dom' ) ;
12
13
13
14
// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
14
15
// example code should be inserted. We replace these comments with divs that have a
@@ -21,6 +22,24 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
21
22
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
22
23
const LINK_PATTERN = / ( < a [ ^ > ] * ) h r e f = " ( [ ^ " ] * ) " / g;
23
24
25
+ // HTML tags in the markdown generated files that should receive a .docs-markdown-${tagName} class
26
+ // for styling purposes.
27
+ const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
28
+ 'a' ,
29
+ 'h1' ,
30
+ 'h2' ,
31
+ 'h3' ,
32
+ 'h4' ,
33
+ 'h5' ,
34
+ 'li' ,
35
+ 'ol' ,
36
+ 'p' ,
37
+ 'table' ,
38
+ 'tbody' ,
39
+ 'td' ,
40
+ 'th'
41
+ ] ;
42
+
24
43
task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' ] ) ;
25
44
26
45
task ( 'markdown-docs' , ( ) => {
@@ -38,6 +57,15 @@ task('markdown-docs', () => {
38
57
}
39
58
} ) )
40
59
. 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
+ } ) )
41
69
. pipe ( dest ( 'dist/docs/markdown' ) ) ;
42
70
} ) ;
43
71
@@ -49,10 +77,10 @@ task('highlight-docs', () => {
49
77
} ;
50
78
51
79
return src ( 'src/examples/**/*.+(html|css|ts)' )
52
- . pipe ( flatten ( ) )
53
- . pipe ( rename ( renameFile ) )
54
- . pipe ( highlight ( ) )
55
- . pipe ( dest ( 'dist/docs/examples' ) ) ;
80
+ . pipe ( flatten ( ) )
81
+ . pipe ( rename ( renameFile ) )
82
+ . pipe ( highlight ( ) )
83
+ . pipe ( dest ( 'dist/docs/examples' ) ) ;
56
84
} ) ;
57
85
58
86
task ( 'api-docs' , ( ) => {
0 commit comments