diff --git a/core/shared/lib/showdown/extensions/ghostfootnotes.js b/core/shared/lib/showdown/extensions/ghostfootnotes.js index 28a4a083de..b491504451 100644 --- a/core/shared/lib/showdown/extensions/ghostfootnotes.js +++ b/core/shared/lib/showdown/extensions/ghostfootnotes.js @@ -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; diff --git a/core/test/unit/showdown_footnotes_spec.js b/core/test/unit/showdown_footnotes_spec.js index 7c1bbea641..f3ea4089df 100644 --- a/core/test/unit/showdown_footnotes_spec.js +++ b/core/test/unit/showdown_footnotes_spec.js @@ -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: /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',