=== WP-Syntax === Contributors: rmm5t Donate link: http://ryan.mcgeary.org/wp-syntax/ Tags: syntax highlighting, syntax, highlight, code, formatting Requires at least: 2.0 Tested up to: 2.1.2 Stable tag: 0.5 WP-Syntax provides clean syntax highlighting for embedding source code within pages or posts. == Description == WP-Syntax provides clean syntax highlighting using [geshi](http://qbnz.com/highlighter/) -- supporting a wide range of popular languages. It supports highlighting with or without line numbers and maintains formatting while copying snippets of code from the browser. It is a bit unique in that it runs an early pre filter and a late post filter which helps it avoid conflicts with other 3rd party plugins. The result is source code formatted and highlighted the way you intended. This plugin was originally written for use with [EmacsBlog](http://www.emacsblog.org). To see it in action, scroll through this [particular post](http://www.emacsblog.org/2007/02/22/maximize-on-startup-part-2/) or visit the [screenshots](http://wordpress.org/extend/plugins/wp-syntax/screenshots/). = Basic Usage = Wrap code blocks with `
` and `` where
`LANGUAGE` is a geshi supported language syntax. The `line` attribute is
optional. [More usage
examples](http://wordpress.org/extend/plugins/wp-syntax/other_notes/)
== Installation ==
1. Upload wp-syntax.zip to your Wordpress plugins directory, usually `wp-content/plugins/` and unzip the file. It will create a `wp-content/plugins/wp-syntax/` directory.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Create a post/page that contains a code snippet following the [proper usage syntax](http://wordpress.org/extend/plugins/wp-syntax/other_notes/).
== Frequently Asked Questions ==
= Why is the plugin generating strange output? =
Try editing code snippets without the visual editor. To turn off the visual
editor for all your edits, uncheck the visual editor checkbox in your profile.
Depending on what type of code you're trying to display, you might also need
to disable WordPress' corrections of invalidly nested XMTML (under Options ->
Writing).
== Screenshots ==
1. PHP, no line numbers.
2. Java, with line numbers.
3. Ruby, with line numbers starting at 18.
4. Ruby, no line numbers with default styling.
== Usage ==
Wrap code blocks with `` and `` where
`LANGUAGE` is a geshi supported language syntax. The `line` attribute is
optional.
**Example 1: PHP, no line numbers**
**Example 2: Java, with line numbers**
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
**Example 2: Ruby, with line numbers starting at 18**
class Example
def example(arg1)
return "Hello: " + arg1.to_s
end
end
== Styling ==
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);
}
.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;
}
== Release Notes ==
**0.5** : Added support for single quoted attributes;
([#624](http://dev.wp-plugins.org/ticket/624))
**0.4** : Cleanup and documentation for WordPress.org [plugin
listings](http://wordpress.org/extend/plugins/);
**0.3** : First official public release; Added line number support; Uses geshi v1.0.7.18;
([#532](http://dev.wp-plugins.org/ticket/532))
**0.2** : Internal release; Adds "before and after" filter support to avoid
conflicts with other plugins;
([#531](http://dev.wp-plugins.org/ticket/531))
**0.1** : First internal release; Uses geshi v1.0.7.16;