首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Code Prettify插件

无法使用Code Prettify插件
EN

Stack Overflow用户
提问于 2016-11-16 00:39:15
回答 2查看 58关注 0票数 1

我是WordPress的新手。

我正在尝试插入一个代码块在闪亮的主题的Wordpress。这是我在编辑器中的代码:

代码语言:javascript
复制
Following is a snippet of a sample Layout file.
<pre class="prettyprint">
<code class="xml">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" >

   <TextView android:id="@+id/text"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="This will print hello world" />

   <!-- More GUI components go here  -->

</LinearLayout>
</code></pre>

我得到了这个作为输出:

请告诉我哪里做错了。提前感谢..:)

EN

回答 2

Stack Overflow用户

发布于 2017-08-21 14:59:08

根本原因是xml标记符号。

将<更改为&lt;

Change > to &gt;

这对我很有效!

票数 1
EN

Stack Overflow用户

发布于 2016-11-16 20:46:07

你的意思是在WP编辑器或主题php文件中插入代码块?

但是,您需要首先将代码转换为html实体。例如:

在PHP中

代码语言:javascript
复制
<?php
$code = '<xml>...</xml>';

echo '<pre><code>';
echo htmlentities($code);
echo '</code></pre>';
?>

在WP编辑器中

粘贴你的代码通过可视化模式,然后wp将自动转换为文本模式下的html实体。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40615180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档