diff options
Diffstat (limited to 'extensions/SyntaxHighlight_GeSHi')
4 files changed, 40 insertions, 18 deletions
diff --git a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php index b1c9851d..7318574d 100644 --- a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php +++ b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php @@ -28,6 +28,12 @@ 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']; @@ -95,12 +101,6 @@ 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 	 to tab, so we can armor it that way. - if( $wgUseTidy ) { - $out = str_replace( "\t", '	', $out ); - } // Register CSS $parser->getOutput()->addHeadItem( self::buildHeadItem( $geshi ), "source-{$lang}" ); @@ -488,4 +488,35 @@ 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; + } } diff --git a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php index 9b940f3e..8555c4f9 100644 --- a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php +++ b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php @@ -688,11 +688,10 @@ $messages['ksh'] = array( /** Luxembourgish (Lëtzebuergesch) * @author Les Meloures * @author Robby - * @author Soued031 */ $messages['lb'] = array( 'syntaxhighlight-desc' => "Syntax-Ervirhiewung <code><syntaxhighlight></code> mat Hëllef vu [http://qbnz.com/highlighter/ 'GeSHi Highlighter']", - 'syntaxhighlight-specify' => 'Déi gewënscht Sprooch muss sou definéiert ginn:', + 'syntaxhighlight-specify' => 'Déi gewënscht Sprooch muss esou definéiert ginn:', 'syntaxhighlight-supported' => "Ënnerstëtzte Sprooche fir d'Syntax faarweg ze markéieren", 'syntaxhighlight-err-loading' => '(Feeler beim Luede vun der Lëscht vun den ënnerstëtzte Sproochen)', 'syntaxhighlight-err-language' => 'Net valabel Sprooch.', diff --git a/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php b/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php index 4323d05c..60741577 100644 --- a/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php +++ b/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php @@ -41,7 +41,7 @@ // /** The version of this GeSHi file */ -define('GESHI_VERSION', '1.0.8.11-wmf1'); // WMF fix for Haskell (bug 52509) +define('GESHI_VERSION', '1.0.8.11'); // Define the root directory for the GeSHi code tree if (!defined('GESHI_ROOT')) { diff --git a/extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php b/extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php index d3b494ed..adae1116 100644 --- a/extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php +++ b/extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php @@ -13,14 +13,6 @@ * ------- * 2005/08/27 (1.0.0) * - First Release - * 2013/09/28 - * - Single quotes dropped from QUOTEMARKS to resolve <https://bugzilla.wikimedia.org/52509>. - * Change is local to SyntaxHighlight_GeSHi, made by Ori Livneh (ori@wikimedia.org), based - * on a proposed upstream patch. - * Upstream bug report: - * <http://sourceforge.net/p/geshi/bugs/217/> - * Upstream patch (stalled since 2012): - * <http://sourceforge.net/p/geshi/bugs/219/> * * TODO (updated 2005/08/27) * ------------------------- @@ -54,7 +46,7 @@ $language_data = array ( 3 => "/{-(?:(?R)|.)-}/s", //Nested Comments ), 'CASE_KEYWORDS' => 0, - 'QUOTEMARKS' => array('"'), // SyntaxHighlight_GeSHi modification; see CHANGES above. + 'QUOTEMARKS' => array('"',"'"), 'ESCAPE_CHAR' => '\\', 'KEYWORDS' => array( /* main haskell keywords */ |