You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My clunky workaround for this problem was to parse the input as html using a div tag, replace the contents of the script tags with a token before passing them through anchorme, and then restore them afterwards.
There's probably a better way, but this works.
// use a div element to parse the htmlconstparser=document.createElement('div');parser.innerHTML=input;constoriginalScripts=[];// find all script tags in the htmlletscriptTags=parser.getElementsByTagName('script');for(vari=0;i<scriptTags.length;i++){// store the script contents for lateroriginalScripts.push(scriptTags[i].innerText);// replace script contents with a temporary tokenscriptTags[i].innerText=`{{script-${i}}}`;}// convert anchorsvarconvertedHtml=anchorme(parser.innerHTML);// restore script tag contents by replacing tokens with original valuefor(vari=0;i<originalScripts.length;i++){convertedHtml=convertedHtml.replace(`{{script-${i}}}`,originalScripts[i]);}returnconvertedHtml;
Results in the following html
The text was updated successfully, but these errors were encountered: