Commit 8ae5ed46 authored by Robert Knight's avatar Robert Knight

Remove converter.js

This logic has now been moved to render-markdown.js
parent ece599ff
......@@ -180,8 +180,6 @@ module.exports = angular.module('h', [
.directive('topBar', require('./directive/top-bar'))
.directive('windowScroll', require('./directive/window-scroll'))
.filter('converter', require('./filter/converter'))
.service('annotationMapper', require('./annotation-mapper'))
.service('annotationUI', require('./annotation-ui'))
.service('auth', require('./auth').service)
......
'use strict';
var showdown = require('showdown');
function targetBlank() {
function filter(text) {
return text.replace(/<a href=/g, '<a target="_blank" href=');
}
return [{type: 'output', filter: filter}];
}
module.exports = function () {
// see https://github.com/showdownjs/showdown#valid-options
var converter = new showdown.Converter({
extensions: [targetBlank],
simplifiedAutoLink: true,
// Since we're using simplifiedAutoLink we also use
// literalMidWordUnderscores because otherwise _'s in URLs get
// transformed into <em>'s.
// See https://github.com/showdownjs/showdown/issues/211
literalMidWordUnderscores: true,
});
return converter.makeHtml.bind(converter);
};
var converter = require('../converter');
describe('markdown converter', function () {
var markdownToHTML = converter();
it('should autolink URLs', function () {
assert.equal(markdownToHTML('See this link - http://arxiv.org/article'),
'<p>See this link - <a target="_blank" href="http://arxiv.org/article">' +
'http://arxiv.org/article</a></p>');
});
it('should autolink URLs with _\'s in them correctly', function () {
assert.equal(
markdownToHTML(
'See this https://hypothes.is/stream?q=tag:group_test_needs_card'),
'<p>See this <a target="_blank" ' +
'href="https://hypothes.is/stream?q=tag:group_test_needs_card">' +
'https://hypothes.is/stream?q=tag:group_test_needs_card</a></p>');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment