@@ -97,21 +97,27 @@ gulp.task('markdown', function() {
97
97
gulp . src ( [ '../docs/*.md' , '!../docs/api.md' ] )
98
98
// Parse markdown.
99
99
. pipe ( markdown ( ) )
100
- // Fix in-page hash paths.
101
- . pipe ( replace ( / " # ( [ ^ ] * ?) " / g, '#{{path}}#$1' ) )
102
- // Fix md urls.
103
- . pipe ( replace ( / " (?: \/ d o c s \/ ) ? ( [ \w \- ] + ) \. m d / g, '"#/$1' ) )
104
- // Fix png urls.
105
- . pipe ( replace ( / " (?: \/ d o c s \/ ) ? ( [ \w \- ] + \. p n g ) " / g, '"img/$1"' ) )
106
- // Fix urls to reference js & feature files.
100
+ // Fix urls which reference files only on github.
107
101
. pipe ( replace (
108
- / " (?: \/ ( [ \- \. \w \/ ] + ) \/ ) ? ( \w + \. (?: j s | f e a t u r e ) (?: # \w * ) ? ) " / g,
102
+ / " (?: \/ ( [ \- \. \w \/ ] + ) \/ ) ? ( \w + \. \w + (?: # . * ) ? ) " / g,
109
103
function ( match , path , file ) {
104
+ var ext = file . match ( / \w + \. ( \w + ) (?: # .* ) ? / ) [ 1 ] ;
105
+ // Don't process .md and .png files which are on the website
106
+ if ( ( ( ext == 'md' ) || ( ext == 'png' ) ) &&
107
+ ! ( path && ( ( path . substr ( 0 , 2 ) == '..' ) || ( path [ 0 ] == '/' ) ) ) ) {
108
+ return match ;
109
+ }
110
110
path = path || 'docs' ;
111
111
return '"https://github.com/angular/protractor/blob/master/' +
112
112
path + '/' + file + '"' ;
113
113
}
114
114
) )
115
+ // Fix in-page hash paths.
116
+ . pipe ( replace ( / " # ( [ ^ ] * ?) " / g, '#{{path}}#$1' ) )
117
+ // Fix md urls.
118
+ . pipe ( replace ( / " (?: \/ d o c s \/ ) ? ( [ \w \- ] + ) \. m d / g, '"#/$1' ) )
119
+ // Fix png urls.
120
+ . pipe ( replace ( / " (?: \/ d o c s \/ ) ? ( [ \w \- ] + \. p n g ) " / g, '"img/$1"' ) )
115
121
// Add anchor links
116
122
. pipe ( replace ( / < h 2 i d = " ( [ ^ " ] * ) " > ( .* ?) < \/ h 2 > / g, '<h2 id="$1" class="' +
117
123
'anchored"><div><a href="#{{path}}#$1">🔗</a>$2</div></h2>' ) )
0 commit comments