HTML code in pre and xmp tags renders

571 views Asked by At

I'm trying to display some HTML code in <pre> and <xmp> tags, but instead of just showing the code, this HTML code actually renders. Also I'm using Google Prettify to highlight the syntax.

<pre class="prettyprint code"></pre>

javascript

$(".code").html("<xmp>"+data+"</xmp>");
$('.prettyprinted').removeClass('prettyprinted');

prettyPrint();

So when I try to display <b>HEllo</b> I get Hello

2

There are 2 answers

0
Alen On BEST ANSWER

I solved this problem. I made class="tag" somewhere in my css, and apperently google prettify use same class name (.tag) to mark the html tags, so after I changed the name of my class to another name, everything was ok.

1
gnuheidix On

You have to use HTML-Entities.

e.g.

&lt;b&gt;HEllo&lt;/b&gt;

gets displayed as <b>HEllo</b>