| 1 | +showdown.subParser('makehtml.unhashHTMLSpans', function (text, options, globals) { |
| 2 | + 'use strict'; |
| 3 | + text = globals.converter._dispatch('makehtml.unhashHTMLSpans.before', text, options, globals).getText(); |
| 4 | + |
| 5 | + for (var i = 0; i < globals.gHtmlSpans.length; ++i) { |
| 6 | + var repText = globals.gHtmlSpans[i], |
| 7 | + // limiter to prevent infinite loop (assume 10 as limit for recurse) |
| 8 | + limit = 0; |
| 9 | + |
| 10 | + while (/¨C(\d+)C/.test(repText)) { |
| 11 | + var num = RegExp.$1; |
| 12 | + repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]); |
| 13 | + if (limit === 10000) { |
| 14 | + console.error('maximum nesting of 10000 spans reached!!!'); |
| 15 | + break; |
| 16 | + } |
| 17 | + ++limit; |
| 18 | + } |
| 19 | + text = text.replace('¨C' + i + 'C', repText); |
| 20 | + } |
| 21 | + |
| 22 | + text = globals.converter._dispatch('makehtml.unhashHTMLSpans.after', text, options, globals).getText(); |
| 23 | + return text; |
| 24 | +}); |