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:
commit
7ef34382f2
3 changed files with 27 additions and 0 deletions
|
@ -21,6 +21,15 @@
|
||||||
return '<del>' + content + '</del>';
|
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
|
// GFM newline and underscore modifications, happen BEFORE showdown
|
||||||
type : 'lang',
|
type : 'lang',
|
||||||
|
|
|
@ -29,6 +29,14 @@ describe('Showdown client side converter', function () {
|
||||||
processedMarkup.should.match(testPhrase.output);
|
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 () {
|
it('should not touch single underscores inside words', function () {
|
||||||
var testPhrase = {input: 'foo_bar', output: /^<p>foo_bar<\/p>$/},
|
var testPhrase = {input: 'foo_bar', output: /^<p>foo_bar<\/p>$/},
|
||||||
processedMarkup = converter.makeHtml(testPhrase.input);
|
processedMarkup = converter.makeHtml(testPhrase.input);
|
||||||
|
|
|
@ -50,6 +50,16 @@ describe('Ghost GFM showdown extension', function () {
|
||||||
processedMarkup.should.match(testPhrase.output);
|
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 () {
|
it('should allow 4 underscores', function () {
|
||||||
var testPhrase = {input: 'Ghost ____', output: /Ghost\s(?:_){4}$/},
|
var testPhrase = {input: 'Ghost ____', output: /Ghost\s(?:_){4}$/},
|
||||||
processedMarkup = _ConvertPhrase(testPhrase.input);
|
processedMarkup = _ConvertPhrase(testPhrase.input);
|
||||||
|
|
Loading…
Add table
Reference in a new issue