=== CodeColorer === Contributors: kpumuk Tags: code, snippet, syntax, highlight, color, geshi Requires at least: 2.0.2 Tested up to: 2.7 Stable tag: 0.7.0 CodeColorer is the plugin which allows you to insert code snippets into the post with nice syntax highlighting. == 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: * 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 * syntax highlighting of the code in comments * code protect from mangling by Wordpress (for example, quotes, double-dashes, etc would look just right as you entered) == Installation == 1. Download and unpack plugin files to wp-content/plugins/codecolorer directory. 2. If you have not used CodeColorer early, rename wp-content/plugins/codecolorer/codecolorer.css.in to wp-content/plugins/codecolorer/codecolorer.css. 3. Enable "CodeColorer" plugin on your Plugins page in Site Admin. 4. Go to the Options/CodeColorer page in Site Admin and change plugin's options as you wish. 5. 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). 6. 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, 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. * 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) -- block width. * height (integer) -- height in pixels; used when lines number is greater then "lines" value. * theme (string) -- color theme (default, blackboard, dawn, mac-classic, twitlight, vibrant). All of these parameters could be configured via the CodeColorer options page. == Screenshots == 1. Ruby syntax highlighting without scrollbars. 2. CSS syntax highlighting with scrollbars. == Frequently Asked Questions == *Q*. I have enabled plugin in Site Admin, but my code samples are not highlighted. *A*. You forgot to rename codecolorer.css.in to codecolorer.css. See step 2. *Q*. I see &lt; instead of < (or other HTML entities like >, &, ") in my code. *A*. You are should not use the visual editor when writing 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. == 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, blitzbasic, bnf, boo, c, c_mac, caddcl, cadlisp, cfdg, cfm, cil, cobol, cpp-qt, cpp, csharp, css-gen.cfg, css, d, delphi, diff, div, dos, dot, eiffel, email, fortran, freebasic, genero, gettext, glsl, gml, gnuplot, groovy, haskell, hq9plus, html4strict, idl, ini, inno, intercal, io, java, java5, javascript, kixtart, klonec, klonecpp, latex, lisp, lolcode, lotusformulas, lotusscript, lscript, lua, m68k, make, matlab, mirc, mpasm, mxml, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle11, oracle8, pascal, per, perl, php-brief, php, pic16, pixelbender, plsql, povray, powershell, progress, prolog, providex, python, qbasic, rails, 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, 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>).