0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Merge pull request #4915 from dbalders/footnote_bug

Fixed Bug Showing Full HTML Inside Code Block
This commit is contained in:
Hannah Wolfe 2015-02-17 19:14:07 +00:00
commit 2086c8d452
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);
});
});