diff --git a/website/gulpfile.js b/website/gulpfile.js index 5e327c544..780cb02a6 100644 --- a/website/gulpfile.js +++ b/website/gulpfile.js @@ -95,21 +95,28 @@ gulp.task('watch', function() { // Transform md files to html. gulp.task('markdown', function() { gulp.src(['../docs/*.md', '!../docs/api.md']) + // Parse markdown. .pipe(markdown()) - // Fix md links. - .pipe(replace(/\/docs\/(.*)\.md/g, '#/$1')) + // Fix in-page hash paths. + .pipe(replace(/"#([^ ]*?)"/g, '#/{{path}}#$1')) + // Fix md urls. + .pipe(replace(/"(?:\/docs\/)?([\w\-]+)\.md/g, '"#/$1')) + // Fix png urls. + .pipe(replace(/"(?:\/docs\/)?([\w\-]+\.png)"/g, '"img/$1"')) + // Fix urls to reference js files. + .pipe(replace( + /"(?:\/([\-\.\w\/]+)\/)?(\w+\.js(?:#\w*)?)"/g, + function(match, path, file) { + path = path || 'docs'; + return '"https://github.com/angular/protractor/blob/master/' + + path + '/' + file + '"'; + } + )) // Add anchor links .pipe(replace(/