There's a <code> html element you can use. Otherwise you could try the Textile or Markdown syntaxes (I'm not sure if WordPress.com uses them). Try it out and use the preview function in WordPress to see when you get it right.
If you are hosting your own wordpress blog opposed to on WP.com you can get this functionality by installing this plugin, since it is the same plugin that the WP.com code relies on.
发布评论
评论(6)
请参阅此处:http://en.support.wordpress.com/code/ posts-source-code/
将代码包含在这些标签中: [sourcecode language='css'] .. [/sourcecode]
(或更短的 [code lang='css'] .. [/code]
)可视化编辑器不会解释标签,您需要单击“预览”来查看它是如何工作的。
可用的语言代码:
See here: http://en.support.wordpress.com/code/posting-source-code/
Wrap your code in these tags: [sourcecode language='css'] .. [/sourcecode]
(or shorter [code lang='css'] .. [/code] )
Note that Visual Editor doesn't interpret the tags, you need to click Preview to see how it works.
Available language codes:
您还可以使用hilite.me。 它不需要安装插件或 JS/CSS 文件。 它也是开源的并且有 API。
免责声明:我是开发者。
You can also use hilite.me. It doesn't require installation of plugins or JS/CSS files. It's also open-source and has an API.
Disclaimer: I'm the developer.
蜡笔语法荧光笔是一个优秀的免费插件。 我选择了这个,但我遇到的许多其他可能可以达到目的:
Crayon Syntax Highlighter is an excellent free plugin. I went with that one, but there are many others I came across that may serve the purpose:
有一个<代码> 您可以使用 html 元素。 否则,您可以尝试 Textile 或 Markdown 语法(我不确定 WordPress.com 是否使用它们)。 尝试一下并使用 WordPress 中的预览功能来查看是否正确。
There's a <code> html element you can use. Otherwise you could try the Textile or Markdown syntaxes (I'm not sure if WordPress.com uses them). Try it out and use the preview function in WordPress to see when you get it right.
通过我的 Wordpress.org 安装,我无法获得接受的答案 在这里工作(不确定这是否只适用于 Wordpress.com?)...
我最终使用了 <而是使用 href="https://wordpress.org/plugins/syntaxhighlighter/" rel="nofollow noreferrer">SyntaxHighlighter 插件。
使用该插件,首先,您的代码将在“预览更改”视图中显示为转义:发布后它将正确显示。 我认为发布后它将正确显示在“预览更改”中(不是 100%)。
With my Wordpress.org installation, I couldn't get the Accepted Answer here to work (not sure if that's only expected to work with Wordpress.com?)...
I ended up using the SyntaxHighlighter plugin instead.
With that plugin, at first, your code will appear escaped in 'Preview Changes' view: It will appear correctly then after publishing. I think thereafter publishing it will then appear correctly in 'Preview Changes' (not 100% about that).
如果您托管自己的 WordPress 博客而不是在 WP.com 上,您可以通过安装此插件来获得此功能,因为它与 WP.com 代码所依赖的插件相同。
http://wordpress.org/extend/plugins/google-syntax-highlighter/< /a>
If you are hosting your own wordpress blog opposed to on WP.com you can get this functionality by installing this plugin, since it is the same plugin that the WP.com code relies on.
http://wordpress.org/extend/plugins/google-syntax-highlighter/