【问题标题】:Why do the less than and greater than symbols get changed by Wordpress?为什么小于和大于符号会被 Wordpress 更改?
【发布时间】:2012-01-05 15:45:24
【问题描述】:

在我的 Wordpress 博客上,我使用 wp-sytax 插件来格式化代码 sn-p。

在 HTML 视图中,我有以下代码:

<pre lang="c">
#include<stdio.h>
</pre>

但在常规视图中它显示:

#include&lt;stdio.h&gt;

如何让#include&lt;stdio.h&gt; 在我输入时出现?

【问题讨论】:

标签: php html wordpress


【解决方案1】:

添加escaped="true",告诉引擎不要将代码转换为实体:

<pre lang="c" escaped="true">
#include<stdio.h>
</pre>

(参见the Documentation 的示例 4)

【讨论】:

    【解决方案2】:

    您需要稍微修改插件,并按照this post 中的说明转义字符。

    //$geshi = new GeSHi($code, $language);
    $geshi = new GeSHi(htmlspecialchars_decode($code), $language);
    

    上面的转义是使用htmlspecialchars_decode 完成的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-18
      • 2011-03-03
      • 1970-01-01
      • 2020-10-28
      • 1970-01-01
      • 1970-01-01
      • 2018-05-01
      相关资源
      最近更新 更多