Commit 4845f467 authored by shammash's avatar shammash Committed by lechuck
Browse files

updated wp-syntax to 0.9.12

parent acd981bf
......@@ -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
Stable tag: 0.9.9
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,7 +167,13 @@ review the [GeSHi Documentation](http://qbnz.com/highlighter/geshi-doc.html).
== Changelog ==
**0.9.9** : Fix to support child theme's. WP-Syntax now requires WP >= 3.0.
**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)
Updated to use 1.0.8.9.
......@@ -233,5 +239,8 @@ conflicts with other plugins;
== Upgrade Notice ==
= 0.9.10 =
Fixes a security vulnerability. Upgrade immediately.
= 0.9.9 =
Compatible with WP >= 3.0 and latest GeSHi
\ No newline at end of file
Compatible with WP >= 3.0 and latest GeSHi
<?php
$code = array();
$test_filter = array();
include("code.php");
function test_lang($lang, $language = null, $line = null, $escaped = null)
......
......@@ -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>&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
Version: 0.9.9
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()
);
}
......@@ -59,7 +63,7 @@ function wp_syntax_head()
$css_url = get_bloginfo("template_url") . "/wp-syntax.css";
}
echo "\n".'<link rel="stylesheet" href="' . $css_url . '" type="text/css" media="screen" />'."\n";*/
$css_url = WP_PLUGIN_URL . "/wp-syntax/wp-syntax.css";
if (file_exists(STYLESHEETPATH . "/wp-syntax.css"))
{
......@@ -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
);
......@@ -161,6 +187,7 @@ function wp_syntax_after_filter($content)
}
$wp_syntax_token = md5(uniqid(rand()));
$wp_syntax_matches = array();
// Add styling
add_action('wp_head', 'wp_syntax_head');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment