0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Merge pull request #4816 from halfdan/fix-footnote

Fix footnote handling for n-digit numbers
This commit is contained in:
Hannah Wolfe 2015-01-17 20:43:58 +00:00
commit e07ec3ef84
2 changed files with 11 additions and 2 deletions

View file

@ -15,7 +15,7 @@
function replaceInlineFootnotes(text) {
// Inline footnotes e.g. "foo[^1]"
var inlineRegex = /(?!^)\[\^(\d|n)\]/gim,
var inlineRegex = /(?!^)\[\^(\d+|n)\]/gim,
i = 0;
return text.replace(inlineRegex, function (match, n) {
@ -34,7 +34,7 @@ function replaceInlineFootnotes(text) {
function replaceEndFootnotes(text, converter) {
// Expanded footnotes at the end e.g. "[^1]: cool stuff"
var endRegex = /\[\^(\d|n)\]: ([\s\S]*?)$(?! )/gim,
var endRegex = /\[\^(\d+|n)\]: ([\s\S]*?)$(?! )/gim,
m = text.match(endRegex),
total = m ? m.length : 0,
i = 0;

View file

@ -53,6 +53,15 @@ describe('Ghost footnotes showdown extension', function () {
processedMarkup.should.match(testPhrase.output);
});
it('should handle n-digit footnotes', function () {
var testPhrase = {
input: 'foo_bar[^42]',
output: /<sup id="fnref:42"><a href="#fn:42" rel="footnote">42<\/a><\/sup>/
}, processedMarkup = _ConvertPhrase(testPhrase.input);
processedMarkup.should.match(testPhrase.output);
});
it('should replace end footnotes with the right html', function () {
var testPhrase = {
input: '[^1]: foo bar',