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.

It would be so cool to have multiple language support in one code block! I love the plugin and intend to use it for a long time, but I think I would really like to see a lang code that supports the use of JS, CSS, HTML, and PHP all in one block. I know geshi does it with PHP and HTML already. Not sure how you could accomplish all together, or a combination, even if we had to define our own classes, colors.

Hi Dmytro, I love this plugin. I would like to report an issue I ran into (not sure if it’s a bug exactly), when loading code from a file. I uploaded a powershell script to my site and I had two problems with using CC to display it:

1) the script was using CR+LF and so the display showed extra line breaks. This was fixed when I changed to CR only, but powershell is used on Windows, and if I want to offer the file for direct download as well, it would be best if I could have it in CR+LF. Any chance of supporting these line endings natively?

2) My encoding was UTF-16. This is the default for powershell when you edit the scripts in Powershell ISE (the IDE for PS). This caused strange characters at the beginning of the script, improper highlighting, and loss of indentation. When I changed it to UTF-8 it was fine, but again, this means having to modify the files from default. I would love to see support for this as well.

I also have two feature requests:
1) A one-click copy button to put all of the code into the clipboard.
2) A download link to get the code as a file.

CC is already the best highlighting plugin in my opinion. These changes would make it perfect, for me.

I’ve used this WordPress plugin for years now and just love it …
Since there have been quite a few changes in WP Core, I was wondering if this plugin will be updated in the near future?
(just curious, if development stopped, then I’d better prepare to switch to another plugin – which I’d hate to do)

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.