为什么Google Code Prettify会呈现实际代码(Why is Google Code Prettify rendering the actual code)

编程入门 行业动态 更新时间:2024-10-10 23:18:07
为什么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实体以防止它们显示在页面上。 & , <和>需要更改为&amp; , &lt; , &gt; 。

You still need to escape html entities to prevent them from being displayed on the page. &, <, and > need to be changed to &amp;, &lt;, and &gt;.

更多推荐

本文发布于:2023-07-29 03:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1311950.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   Prettify   Code   Google   actual

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!