mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Improving underscore handling
Additional changes to how underscores are handled. This more closely matches codemirror, but is still not 100%.
This commit is contained in:
parent
21487aa802
commit
c45f911a1e
2 changed files with 10 additions and 2 deletions
|
@ -33,8 +33,9 @@
|
||||||
return "{gfm-js-extract-pre-" + hash + "}";
|
return "{gfm-js-extract-pre-" + hash + "}";
|
||||||
}, 'm');
|
}, '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, '\\_');
|
return x.replace(/_/gm, '\\_');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,13 @@ describe("Showdown client side converter", function () {
|
||||||
processedMarkup.should.match(testPhrase.output);
|
processedMarkup.should.match(testPhrase.output);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not create italic words between lines", function () {
|
||||||
|
var testPhrase = {input: "foo_bar\nbar_foo", output: /^<p>foo_bar <br \/>\nbar_foo<\/p>$/},
|
||||||
|
processedMarkup = converter.makeHtml(testPhrase.input);
|
||||||
|
|
||||||
|
processedMarkup.should.match(testPhrase.output);
|
||||||
|
});
|
||||||
|
|
||||||
it("should not touch underscores in code blocks", function () {
|
it("should not touch underscores in code blocks", function () {
|
||||||
var testPhrase = {input: " foo_bar_baz", output: /^<pre><code>foo_bar_baz\n<\/code><\/pre>$/},
|
var testPhrase = {input: " foo_bar_baz", output: /^<pre><code>foo_bar_baz\n<\/code><\/pre>$/},
|
||||||
processedMarkup = converter.makeHtml(testPhrase.input);
|
processedMarkup = converter.makeHtml(testPhrase.input);
|
||||||
|
|
Loading…
Add table
Reference in a new issue