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

Commit

Permalink
chore(website): make parsing urls from markdown more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelin committed Mar 10, 2015
1 parent 9ef93a2 commit de59047
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions website/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<h2 id="([^"]*)">(.*?)<\/h2>/g, '<h2 id="$1" class="' +
'anchored"><div><a href="#{{path}}#$1">&#x1f517;</a>$2</div></h2>'))
// Fix reference conf links.
.pipe(replace(
/"\/(docs|example|spec\/basic)\/(\w+\.js)"/g,
'https://github.com/angular/protractor/blob/master/$1/$2'
))
// Decorate tables.
.pipe(replace(/<table>/g, '<table class="table table-striped">'))
// Fix image links.
.pipe(replace(/"\/docs\/(\w+\.png)"/g, '"img/$1"'))
// Fix <code> blocks to not interpolate Angular
.pipe(replace(/<code>/g, '<code ng-non-bindable>'))
.pipe(rename(function(path) {
Expand Down

0 comments on commit de59047

Please sign in to comment.