0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fixed Bug Showing Full HTML Inside Code Block

This commit is contained in:
David Balderston 2015-02-13 23:01:31 -08:00
parent 81fd5f9eaf
commit 2b1bf96130
2 changed files with 49 additions and 0 deletions

View file

@ -79,12 +79,25 @@ function replaceEndFootnotes(text, converter) {
}
// Extract pre blocks
text = text.replace(/<(pre|code)>[\s\S]*?<\/(\1)>/gim, function (x) {
var hash = hashId();
preExtractions[hash] = x;
return '{gfm-js-extract-pre-' + hash + '}';
}, 'm');
text = text.replace(/```[\s\S]*?\n```/gim, function (x) {
var hash = hashId();
preExtractions[hash] = x;
return '{gfm-js-extract-pre-' + hash + '}';
}, 'm');
// Extract code blocks
text = text.replace(/`[\s\S]*?`/gim, function (x) {
var hash = hashId();
preExtractions[hash] = x;
return '{gfm-js-extract-pre-' + hash + '}';
}, 'm');
text = replaceInlineFootnotes(text);
text = replaceEndFootnotes(text, converter);

View file

@ -103,4 +103,40 @@ describe('Ghost footnotes showdown extension', function () {
processedMarkup.should.match(testPhrase.output);
});
it('should show markdown inside code block', function () {
var testPhrase = {
input: '<code>[^n]<\/code>',
output: '<code>[^n]<\/code>'
}, processedMarkup = _ConvertPhrase(testPhrase.input);
processedMarkup.should.match(testPhrase.output);
});
it('should show markdown inside pre block', function () {
var testPhrase = {
input: '<pre>[^n]<\/pre>',
output: '<pre>[^n]<\/pre>'
}, processedMarkup = _ConvertPhrase(testPhrase.input);
processedMarkup.should.match(testPhrase.output);
});
it('should show markdown inside single tick', function () {
var testPhrase = {
input: '`[^n]`',
output: '`[^n]`'
}, processedMarkup = _ConvertPhrase(testPhrase.input);
processedMarkup.should.match(testPhrase.output);
});
it('should show markdown inside triple tick', function () {
var testPhrase = {
input: '```[^n]```',
output: '```[^n]```'
}, processedMarkup = _ConvertPhrase(testPhrase.input);
processedMarkup.should.match(testPhrase.output);
});
});