Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php |
— | — | @@ -34,8 +34,8 @@ |
35 | 35 | * If you forget, or give an unsupported value, the extension spits out |
36 | 36 | * some help text and a list of all supported languages. |
37 | 37 | * |
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. |
40 | 40 | */ |
41 | 41 | |
42 | 42 | if( !defined( 'MEDIAWIKI' ) ) |
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php |
— | — | @@ -36,19 +36,9 @@ |
37 | 37 | $geshi = self::prepare( $text, $lang ); |
38 | 38 | if( !$geshi instanceof GeSHi ) |
39 | 39 | 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 | + |
53 | 43 | // Line numbers |
54 | 44 | if( isset( $args['line'] ) ) { |
55 | 45 | $geshi->enable_line_numbers( GESHI_FANCY_LINE_NUMBERS ); |
— | — | @@ -73,11 +63,15 @@ |
74 | 64 | return self::formatError( $err ); |
75 | 65 | } else { |
76 | 66 | // Armour for Parser::doBlockLevels() |
77 | | - if( $enclose == GESHI_HEADER_DIV ) |
| 67 | + if( $enclose === GESHI_HEADER_DIV ) |
78 | 68 | $out = str_replace( "\n", '', $out ); |
79 | 69 | // Register CSS |
80 | 70 | $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 | + } |
82 | 76 | } |
83 | 77 | } |
84 | 78 | |
— | — | @@ -130,6 +124,33 @@ |
131 | 125 | $end - $start < $arbitrarilyLargeConstant; |
132 | 126 | } |
133 | 127 | |
| 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 | + |
134 | 155 | /** |
135 | 156 | * Hook into Article::view() to provide syntax highlighting for |
136 | 157 | * custom CSS and JavaScript pages |