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
When I used this with manual highlighting and Prism.highlight, it simply did nothing. After digging around in the code for a bit, I noticed that:
Fold only activates on the first "on page load" run (the 'before-all-elements-highlight' hook).
Fold is removed by the Prism sanity check or highlighter.
This is easily fixable from a user's standpoint, although it is a bit hacky
Here is what finally got it working for me (using the js and css files directly from GitHub):
letel=document.getElementById("code")// the code elementel.innerHTML=string// the JSON (in this case) to be parsed insertFolds(el)// from prism-js-foldletnewstring=el.innerHTMLlethtml=Prism.highlight(newstring,Prism.languages.json,'json')html=html.replace(/</g,"<")html=html.replace(/>/g,">")// fix the class, open, etc. attributes being converted to span.token.string elementshtml=html.replace(/<(\w+) (\w+)=<span class="token string">"(\w*)"<\/span>/g,'<$1 $2="$3"')el.innerHTML=html
This could possibly be fixed with an "after-highlight" hook, although I am not sure if it works the same as Prism.highlight. My results with a hook always seemed to have the details and summary elements stripped out.
The text was updated successfully, but these errors were encountered:
When I used this with manual highlighting and
Prism.highlight
, it simply did nothing. After digging around in the code for a bit, I noticed that:'before-all-elements-highlight'
hook).Here is what finally got it working for me (using the js and css files directly from GitHub):
This could possibly be fixed with an
"after-highlight"
hook, although I am not sure if it works the same asPrism.highlight
. My results with a hook always seemed to have thedetails
andsummary
elements stripped out.The text was updated successfully, but these errors were encountered: