WordPress.org

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

CodeColorer

CodeColorer is a syntax highlighting plugin which allows to insert code snippets into blog posts. Supports color themes, code in RSS, comments.

  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 Options/CodeColorer page in Site Admin and change plugin's options as you wish.
  4. Use [cc lang="lang"]code[/cc] or <code lang="lang">code</cc> syntax to insert code snippet into the post (you could skip lang="lang", in this case code would be in CodeColorer's code block, but without syntax highlighting). Also you can use [cci lang="lang"]code[/cci] to format inline code (see the "inline" option description).
  5. Have fun!

Syntax

To insert code snippet into your post (or comment) you should use

[cc lang="lang"]code[/cc]

or <code lang="lang">code</cc> syntax. Starting from version 0.6.0 you could specify additional CodeColorer options inside

[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.

Short codes

Starting from CodeColorer 0.8.6 you can use short codes to insert code snippets. The short code in common looks like [ccM_LANG], where LANG is your programming language, and M is the one or more of following modes:

  • iinline
  • eescaped
  • sstrict
  • nline_numbers
  • bno_border
  • wno_wrap
  • lno_links

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]&lt;html&gt;[/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

  • lang (string) – source language.
  • tab_size (integer) – how many spaces would represent TAB symbol.
  • lines (integer) – how many lines would be block height without scroll; could be set to -1 to remove vertical scrollbar.
  • width (integer or string) – block width.
  • height (integer or string) – height in pixels; used when lines number is greater then "lines" value.
  • rss_width (integer or string) – block width in RSS feeds.
  • theme (string) – color theme (default, blackboard, dawn, mac-classic, twitlight, vibrant, geshi).
  • first_line (integer) – a number of the first line in the block.
  • highlight (string) — a comma-separated list of line numbers or ranges of line numbers to highlight (e.g. 1,5,8-11).
  • escaped (boolean) – when true special HTML sequences like &lt; or [ will be treated as encoded (in this example as < and [ respectively.)
  • line_numbers (boolean) – when true line numbers will be added.
  • no_links (boolean) – when false keywords will be represented as links to manual.
  • inline (boolean) – when true forces code block to render inside ```. Used to paste a single line of code into the regular text.
  • strict (boolean) – when true strict mode will be enabled. By default CodeColorer tries to guess whether strict mode is needed, so this option allows to force it on or off when automatic suggestion is wrong.
  • nowrap (boolean) – when false no horizontal scrollbar will be shown; instead code will be wrapped in the end of code box.
  • noborder (boolean) – when true no border will be shown around the code block.
  • no_cc (boolean) – when true the syntax in code block will not be highlighted, code will be rendered inside ``` tag.
  • class (string) – additional CSS classes to add to the wrapper HTML element.
  • file (string) — when specified, code will be loaded from external file. Should be a relative to uploads folder path, only files from uploads are allowed to be embedded.

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 example of CodeColorer short codes you can use something like this:

[cce_bash]
&amp;#91;cc lang="html"]
<title>CodeColorer short code colorized</title>
&amp;#91;/cc]
[/cce_bash]

Requires: 2.7.0 or higher
Compatible up to: 3.1.4
Last Updated: 2011-4-28
Active Installs: 6,000+

Ratings

4.9 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1
100,4,4 100,1,1
100,2,2 100,3,3 100,2,2
100,3,3
75,4,3
100,5,5 89,9,8
100,2,2
83,6,5
100,2,2
100,2,2
100,1,1
100,6,6
67,3,2 100,4,4
100,1,1 100,4,4
100,1,1
100,1,1
0,1,0
100,6,6
100,2,2
100,5,5
100,2,2
100,6,6
100,4,4
100,1,1
100,1,1
100,2,2
100,1,1
0,1,0
0,1,0
100,1,1