Linux 软件免费装
Banner图

CodeColorer

开发者 kpumuk
更新时间 2026年3月17日 04:50
PHP版本: 7.0 及以上
WordPress版本: 6.9.4
版权: GPLv2 or later
版权网址: 版权信息

标签

comments code snippet syntax highlighting

下载

0.7.0 0.7.3 0.7.2 0.8.0 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.10 0.11.0 0.5.1 0.6.0 0.8.1 0.9.11 0.9.12 0.9.13 0.9.15 0.9.16 0.9.6 0.9.7 0.10.0 0.8.2 0.8.3 0.9.14 0.9.2 0.9.3 0.9.4 0.9.5 0.9.8 0.9.9 0.10.1 0.10.2

详情介绍:

CodeColorer lets you insert syntax-highlighted code snippets into posts, comments, and feeds. CodeColorer currently bundles GeSHi 1.0.9.0 from the upstream 1.0.x line, with a small set of project-local maintenance patches for current PHP and WordPress compatibility. Plugin based on GeSHi library, which supports most languages. CodeColorer has various nice features: Support If you have any suggestions, found a bug, wanted to contribute a translation to your language, or just wanted to say "thank you", feel free to email me kpumuk@kpumuk.info. I will try my best to answer you. If you want to contribute your code, see the Development section under the Other Notes tab.

安装:

  1. Download and unpack plugin files to wp-content/plugins/codecolorer directory.
  2. Enable CodeColorer plugin on your Plugins page in Site Admin.
  3. Go to the Settings > CodeColorer page in Site Admin and change the plugin options as you wish.
  4. Use [cc lang="lang"]code[/cc] or <code lang="lang">code</code> syntax to insert a code snippet into the post (you can skip lang="lang" if you want a plain CodeColorer block without syntax highlighting). You can also use [cci lang="lang"]code[/cci] to format inline code (see the "inline" option description).
  5. Have fun!
Syntax To insert a code snippet into your post (or comment) you can use [cc lang="lang"]code[/cc] or <code lang="lang">code</code> syntax. Starting from version 0.6.0 you can specify additional CodeColorer options inside the [cc] tag: [cc lang="php" tab_size="2" lines="40"] // some code [/cc] Note: You should always use double quotes or single quotes around the parameter value. Boolean values could be passed using string true or false, on or off, number 1 or 0. Shortcodes Starting from CodeColorer 0.8.6 you can use shortcodes to insert code snippets. The general form looks like [ccM_LANG], where LANG is your programming language, and M is one or more of the following modes: Small letter means enabled, capital – disabled. Examples: PHP code with links enabled and line numbers disabled: [cclN_php] echo "hello" [/cclN_php] Already escaped HTML code: [ccie_html]<html>[/ccie_html] Ruby code without wrapping having tab size equal to 4: [ccW_ruby tab_size="4"] attr_accessor :title [/ccW_ruby] More examples could be found on the CodeColorer Examples page. You can find modes explained below. Possible parameters You can use special tag [cci] instead of [cc] to force inline mode: [cci lang="php"]some code[/cci] Most of these parameters could be configured via the CodeColorer options page. To insert an example of CodeColorer shortcodes you can use something like this: [cce_bash] [cc lang="html"] CodeColorer short code colorized [/cc] [/cce_bash]

屏幕截图:

  • Ruby syntax highlighting with scrollbars (Twitlight theme).
  • Inline code syntax highlighting.
  • Settings page.

常见问题:

How can I customize CodeColorer CSS rules?

Go to the Settings > CodeColorer page in Site Admin and change the "Custom CSS Styles" option.

I see < instead of < (or other HTML entities like >, &, ") in my code.

You should use [cc escaped="true"] or [cce] in the visual editor when inserting code into the post.

Does it highlight my code on the server or client side?

CodeColorer performs code highlighting on the server; you could see HTML of the highlighted code in the page source.

Does it produce valid XHTML source?

Yes, resulting XHTML is completely valid.

Could my visitors insert code snippets in comments?

Yes, CodeColorer supports code highlighting in comments using the same syntax, as you use in your blog posts.

How can I disable syntax highlighting for a particular <code> block?

Use <code no_cc="true"> option for your code block.

I have updated the plugin to the newest version and now I keep getting following warnings:

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/wordpress/wp-content/plugins/codecolorer/lib/geshi.php on line 3599 Remove all files from the wp-content/plugins/codecolorer folder and unpack an archive with plugin again (thanks to Anatoliy 'TLK' Kolesnick).

How do I insert code from an external file?

You can upload this file with the WordPress uploader or put it somewhere in the uploads folder, and then specify the relative path with the file="relative/path/to/file" attribute: [cc_ruby file="test_project/main.rb"][/cc_ruby] This snippet will insert code from the UPLOADS_DIR/test_project/main.rb file.

Google Website Translator breaks my code blocks

The solution is to add notranslate class to the list of "Custom CSS Classes" on the admin plugin settings page.

Is this plugin GDPR compliant?

Yes. We do not store or process any user information.

更新日志:

0.11.0 0.10.2 0.10.1 (May 28, 2023) 0.10.0 (April 28, 2023) 0.9.16 (July 23, 2018) 0.9.15 (February 24, 2017) 0.9.14 (October 25, 2017) 0.9.13 (October 24, 2017) 0.9.12 (October 12, 2017) 0.9.11 (August 8, 2017) 0.9.10 (July 28, 2017)