0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Merge pull request #1821 from schneidmaster/fix-1791

Modified github.js to ensure __ is not escaped at the beginning of a line
This commit is contained in:
Hannah Wolfe 2014-01-04 11:13:37 -08:00
commit 3937c1bf0e
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>$/},