Modified github.js to ensure __ isn't escaped at beginning of line

fixes #1791
This commit is contained in:
Zach Schneider 2014-01-02 23:45:39 -05:00
parent bad2a307ae
commit a79597d8b3
2 changed files with 13 additions and 1 deletions

View File

@ -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, '\\_');
});

View File

@ -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: /^<p><strong>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: "<pre>\nthis is `a\\_test` and this\\_too and finally_this_is\n</pre>", output: /^<pre>\nthis is `a\\_test` and this\\_too and finally_this_is\n<\/pre>$/},