summaryrefslogtreecommitdiff
path: root/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-02-28 08:36:29 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-02-28 08:36:29 +0100
commita4edbfa031eb4cd72678051f1510afde4f77951e (patch)
tree76cef11b1a13538c8982a7491dbbf7324d4a7b2a /extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
parent1b65fa2a5f4c48b02ceda934e9c1aee2d03ce453 (diff)
Update to MediaWiki 1.22.3
Diffstat (limited to 'extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php')
-rw-r--r--extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php43
1 files changed, 6 insertions, 37 deletions
diff --git a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
index 7318574d..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}" );
@@ -488,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;
- }
}