diff options
author | Theo Chatzimichos <tampakrap@gentoo.org> | 2011-08-01 14:17:42 +0300 |
---|---|---|
committer | Theo Chatzimichos <tampakrap@gentoo.org> | 2011-08-01 14:17:42 +0300 |
commit | 70011eb7f2f5c26a3b9bfee28863c3aa8dcdc2f7 (patch) | |
tree | 9f834d1696c4b647594ca3e19aef6dc50c0ebb0b /plugins/wp-syntax | |
parent | Update smart-youtube and wp-syntax (diff) | |
download | blogs-gentoo-70011eb7f2f5c26a3b9bfee28863c3aa8dcdc2f7.tar.gz blogs-gentoo-70011eb7f2f5c26a3b9bfee28863c3aa8dcdc2f7.tar.bz2 blogs-gentoo-70011eb7f2f5c26a3b9bfee28863c3aa8dcdc2f7.zip |
Update wp-importer and wp-syntax
Diffstat (limited to 'plugins/wp-syntax')
-rw-r--r-- | plugins/wp-syntax/README.txt | 11 | ||||
-rw-r--r-- | plugins/wp-syntax/wp-syntax.php | 48 |
2 files changed, 44 insertions, 15 deletions
diff --git a/plugins/wp-syntax/README.txt b/plugins/wp-syntax/README.txt index 3a322642..174ac431 100644 --- a/plugins/wp-syntax/README.txt +++ b/plugins/wp-syntax/README.txt @@ -3,8 +3,8 @@ Contributors: shazahm1@hotmail.com, rmm5t Donate link: http://connections-pro.com Tags: syntax highlighting, syntax, highlight, code, formatting Requires at least: 3.0 -Tested up to: 3.1.3 -Stable tag: 0.9.10 +Tested up to: 3.2.1 +Stable tag: 0.9.12 WP-Syntax provides clean syntax highlighting for embedding source code within pages or posts. @@ -167,8 +167,11 @@ review the [GeSHi Documentation](http://qbnz.com/highlighter/geshi-doc.html). == Changelog == -**0.9.10** : Fix for security vulnerability when register_globals in php is - enabled; +**0.9.12** : Fixed a range bug in the new highlight feature. + +**0.9.11** : Added line highlighting support. User submitted patch. [Thanks Flynsarmy && Chimo](http://www.flynsarmy.com/2011/06/how-to-add-line-highlight-support-to-wp-syntax/) + +**0.9.10** : Fix for security vulnerability when register_globals in php is enabled. **0.9.9** : Fix to support child theme's. WP-Syntax now requires WP >= 3.0. Credit to [OddOneOut](http://wordpress.org/support/topic/wp-syntax-css-with-twenty-ten-child-theme) diff --git a/plugins/wp-syntax/wp-syntax.php b/plugins/wp-syntax/wp-syntax.php index db9ea98b..3d195ead 100644 --- a/plugins/wp-syntax/wp-syntax.php +++ b/plugins/wp-syntax/wp-syntax.php @@ -3,11 +3,13 @@ Plugin Name: WP-Syntax Plugin URI: http://wordpress.org/extend/plugins/wp-syntax/ Description: Syntax highlighting using <a href="http://qbnz.com/highlighter/">GeSHi</a> supporting a wide range of popular languages. Wrap code blocks with <code><pre lang="LANGUAGE" line="1"></code> and <code></pre></code> where <code>LANGUAGE</code> is a geshi supported language syntax. The <code>line</code> attribute is optional. -Author: Ryan McGeary, Steven A. Zahm -Version: 0.9.10 +Author: Steven A. Zahm +Version: 0.9.12 Author URI: http://connections-pro.com */ +# Original Author: Ryan McGeary + # # Copyright (c) 2007-2009 Ryan McGeary 2010 Steven A. Zahm # @@ -37,12 +39,14 @@ if (!CUSTOM_TAGS) { 'escaped' => array(), 'style' => array(), 'width' => array(), + 'highlight' => array() ); //Allow plugin use in comments $allowedtags['pre'] = array( 'lang' => array(), 'line' => array(), 'escaped' => array(), + 'highlight' => array() ); } @@ -101,22 +105,44 @@ function wp_syntax_line_numbers($code, $start) function wp_syntax_highlight($match) { global $wp_syntax_matches; - + $i = intval($match[1]); $match = $wp_syntax_matches[$i]; - + $language = strtolower(trim($match[1])); $line = trim($match[2]); $escaped = trim($match[3]); - $code = wp_syntax_code_trim($match[4]); + + $code = wp_syntax_code_trim($match[5]); if ($escaped == "true") $code = htmlspecialchars_decode($code); - + $geshi = new GeSHi($code, $language); $geshi->enable_keyword_links(false); do_action_ref_array('wp_syntax_init_geshi', array(&$geshi)); - + + //START LINE HIGHLIGHT SUPPORT + $highlight = array(); + if ( !empty($match[4]) ) + { + $highlight = strpos($match[4],',') == false ? array($match[4]) : explode(',', $match[4]); + + $h_lines = array(); + for( $i=0; $i<sizeof($highlight); $i++ ) + { + $h_range = explode('-', $highlight[$i]); + + if( sizeof($h_range) == 2 ) + $h_lines = array_merge( $h_lines, range($h_range[0], $h_range[1]) ); + else + array_push($h_lines, $highlight[$i]); + } + + $geshi->highlight_lines_extra( $h_lines ); + } + //END LINE HIGHLIGHT SUPPORT + $output = "\n<div class=\"wp_syntax\">"; - + if ($line) { $output .= "<table><tr><td class=\"line_numbers\">"; @@ -132,16 +158,16 @@ function wp_syntax_highlight($match) $output .= "</div>"; } return - + $output .= "</div>\n"; - + return $output; } function wp_syntax_before_filter($content) { return preg_replace_callback( - "/\s*<pre(?:lang=[\"']([\w-]+)[\"']|line=[\"'](\d*)[\"']|escaped=[\"'](true|false)?[\"']|\s)+>(.*)<\/pre>\s*/siU", + "/\s*<pre(?:lang=[\"']([\w-]+)[\"']|line=[\"'](\d*)[\"']|escaped=[\"'](true|false)?[\"']|highlight=[\"']((?:\d+[,-])*\d+)[\"']|\s)+>(.*)<\/pre>\s*/siU", "wp_syntax_substitute", $content ); |