Usage
Wrap code blocks with and
where LANGUAGE is a GeSHi supported language syntax. See below for a full list of supported languages. The
line
attribute is optional.
Example 1: PHP, no line numbers
function foo() {
echo "Hello World!\\n";
}
for (\$i = 0; \$i < 10 $i++) {
foo();
}
?>
Example 2: Java, with line numbers
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Example 3: Ruby, with line numbers starting at 18
class Example
def example(arg1)
return "Hello: " + arg1.to_s
end
end
Supported Languages
The following languages are supported in the lang
attribute:
actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp-qt, cpp, csharp, css-gen, css, d, delphi, diff, div, dos, eiffel, fortran, freebasic, gml, groovy, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, matlab, mirc, mpasm, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle8, pascal, perl, php-brief, php, plsql, python, qbasic, rails, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, xpp, z80
(Bold languages just highlight the more popular ones.)
Styling Guidelines
WP-Syntax uses default GeSHi colors by default. It also uses inline styling to make sure that code highlights still work in RSS feeds. To spruce up your code snippets to look more like the screenshots, try adding this CSS to your stylesheet template:
.wp_syntax {
color: #100;
background-color: #f9f9f9;
border: 1px solid silver;
margin: 0 0 1.5em 0;
overflow: auto;
}
/* IE FIX */
.wp_syntax {
overflow-x: auto;
overflow-y: hidden;
padding-bottom: expression(this.scrollWidth > this.offsetWidth ? 15 : 0);
width: 100%;
}
.wp_syntax table {
border-collapse: collapse;
}
.wp_syntax div, .wp_syntax td {
vertical-align: top;
padding: 2px 4px;
}
.wp_syntax .line_numbers {
text-align: right;
background-color: #def;
color: gray;
overflow: visible;
}
/* potential overrides for other styles */
.wp_syntax pre {
margin: 0;
width: auto;
float: none;
clear: none;
overflow: visible;
没有评论:
发表评论