summaryrefslogtreecommitdiff
path: root/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
commit4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch)
treeaf68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
parentaf4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff)
Update to MediaWiki 1.22.0
Diffstat (limited to 'extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php')
-rw-r--r--extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php48
1 files changed, 10 insertions, 38 deletions
diff --git a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
index 4538a5f1..b1c9851d 100644
--- a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
+++ b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
@@ -28,12 +28,6 @@ class SyntaxHighlight_GeSHi {
// Don't trim leading spaces away, just the linefeeds
$text = preg_replace( '/^\n+/', '', $text );
- if( $wgUseTidy ) {
- // HTML Tidy will convert tabs to spaces incorrectly (bug 30930).
- // Preemptively replace the spaces in a more controlled fashion.
- $text = self::tabsToSpaces( $text );
- }
-
// Validate language
if( isset( $args['lang'] ) && $args['lang'] ) {
$lang = $args['lang'];
@@ -101,6 +95,12 @@ class SyntaxHighlight_GeSHi {
if( $enclose === GESHI_HEADER_DIV ) {
$out = str_replace( "\n", '', $out );
}
+ // HTML Tidy will convert tabs to spaces incorrectly (bug 30930).
+ // But the conversion from tab to space occurs while reading the input,
+ // before the conversion from &#9; to tab, so we can armor it that way.
+ if( $wgUseTidy ) {
+ $out = str_replace( "\t", '&#9;', $out );
+ }
// Register CSS
$parser->getOutput()->addHeadItem( self::buildHeadItem( $geshi ), "source-{$lang}" );
@@ -327,6 +327,9 @@ class SyntaxHighlight_GeSHi {
* @return GeSHi
*/
public static function prepare( $text, $lang ) {
+
+ global $wgSyntaxHighlightKeywordLinks;
+
self::initialise();
$geshi = new GeSHi( $text, $lang );
if( $geshi->error() == GESHI_ERROR_NO_SUCH_LANG ) {
@@ -335,7 +338,7 @@ class SyntaxHighlight_GeSHi {
$geshi->set_encoding( 'UTF-8' );
$geshi->enable_classes();
$geshi->set_overall_class( "source-$lang" );
- $geshi->enable_keyword_links( false );
+ $geshi->enable_keyword_links( $wgSyntaxHighlightKeywordLinks );
// If the source code is over 100 kB, disable higlighting of symbols.
// If over 200 kB, disable highlighting of strings too.
@@ -485,35 +488,4 @@ class SyntaxHighlight_GeSHi {
public static function hOldSpecialVersion_GeSHi( &$sp, &$extensionTypes ) {
return self::hSpecialVersion_GeSHi( $extensionTypes );
}
-
- /**
- * Convert tabs to spaces
- *
- * @param string $text
- * @return string
- */
- private static function tabsToSpaces( $text ) {
- $lines = explode( "\n", $text );
- $lines = array_map( array( __CLASS__, 'tabsToSpacesLine' ), $lines );
- return implode( "\n", $lines );
- }
-
- /**
- * Convert tabs to spaces for a single line
- *
- * @param $line
- * @internal param string $text
- * @return string
- */
- private static function tabsToSpacesLine( $line ) {
- $parts = explode( "\t", $line );
- $width = 8; // To match tidy's config & typical browser defaults
- $out = $parts[0];
- foreach( array_slice( $parts, 1 ) as $chunk ) {
- $spaces = $width - (strlen( $out ) % $width);
- $out .= str_repeat( ' ', $spaces );
- $out .= $chunk;
- }
- return $out;
- }
}