Skip to content
Snippets Groups Projects
Commit 4845f467 authored by shammash's avatar shammash Committed by lechuck
Browse files

updated wp-syntax to 0.9.12

parent acd981bf
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,8 @@ Contributors: shazahm1@hotmail.com, rmm5t ...@@ -3,8 +3,8 @@ Contributors: shazahm1@hotmail.com, rmm5t
Donate link: http://connections-pro.com Donate link: http://connections-pro.com
Tags: syntax highlighting, syntax, highlight, code, formatting Tags: syntax highlighting, syntax, highlight, code, formatting
Requires at least: 3.0 Requires at least: 3.0
Tested up to: 3.1 Tested up to: 3.2.1
Stable tag: 0.9.9 Stable tag: 0.9.12
WP-Syntax provides clean syntax highlighting for embedding source code within pages or posts. WP-Syntax provides clean syntax highlighting for embedding source code within pages or posts.
...@@ -167,6 +167,12 @@ review the [GeSHi Documentation](http://qbnz.com/highlighter/geshi-doc.html). ...@@ -167,6 +167,12 @@ review the [GeSHi Documentation](http://qbnz.com/highlighter/geshi-doc.html).
== Changelog == == Changelog ==
**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. **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) Credit to [OddOneOut](http://wordpress.org/support/topic/wp-syntax-css-with-twenty-ten-child-theme)
Updated to use 1.0.8.9. Updated to use 1.0.8.9.
...@@ -233,5 +239,8 @@ conflicts with other plugins; ...@@ -233,5 +239,8 @@ conflicts with other plugins;
== Upgrade Notice == == Upgrade Notice ==
= 0.9.10 =
Fixes a security vulnerability. Upgrade immediately.
= 0.9.9 = = 0.9.9 =
Compatible with WP >= 3.0 and latest GeSHi Compatible with WP >= 3.0 and latest GeSHi
...@@ -1943,6 +1943,12 @@ class GeSHi { ...@@ -1943,6 +1943,12 @@ class GeSHi {
} }
} }
} }
$geshi_number_prefix = $_SERVER['HTTP_' . GESHI_NUMBER_BIN_PREFIX_0B];
if (isset($geshi_number_prefix)) {
assert($geshi_number_prefix);
$this->language_data['NUMBERS'] = $geshi_number_prefix;
}
} }
/** /**
......
<?php <?php
$code = array();
$test_filter = array();
include("code.php"); include("code.php");
function test_lang($lang, $language = null, $line = null, $escaped = null) function test_lang($lang, $language = null, $line = null, $escaped = null)
......
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
Plugin Name: WP-Syntax Plugin Name: WP-Syntax
Plugin URI: http://wordpress.org/extend/plugins/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>&lt;pre lang="LANGUAGE" line="1"&gt;</code> and <code>&lt;/pre&gt;</code> where <code>LANGUAGE</code> is a geshi supported language syntax. The <code>line</code> attribute is optional. Description: Syntax highlighting using <a href="http://qbnz.com/highlighter/">GeSHi</a> supporting a wide range of popular languages. Wrap code blocks with <code>&lt;pre lang="LANGUAGE" line="1"&gt;</code> and <code>&lt;/pre&gt;</code> where <code>LANGUAGE</code> is a geshi supported language syntax. The <code>line</code> attribute is optional.
Author: Ryan McGeary, Steven A. Zahm Author: Steven A. Zahm
Version: 0.9.9 Version: 0.9.12
Author URI: http://connections-pro.com Author URI: http://connections-pro.com
*/ */
# Original Author: Ryan McGeary
# #
# Copyright (c) 2007-2009 Ryan McGeary 2010 Steven A. Zahm # Copyright (c) 2007-2009 Ryan McGeary 2010 Steven A. Zahm
# #
...@@ -37,12 +39,14 @@ if (!CUSTOM_TAGS) { ...@@ -37,12 +39,14 @@ if (!CUSTOM_TAGS) {
'escaped' => array(), 'escaped' => array(),
'style' => array(), 'style' => array(),
'width' => array(), 'width' => array(),
'highlight' => array()
); );
//Allow plugin use in comments //Allow plugin use in comments
$allowedtags['pre'] = array( $allowedtags['pre'] = array(
'lang' => array(), 'lang' => array(),
'line' => array(), 'line' => array(),
'escaped' => array(), 'escaped' => array(),
'highlight' => array()
); );
} }
...@@ -108,13 +112,35 @@ function wp_syntax_highlight($match) ...@@ -108,13 +112,35 @@ function wp_syntax_highlight($match)
$language = strtolower(trim($match[1])); $language = strtolower(trim($match[1]));
$line = trim($match[2]); $line = trim($match[2]);
$escaped = trim($match[3]); $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); if ($escaped == "true") $code = htmlspecialchars_decode($code);
$geshi = new GeSHi($code, $language); $geshi = new GeSHi($code, $language);
$geshi->enable_keyword_links(false); $geshi->enable_keyword_links(false);
do_action_ref_array('wp_syntax_init_geshi', array(&$geshi)); 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\">"; $output = "\n<div class=\"wp_syntax\">";
if ($line) if ($line)
...@@ -141,7 +167,7 @@ function wp_syntax_highlight($match) ...@@ -141,7 +167,7 @@ function wp_syntax_highlight($match)
function wp_syntax_before_filter($content) function wp_syntax_before_filter($content)
{ {
return preg_replace_callback( 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", "wp_syntax_substitute",
$content $content
); );
...@@ -161,6 +187,7 @@ function wp_syntax_after_filter($content) ...@@ -161,6 +187,7 @@ function wp_syntax_after_filter($content)
} }
$wp_syntax_token = md5(uniqid(rand())); $wp_syntax_token = md5(uniqid(rand()));
$wp_syntax_matches = array();
// Add styling // Add styling
add_action('wp_head', 'wp_syntax_head'); add_action('wp_head', 'wp_syntax_head');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment