繁体   English   中英

网页“ google-code-prettify”中代码段的语法高亮显示不适用于aspx和html代码

[英]syntax highlighting of code snippets in a web page “google-code-prettify” not working with aspx and html code

我将以下行放在html的标题中

<link href="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.js" type="text/javascript"></script>

在html中,我想强调一些html代码:

<body onload="prettyPrint()">
    <pre class="prettyprint lang-html">

           <input type="button" value="HELLO"/>

</pre>
</body>

但我不能取消HTML代码:当前的副本在这里: http : //jsfiddle.net/jTYQk/

pre元素不会阻止浏览器呈现内部元素。 http://www.htmlcodetutorial.com/linepar/_PRE.html

通过将您的<更改为&lt; 和>到&gt; ,您将获得正确渲染的效果。 查看http://jsfiddle.net/jTYQk/1/以获得示例。

要么

您也可以将代码包装在<xmp></xmp> http://jsfiddle.net/jTYQk/2/上查看。

但是,由于xmp已被标记为过时,因此不建议这样做。 参见https://developer.mozilla.org/en-US/docs/Web/HTML/Element/xmp

暂无
暂无

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

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