diff --git a/public/index.html b/public/index.html index a411bf235..ff932035b 100644 --- a/public/index.html +++ b/public/index.html @@ -6540,6 +6540,7 @@ + diff --git a/public/lib/showdown-patch.js b/public/lib/showdown-patch.js new file mode 100644 index 000000000..38d7f0f4a --- /dev/null +++ b/public/lib/showdown-patch.js @@ -0,0 +1,24 @@ +showdown.subParser('makehtml.unhashHTMLSpans', function (text, options, globals) { + 'use strict'; + text = globals.converter._dispatch('makehtml.unhashHTMLSpans.before', text, options, globals).getText(); + + for (var i = 0; i < globals.gHtmlSpans.length; ++i) { + var repText = globals.gHtmlSpans[i], + // limiter to prevent infinite loop (assume 10 as limit for recurse) + limit = 0; + + while (/¨C(\d+)C/.test(repText)) { + var num = RegExp.$1; + repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]); + if (limit === 10000) { + console.error('maximum nesting of 10000 spans reached!!!'); + break; + } + ++limit; + } + text = text.replace('¨C' + i + 'C', repText); + } + + text = globals.converter._dispatch('makehtml.unhashHTMLSpans.after', text, options, globals).getText(); + return text; +});