-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML Code Block Issue For Better Solution #887
Comments
You are right. HTML code needs to be escaped to be displayed properly in Prism. Note that this is not related to Prism but to the way the browsers interpret content inside pre and code. |
I’ve had this problem myself and I use $$("script[type='text/plain']").forEach(script=>{
var pre = document.createElement("pre");
var code = document.createElement("code");
code.className = script.className;
pre.appendChild(code);
script.parentNode.insertBefore(pre, script);
code.appendChild(script);
}); Note that this depends on Prism’s behavior of removing markup. If using the keep markup plugin, it will need a few adjustments. I should clean up the code and add it as a plugin, since that's such a common request. |
Thanks All guys. Have a great day :) |
Needed for unescaped markup plugin, as discussed in #887. Alternatively, we could reinstate @zeitgeist87’s PR about making the selector a config option. Thoughts?
Btw @hlaporthein there is now a beta plugin here: http://prismjs.com/plugins/unescaped-markup/ |
Hello All,
I found prismjs yesterday when googling. It is really awesome. It's features meet all my requirements. But I have a little problems in html markup.
For example if I would like to create below html code section
Code No.1
The above code only give me result one, I have no idea why paragraph tag is missing. After that I found out the problems, I would need to do HTML Escape to work like below code (No.2)
Code No.2
Let's say, if the above code.2 method is correct, how should I solve over escaping fifty html tags? I know there are some html escape convert tools. In facts, I know that html escape tools is good if I need to escape more html tags.
So, My Question is
Is using html escape convert tools correct method?
Does prismjs have better solution for that?
Or... Should I create javascript function (like code No.3) to search and escape? ( I think that is not good approach.). Please give me advice and Thanks.
Code No.3
The text was updated successfully, but these errors were encountered: