跳到内容

Code Markup

v1.3

bennettmcelwee · 2005年5月12日 上架

Code Markup is a WordPress plugin that makes it easy to include program code samples in your posts.

正在使用
200+
评分
暂无
累计下载
2.2 万
最近更新
2008年4月14日
需要 WordPress 1.5+已测试到 2.5

贡献者

Code Markup is a WordPress plugin that makes it easy to include program code samples in your posts. You can even include HTML markup in the code sample; Code Markup magically knows which characters should be displayed as code and which should be rendered as HTML.

The plugin works by escaping most special HTML tags and characters so they display exactly as typed, but leaving certain ones alone so they will render as normal HTML. The default set of allowed tags is the standard formatting tags like em, strong, span and so on. You can control this explicitly, or implicitly by specifying the language of the code block. For example, in a normal code block, <em> will be rendered as emphasised text, but in an HTML code block, <em> will be displayed as <em>.

(I have to use square brackets instead of angle brackets because of the WordPress Extend site formatting.)

USAGE

  1. Enclose any code inside a <code> block.

  2. Use <code markup=”…” lang=”…”> to specify appearance of code.

    • Include any HTML markup you like in the code, for example to add emphasis to certain sections.
    • Separate <code> blocks should be nested within a <pre> block to preserve whitespace.
  3. If you want to fine-tune how Code Markup treats your code, use the markup and lang attributes on the code tag to specify how Code Markup should handle it.

    • <code> or <code markup=”default”> allows common HTML tags to be rendered, and displays everything else exactly as written.
    • <code markup=”none”> displays content exactly as written ? no markup is rendered.
    • <code markup=”all”> renders content as HTML ? all markup is rendered.
    • <code markup=”em strong a”> treats <em>, <strong> and <a> tags as HTML markup ? everything else is displayed exactly as written. You can put whatever tags you like in the markup attribute, separated by spaces. As a special case, you can include the comment tag ? this means that HTML comments <!– like this –> will be ?rendered? as normal HTML comments (i.e. not displayed).
    • <code lang=”html”> or <code lang=”xhtml”> displays content exactly as written, the same as <code markup=”none”>.
  4. The markup attribute overrides the lang attribute.

  5. Separate <code> blocks should be nested within a <pre> block to
    preserve whitespace.

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums