r41349 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41348‎ | r41349 | r41350 >
Date:15:30, 28 September 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* (bug 15634) Add The Enclosure/Header Type "none"
Modified paths:
  • /trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php (modified) (history)
  • /trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php
@@ -34,8 +34,8 @@
3535 * If you forget, or give an unsupported value, the extension spits out
3636 * some help text and a list of all supported languages.
3737 *
38 - * The extension has been tested with GeSHi 1.0.7 and MediaWiki 1.5 CVS
39 - * as of 2005-06-22.
 38+ * The extension has been tested with GeSHi 1.0.8 and MediaWiki 1.14a
 39+ * as of 2008-09-28.
4040 */
4141
4242 if( !defined( 'MEDIAWIKI' ) )
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
@@ -36,19 +36,9 @@
3737 $geshi = self::prepare( $text, $lang );
3838 if( !$geshi instanceof GeSHi )
3939 return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
40 - // "Enclose" parameter
41 - if ( isset( $args['enclose'] ) && $args['enclose'] == 'div' ) {
42 - $enclose = GESHI_HEADER_DIV;
43 - } elseif ( defined('GESHI_HEADER_PRE_VALID') ) {
44 - // Since version 1.0.8 geshi can produce valid pre, but we need to check for it
45 - $enclose = GESHI_HEADER_PRE_VALID;
46 - } elseif( isset( $args['line'] ) ) {
47 - // Force <div> mode to maintain valid XHTML, see
48 - // http://sourceforge.net/tracker/index.php?func=detail&aid=1201963&group_id=114997&atid=670231
49 - $enclose = GESHI_HEADER_DIV;
50 - } else {
51 - $enclose = GESHI_HEADER_PRE;
52 - }
 40+
 41+ $enclose = self::getEncloseType( $args );
 42+
5343 // Line numbers
5444 if( isset( $args['line'] ) ) {
5545 $geshi->enable_line_numbers( GESHI_FANCY_LINE_NUMBERS );
@@ -73,11 +63,15 @@
7464 return self::formatError( $err );
7565 } else {
7666 // Armour for Parser::doBlockLevels()
77 - if( $enclose == GESHI_HEADER_DIV )
 67+ if( $enclose === GESHI_HEADER_DIV )
7868 $out = str_replace( "\n", '', $out );
7969 // Register CSS
8070 $parser->mOutput->addHeadItem( self::buildHeadItem( $geshi ), "source-{$lang}" );
81 - return '<div dir="ltr" style="text-align: left;">' . $out . '</div>';
 71+ if ( $enclose === GESHI_HEADER_NONE ) {
 72+ return '<span class="'.$lang.' source-'.$lang.'"> '.$out . '</span>';
 73+ } else {
 74+ return '<div dir="ltr" style="text-align: left;">' . $out . '</div>';
 75+ }
8276 }
8377 }
8478
@@ -130,6 +124,33 @@
131125 $end - $start < $arbitrarilyLargeConstant;
132126 }
133127
 128+ static function getEncloseType( $args ) {
 129+ // Since version 1.0.8 geshi can produce valid pre, but we need to check for it
 130+ if ( defined('GESHI_HEADER_PRE_VALID') ) {
 131+ $pre = GESHI_HEADER_PRE_VALID;
 132+ } else {
 133+ $pre = GESHI_HEADER_PRE;
 134+ }
 135+
 136+ // "Enclose" parameter
 137+ $enclose = $pre;
 138+ if ( isset( $args['enclose'] ) ) {
 139+ if ( $args['enclose'] === 'div' ) {
 140+ $enclose = GESHI_HEADER_DIV;
 141+ } elseif ( $args['enclose'] === 'none' ) {
 142+ $enclose = GESHI_HEADER_NONE;
 143+ }
 144+ }
 145+
 146+ if( isset( $args['line'] ) && $pre === GESHI_HEADER_PRE ) {
 147+ // Force <div> mode to maintain valid XHTML, see
 148+ // http://sourceforge.net/tracker/index.php?func=detail&aid=1201963&group_id=114997&atid=670231
 149+ $enclose = GESHI_HEADER_DIV;
 150+ }
 151+
 152+ return $enclose;
 153+ }
 154+
134155 /**
135156 * Hook into Article::view() to provide syntax highlighting for
136157 * custom CSS and JavaScript pages

Status & tagging log