Download public/scripts/util/showdown-patch.js from SCritter/st-mobile: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/SCritter/st-mobile/resolve/main/public/scripts/util/showdown-patch.js
- Command line
-
hf download hf://spaces/SCritter/st-mobile/public/scripts/util/showdown-patch.js
-
curl -L -o showdown-patch.js https://huggingface.co/spaces/SCritter/st-mobile/resolve/main/public/scripts/util/showdown-patch.js
1.17 kB
| /** | |
| * Patches showdown to unrestrictedly unhash HTML spans. | |
| * @param {import('showdown')} showdown The showdown object to patch | |
| */ | |
| export function addShowdownPatch(showdown) { | |
| showdown.subParser('unhashHTMLSpans', function (text, options, globals) { | |
| 'use strict'; | |
| text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals); | |
| 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('unhashHTMLSpans.after', text, options, globals); | |
| return text; | |
| }); | |
| } | |