mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
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:
parent
c38c0cdfe1
commit
8841be8ec8
@ -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',
|
||||
|
@ -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);
|
||||
|
@ -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(?:_){4}$/},
|
||||
processedMarkup = _ConvertPhrase(testPhrase.input);
|
||||
|
Loading…
Reference in New Issue
Block a user