Commit 48617682 authored by Sean Hammond's avatar Sean Hammond

Enable showdown's literalMidWordUnderscores

This stops showdown from interpreting underscores in the middle of words
as <em> and <strong>, instead it treats them as literal underscores.

Example:

some text with__underscores__in middle

will be parsed as

<p>some text with__underscores__in middle</p>

Fixes #2598 (URLs with _'s in them were getting <em> tags inserted into
them, breaking the links).

Also see <https://github.com/showdownjs/showdown/issues/211>.
parent 4883f129
......@@ -11,7 +11,12 @@ module.exports = function () {
// see https://github.com/showdownjs/showdown#valid-options
var converter = new showdown.Converter({
extensions: [targetBlank],
simplifiedAutoLink: true
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);
};
......@@ -2,9 +2,19 @@ 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