Obsidian_to_Anki
Obsidian_to_Anki copied to clipboard
Facing issues while using custom regex
While using custom regex (this one: https://github.com/ObsidianToAnki/Obsidian_to_Anki/issues/332) i am facing an issue with links inside my cards that never happened before. I guess since the update on the newest version of Obsidian.
It depends on this piece of code and does not happen with other card formattings (like the built in).
showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
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 === 10) {
console.error('maximum nesting of 10 spans reached!!!');
break;
}
++limit;
}
text = text.replace('¨C' + i + 'C', repText);
}