GhostGFM honours escaped tildes

fixes #2703

- adds an extra rule to remove the slash if a tilde is escaped as showdown
  won't do this.
This commit is contained in:
Hannah Wolfe 2014-09-18 15:42:19 +01:00
parent c38c0cdfe1
commit 8841be8ec8
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);