From a79597d8b3fef6379e4c291036c6ccb7210b31fe Mon Sep 17 00:00:00 2001 From: Zach Schneider Date: Thu, 2 Jan 2014 23:45:39 -0500 Subject: [PATCH] Modified github.js to ensure __ isn't escaped at beginning of line fixes #1791 --- core/shared/vendor/showdown/extensions/github.js | 2 +- core/test/unit/client_showdown_int_spec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/shared/vendor/showdown/extensions/github.js b/core/shared/vendor/showdown/extensions/github.js index f7138e5a90..d11e2c04dd 100644 --- a/core/shared/vendor/showdown/extensions/github.js +++ b/core/shared/vendor/showdown/extensions/github.js @@ -43,7 +43,7 @@ //prevent foo_bar and foo_bar_baz from ending up with an italic word in the middle - text = text.replace(/(^(?! {4}|\t)\w+_\w+_\w[\w_]*)/gm, function (x) { + text = text.replace(/(^(?! {4}|\t)(?!__)\w+_\w+_\w[\w_]*)/gm, function (x) { return x.replace(/_/gm, '\\_'); }); diff --git a/core/test/unit/client_showdown_int_spec.js b/core/test/unit/client_showdown_int_spec.js index 67c3e1cdeb..ebaf1ba5ce 100644 --- a/core/test/unit/client_showdown_int_spec.js +++ b/core/test/unit/client_showdown_int_spec.js @@ -60,6 +60,18 @@ describe("Showdown client side converter", function () { }); }); + it("should not escape double underscores at the beginning of a line", function () { + var testPhrases = [ + {input: "\n__test__\n", output: /^

test<\/strong><\/p>$/} + ], + processedMarkup; + + testPhrases.forEach(function (testPhrase) { + processedMarkup = converter.makeHtml(testPhrase.input); + processedMarkup.should.match(testPhrase.output); + }); + }); + it("should not treat pre blocks with pre-text differently", function () { var testPhrases = [ {input: "

\nthis is `a\\_test` and this\\_too and finally_this_is\n
", output: /^
\nthis is `a\\_test` and this\\_too and finally_this_is\n<\/pre>$/},