0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Merge pull request #4063 from ErisDS/issue-2703

GhostGFM honours escaped tildes
This commit is contained in:
Matt Enlow 2014-09-19 10:04:50 -06:00
commit 7ef34382f2
3 changed files with 27 additions and 0 deletions

View file

@ -21,6 +21,15 @@
return '<del>' + content + '</del>';
}
},
{
// Escaped tildes
// NOTE: showdown already replaced "~" with "~T", and this char doesn't get escaped properly.
type : 'lang',
regex : '\\\\(~T)',
replace : function (match, content) {
return content;
}
},
{
// GFM newline and underscore modifications, happen BEFORE showdown
type : 'lang',

View file

@ -29,6 +29,14 @@ describe('Showdown client side converter', function () {
processedMarkup.should.match(testPhrase.output);
});
it('should honour escaped tildes', function () {
var testPhrase = {input: '\\~\\~foo_bar\\~\\~', output: /^<p>~~foo_bar~~<\/p>$/},
processedMarkup = converter.makeHtml(testPhrase.input);
// The image is the entire markup, so the image box should be too
processedMarkup.should.match(testPhrase.output);
});
it('should not touch single underscores inside words', function () {
var testPhrase = {input: 'foo_bar', output: /^<p>foo_bar<\/p>$/},
processedMarkup = converter.makeHtml(testPhrase.input);

View file

@ -50,6 +50,16 @@ describe('Ghost GFM showdown extension', function () {
processedMarkup.should.match(testPhrase.output);
});
it('should honour escaped tildes', function () {
/*jshint -W044 */
var testPhrase = {input: '\\~T\\~Tfoo_bar\\~T\\~T', output: /~T~Tfoo_bar~T~T/},
/*jshint +W044 */
processedMarkup = _ConvertPhrase(testPhrase.input);
// The image is the entire markup, so the image box should be too
processedMarkup.should.match(testPhrase.output);
});
it('should allow 4 underscores', function () {
var testPhrase = {input: 'Ghost ____', output: /Ghost\s(?:&#95;){4}$/},
processedMarkup = _ConvertPhrase(testPhrase.input);