Domanda

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

È stato utile?

Soluzione 2

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.

Altri suggerimenti

You have to use HTML-Entities.

e.g.

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

gets displayed as <b>HEllo</b>

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top