Convert HTML entities inside <code> tag to display on web site?

Good day,

I'm writing some HTML/CSS code examples on a web site. I'm using the <code> element to mark out my examples.

I'm trying to:

  1. Convert all HTML-tags inside my <code> blocks to be displayed on my web site
  2. Make my examples beautiful with syntax highlighting and maybe even auto indent

I have tried PrismJS and Highlighter.JS but I cannot get any of them to convert the HTML tags. Are you forced to make it server side? And if so are there any PHP-examples or tools for this that works fine with any of the JS-libraries?

Thanks in advance


Well you might do a simple trick to display html and css codes without and tag You might simply but the text inside a input within the code Then you might simply style it and give it custom background and everything also it will be easy for the user to copy it but make sure to right the code you want to display inside the html code not on the rendered page or it will not be displayed to the users like this

<input type="text" name="html_test_code">whatever code here</input>

And then the styling of sytax might be done using js easily

Need Your Help

Android app doesn't crash, but not responding on uncaught exceptions

java android google-analytics uncaughtexceptionhandler

I recently noticed, that my app doesn't crash when an uncaught exception occurs, but it is not responding. I use Google Analytics to get insight of crashes, I suspect that this may be the cause of ...

Singleton with Arguments in Java

java oop singleton anti-patterns

I was reading the Singleton article on Wikipedia and I came across this example: