=== CodeColorer ===
Contributors: kpumuk
Tags: code, snippet, syntax, highlight, color, geshi
Requires at least: 2.0.2
Tested up to: 2.8.2
Stable tag: 0.8.6
CodeColorer is the plugin which allows you to insert code snippets to your posts with nice syntax highlighting powered by GeSHi library.
== Description ==
CodeColorer is the plugin which allows you to insert code snippets into the post with nice syntax highlighting.
Plugin based on GeSHi library, which supports most languages. CodeColorer has various nice features:
* syntax highlighting in RSS feeds
* syntax highlighting of single line of code (inline)
* syntax highlighting of code in comments
* line numbers
* automatic links to the documentation inserting
* code block intelligent scroll detection (short code would have short block, for long one block height would be fixed and scrollbar would appear)
* predefined color themes (Slush & Poppies, Blackboard, Dawn, Mac Classic, Twitlight, Vibrant Ink)
* syntax colors customization in CSS file
* code protect from mangling by Wordpress (for example, quotes, double-dashes, etc would look just right as you entered)
= Translations =
Thank you all guys, who submitted translations to your language. CodeColorer is currently available in following languages:
* English
* Russian - Русский
* Ukrainian - Українська
* Italian - Italiano (thanks to CodeSnippet)
* Belarusian - Беларуский (thanks to И. Фадков)
* Simplified Chinese - 简化字 (thanks to liuxiangqian)
== Installation ==
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 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.
Possible parameters:
* lang (string) -- source language.
* tab_size (integer) -- how many spaces would represent TAB symbol.
* line_numbers (boolean) -- when true line numbers will be added.
* first_line (integer) -- a number of the first line in the block.
* no_links (boolean) -- when false keywords will be represented as links to manual.
* 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).
* inline (boolean) -- when true forces code block to render inside <code>. 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 <code></code> tag.
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.
== Frequently Asked Questions ==
*Q*. How do I can customize CodeColorer CSS rules?
*A*. Go to the Options/CodeColorer page in Site Admin and change the "Custom CSS Styles" option.
*Q*. I see < instead of < (or other HTML entities like >, &, ") in my code.
*A*. You should use escaped="true" in the visual editor when inserting code into the post.
*Q*. Does it highlights my code on server or client side?
*A*. CodeColorer performs code highlighting on the server, you could see HTML of the highlighted code in page source.
*Q*. Is it produces valid XHTML source?
*A*. Yes, resulting XHTML is completely valid.
*Q*. Could my visitors insert their code snippets in comments?
*A*. Yes, CodeColorer supports code highlighting in comments using the same syntax, as you use in your blog posts.
*Q*. How can I disable syntax highlighting for a particular <code> block?
*A*. Use no_cc="true" option for your code block.
*Q*. 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
*A*. Remove all files from codecolorer folder and unpack an archive with plugin again (thanks to Anatoliy 'TLK' Kolesnick).
== Screenshots ==
1. Ruby syntax highlighting without scrollbars (Vibrant theme).
2. Ruby syntax highlighting with scrollbars (Twitlight theme).
== Changelog ==
= 0.8.6 (July 22, 2009) =
* Added a new option "escaped" to process code blocks with special HTML chars escaped (< -> <).
* Fixed regular expressions for PHP and some other languages.
* Use html_entity_decode instead of htmlspecialchars_decode if escaped="true".
* Added advanced syntax [ccMODE_LANG], where MODE is set of modes, and LAND is language.
= 0.8.5 (July 20, 2009) =
* Fixed bug occured when [cc] block goes just right after the [cci].
* Fixed bug with tab_size option saving (thanks to Marc Love).
= 0.8.4 (July 14, 2009) =
* Fixed inline code blocks formatting.
* Added special tag [cci] which works just like [cc], but with inline forced.
* Fixed problem when line numbers could not be disabled (thanks to miaow).
= 0.8.3 (July 14, 2009) =
* Added a new option "strict" to enable or disable strict mode.
* Added a new option "inline" which forces code block to render inside <code> tag. Used to paste a single line of code into the regular text.
* Trim only empty lines in the beginning of code, leave spaces untouched (thanks to FeepingCreature -- contact me please and I will add your link here).
* Allow "on" and "off" as boolean parameter value.
* Added Italian translation (thanks to CodeSnippet).
* Added Belarusian translation (thanks to И. Фадков).
= 0.8.2 (July 14, 2009) =
* Fixed problem with width and heigth specified at the same time.
* Added a new option "nowrap" to disable horizontal scrollbar.
* Added a new option "noborder" to disable a border around code block.
* Fixed inner table borders in some WordPress themes.
* Geshi updated to 1.0.8.4.
You can find complete changelog on the plugin home page.
== Supported languages ==
Here is list of supported by CodeColorer languages: abap, actionscript, actionscript3, ada, apache, applescript, apt\_sources, asm, asp, autoit, avisynth, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c\_mac, caddcl, cadlisp, cfdg, cfm, cil, cmake, cobol, cpp-qt, cpp, csharp, css, d, dcs, delphi, diff, div, dos, dot, eiffel, email, erlang, fo, fortran, freebasic, genero, gettext, glsl, gml, gnuplot, groovy, haskell, hq9plus, html4strict, idl, ini, inno, intercal, io, java, java5, javascript, kixtart, klonec, klonecpp, latex, lisp, locobasic, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, make, matlab, mirc, modula3, mpasm, mxml, mysql, nsis, oberon2, objc, ocaml-brief, ocaml, oobas, oracle11, oracle8, pascal, per, perl, php-brief, php, pic16, pixelbender, plsql, povray, powershell, progress, prolog, properties, providex, python, qbasic, rails, rebol, reg, robots, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, tcl, teraterm, text, thinbasic, tsql, typoscript, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xml, xorg\_conf, xpp, yaml, z80.
== Customization ==
Syntax coloring is highly customizable: you could change color scheme for all languages or for specific language. You could find CodeColorer CSS in wp-content/plugins/codecolorer/codecolorer.css file. To change colors for all languages edit lines below Color scheme section. Usually you would use only following CSS classes:
* *kw1*, *kw2*, *kw3* - keywords
* *co1*, *co2*, *coMULTI* - comments
* *es0* - escaped chars
* *br0* - brackets
* *st0* - strings
* *nu0* - numbers
* *me0* - methods
To change colors for specific language copy default values and add language name with a period before it. For example, you could use following color scheme for PHP:
.php .codecolorer .kw1 { color: #FF6600; font-weight: bolder; }
.php .codecolorer .kw2 { color: #339999; }
.php .codecolorer .kw3 { color: #FF6600; }
.php .codecolorer .kw4 { color: #DDE93D; }
.php .codecolorer .kw5 { color: #999966; }
.php .codecolorer .st0 { color: #66FF00; }
.php .codecolorer .es0 { color: #42A500; }
.php .codecolorer .br0 { color: Olive; }
.php .codecolorer .nu0 { color: #CCFF33; font-weight: bolder; }
.php .codecolorer .re0 { color: #339999; }
.php .codecolorer .re1 { color: #FFCC00; }
.php .codecolorer .re3 * { color: #FFFFFF; }
.php .codecolorer .re4, .php .codecolorer .re4 * {
color: #64A2FF;
}
.php .codecolorer .co1, .php .codecolorer .co2,
.php .codecolorer .coMULTI { color: #9933CC; }
Also you could change width of the code block in the top of CSS file (there are different values for different situations, for example when you code is places under <blockquote>).