Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 000f119

Browse files
committed
chore(website): fix links to github files
Closes #2545
1 parent 9105368 commit 000f119

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Diff for: website/gulpfile.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,27 @@ gulp.task('markdown', function() {
9797
gulp.src(['../docs/*.md', '!../docs/api.md'])
9898
// Parse markdown.
9999
.pipe(markdown())
100-
// Fix in-page hash paths.
101-
.pipe(replace(/"#([^ ]*?)"/g, '#{{path}}#$1'))
102-
// Fix md urls.
103-
.pipe(replace(/"(?:\/docs\/)?([\w\-]+)\.md/g, '"#/$1'))
104-
// Fix png urls.
105-
.pipe(replace(/"(?:\/docs\/)?([\w\-]+\.png)"/g, '"img/$1"'))
106-
// Fix urls to reference js & feature files.
100+
// Fix urls which reference files only on github.
107101
.pipe(replace(
108-
/"(?:\/([\-\.\w\/]+)\/)?(\w+\.(?:js|feature)(?:#\w*)?)"/g,
102+
/"(?:\/([\-\.\w\/]+)\/)?(\w+\.\w+(?:#.*)?)"/g,
109103
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+
}
110110
path = path || 'docs';
111111
return '"https://github.com/angular/protractor/blob/master/' +
112112
path + '/' + file + '"';
113113
}
114114
))
115+
// Fix in-page hash paths.
116+
.pipe(replace(/"#([^ ]*?)"/g, '#{{path}}#$1'))
117+
// Fix md urls.
118+
.pipe(replace(/"(?:\/docs\/)?([\w\-]+)\.md/g, '"#/$1'))
119+
// Fix png urls.
120+
.pipe(replace(/"(?:\/docs\/)?([\w\-]+\.png)"/g, '"img/$1"'))
115121
// Add anchor links
116122
.pipe(replace(/<h2 id="([^"]*)">(.*?)<\/h2>/g, '<h2 id="$1" class="' +
117123
'anchored"><div><a href="#{{path}}#$1">&#x1f517;</a>$2</div></h2>'))

0 commit comments

Comments
 (0)