Skip to content

Commit

Permalink
Do not render links to travis or david
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuso Backman committed Nov 18, 2014
1 parent 9bf0fc6 commit 5ef5e8c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/modules/markdown.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use strict';

var marked = require('gulp-marked'),
vfs = require('vinyl-fs');
vfs = require('vinyl-fs'),
excludeLinks = [
'https://travis-ci.org/SC5/sc5-styleguide',
'https://david-dm.org/SC5/sc5-styleguide'
];

function dasherize(str) {
return str.replace(/\s/ig, '-').toLowerCase();
Expand All @@ -28,6 +32,10 @@ module.exports = {
return '<li class="sg">' + text + '</li>\n';
};
renderer.link = function(href, title, text) {
if (excludeLinks.indexOf(href) >= 0) {
return '';
}

if (this.options.sanitize) {
try {
var prot = decodeURIComponent(unescape(href))
Expand Down
32 changes: 32 additions & 0 deletions test/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,38 @@ var gulp = require('gulp'),

describe('Markdown', function() {

describe('renderer', function() {

var renderer, result;

beforeEach(function() {
renderer = markdown.getRenderer();
renderer.options = {
sanitize: true
};
});

describe('link', function() {

it('adds class .sg to <a> tags', function() {
result = renderer.link('linkHref', 'title', 'link text');
expect(result).to.eql('<a class="sg" href="linkHref" title="title">link text</a>');
});

it('excludes link to https://travis-ci.org/SC5/sc5-styleguide', function() {
result = renderer.link('https://travis-ci.org/SC5/sc5-styleguide');
expect(result).to.eql('');
});

it('excludes link to https://david-dm.org/SC5/sc5-styleguide', function() {
result = renderer.link('https://david-dm.org/SC5/sc5-styleguide');
expect(result).to.eql('');
});

});

});

it('getRenderer if formed correctly', function() {
var renderer = markdown.getRenderer();
expect(renderer).to.be.an('object');
Expand Down

0 comments on commit 5ef5e8c

Please sign in to comment.