简体   繁体   English

pre和xmp标签中的HTML代码呈现

[英]HTML code in pre and xmp tags renders

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. 我试图在<pre><xmp>标记中显示一些HTML代码,但该HTML代码实际上呈现了,而不只是显示代码。 Also I'm using Google Prettify to highlight the syntax. 另外,我正在使用Google Prettify突出显示语法。

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

javascript javascript

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

prettyPrint();

So when I try to display <b>HEllo</b> I get Hello 因此,当我尝试显示<b>HEllo</b> ,您会收到Hello

You have to use HTML-Entities. 您必须使用HTML实体。

eg 例如

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

gets displayed as <b>HEllo</b> 显示为<b> HELlo </ b>

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. 我在CSS的某个地方制作了class="tag" ,然后谷歌美化了使用相同的类名( .tag )标记html标签的方法,因此在我将类名更改为另一个名称后,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM