diff --git a/test/javascripts/lib/markdown_test.js b/test/javascripts/lib/markdown_test.js index c5cdc6108..d3c3ba1b7 100644 --- a/test/javascripts/lib/markdown_test.js +++ b/test/javascripts/lib/markdown_test.js @@ -50,6 +50,10 @@ test("Traditional Line Breaks", function() { cooked(input, traditionalOutput, "It supports traditional markdown via a Site Setting"); }); +test("Unbalanced underscores", function() { + cooked("[evil_trout][1] hello_\n\n[1]: http://eviltrout.com", "

evil_trout hello_

"); +}); + test("Line Breaks", function() { cooked("[] first choice\n[] second choice", "

[] first choice
[] second choice

", diff --git a/vendor/assets/javascripts/better_markdown.js b/vendor/assets/javascripts/better_markdown.js index 93555f4c5..304606cdd 100644 --- a/vendor/assets/javascripts/better_markdown.js +++ b/vendor/assets/javascripts/better_markdown.js @@ -643,7 +643,8 @@ var DialectHelpers = {}; DialectHelpers.inline_until_char = function( text, want ) { var consumed = 0, - nodes = []; + nodes = [], + patterns = this.dialect.inline.__patterns__.replace('|_|', ''); while ( true ) { if ( text.charAt( consumed ) === want ) { @@ -657,7 +658,7 @@ return null; } - var res = this.dialect.inline.__oneElement__.call(this, text.substr( consumed ) ); + var res = this.dialect.inline.__oneElement__.call(this, text.substr( consumed ), patterns ); consumed += res[ 0 ]; // Add any returned nodes. nodes.push.apply( nodes, res.slice( 1 ) );