diff --git a/core/shared/vendor/showdown/extensions/github.js b/core/shared/vendor/showdown/extensions/github.js index 6c2ad2dd50..6c3bad0262 100644 --- a/core/shared/vendor/showdown/extensions/github.js +++ b/core/shared/vendor/showdown/extensions/github.js @@ -33,8 +33,9 @@ return "{gfm-js-extract-pre-" + hash + "}"; }, 'm'); - // prevent 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) { + + //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_]*)/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 ae4cd4773a..a18fa0af92 100644 --- a/core/test/unit/client_showdown_int_spec.js +++ b/core/test/unit/client_showdown_int_spec.js @@ -29,6 +29,13 @@ describe("Showdown client side converter", function () { processedMarkup.should.match(testPhrase.output); }); + it("should not create italic words between lines", function () { + var testPhrase = {input: "foo_bar\nbar_foo", output: /^

foo_bar
\nbar_foo<\/p>$/}, + processedMarkup = converter.makeHtml(testPhrase.input); + + processedMarkup.should.match(testPhrase.output); + }); + it("should not touch underscores in code blocks", function () { var testPhrase = {input: " foo_bar_baz", output: /^

foo_bar_baz\n<\/code><\/pre>$/},
             processedMarkup = converter.makeHtml(testPhrase.input);