为什么Google Code Prettify会呈现实际代码(Why is Google Code Prettify rendering the actual code)
我正在尝试在代码块中将html模板显示为标记
<div> <pre class="prettyprint lang-html"> <code> <%= template %> </code> </pre> </div>但模板实际上是在浏览器中呈现,而不是在代码块中显示的标记。
我已将CDN脚本包含在我的body标签中
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>I'm trying to display a html template as markup in a code block
<div> <pre class="prettyprint lang-html"> <code> <%= template %> </code> </pre> </div>But the template actually renders in the browser, rather than the markup displaying in a code block.
I've included the CDN script in my body tag
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>最满意答案
您仍然需要转义html实体以防止它们显示在页面上。 & , <和>需要更改为& , < , > 。
You still need to escape html entities to prevent them from being displayed on the page. &, <, and > need to be changed to &, <, and >.
更多推荐
发布评论