Installation

Go to the Options/CodeColorer page in Site Admin and change plugin’s options as you wish.

Use [cclang="lang"]code[/cc] or <codelang="lang">code</code> syntax to insert code snippet into the post (you could skip lang="lang", in this case code would be in code block, but without syntax highlighting). Also you can use [cci lang="lang"]code[/cci] to format inline code (see the “inline” option description). The list of available languages you could find below.

Have fun!

Syntax

To insert code snippet into your post (or comment) you should use [cclang="lang"]code[/cc] or <codelang="lang">code</code> syntax. Starting from version 0.6.0 you could specify additional CodeColorer options inside [cc] tag:

1

[cclang="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 [ccMODE_LANG], where LANG is your programming language, and MODE is the one or more of following modes:

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 <code></code> tag. Used to paste a single line of code into the regular text.

strict (boolean) – when truestrict 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 <code></code> tag.

Enter project name (something like CodeColorer 0.9.8), your name and email address, select a language you want to translate to and click OK.

Enter a filename like codecolorer-en_EN.po and click Save.

Translate all strings one by one.

Send me a .po file with a translation to [email protected]. Do not forget a link to add to CodeColorer project home page.

Thank you!

To fix existing translation, just open corresponding .po file from codecolorer/languages folder in Poedit, and add missing or update existing strings.

Customization

Syntax coloring is highly customizable: you could change color scheme for all
languages or for specific language. You could find CodeColorer CSS inwp-content/plugins/codecolorer/codecolorer.css file. To change colors for
all languages edit lines below Color scheme section.

There is simple mapping exists between Textmate color themes and CodeColorer
ones:

Development

Feel free to check them out, make your changes and send me patches. Promise, I will apply every patch (of course, if they add a value to the product). Email for patches, suggestions, or bug reports: [email protected]. Also you have much more ways to contact me.

Changelog

0.9.14 (October 25, 2017)

IMPORTANT: Another line numbers column width issue for numbers bigger than 1000.

I am having a few problems with CodeColorer. First off, it seems that no matter what or where I set the tab_length to it equals 4. Also, if I post some code, and then go to edit it later, all of the tabs disappear. Is there any way that the CodeColorer could automatically insert tabs where it makes sense?

Post a comment

Name (required)

Email (will not be published) (required)

Website

You can use simple HTML-formatting tags (like <a>, <strong>, <em>, <ul>, <blockquote>, and other). To format your code sample use [cclang="php"]$a = "hello";[/cc] (allowed languages are ruby, php, yaml, html, csharp, javascript). Also you can use [cc][/cc] block and its syntax would not be highlighted.