Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php |
— | — | @@ -35,20 +35,20 @@ |
36 | 36 | if ( !is_null( $wgSyntaxHighlightDefaultLang ) ) { |
37 | 37 | $lang = $wgSyntaxHighlightDefaultLang; |
38 | 38 | } else { |
39 | | - $error = self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) ); |
| 39 | + $error = self::formatLanguageError( $text ); |
40 | 40 | wfProfileOut( __METHOD__ ); |
41 | 41 | return $error; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | $lang = strtolower( $lang ); |
45 | 45 | if( !preg_match( '/^[a-z_0-9-]*$/', $lang ) ) { |
46 | | - $error = self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) ); |
| 46 | + $error = self::formatLanguageError( $text ); |
47 | 47 | wfProfileOut( __METHOD__ ); |
48 | 48 | return $error; |
49 | 49 | } |
50 | 50 | $geshi = self::prepare( $text, $lang ); |
51 | 51 | if( !$geshi instanceof GeSHi ) { |
52 | | - $error = self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) ); |
| 52 | + $error = self::formatLanguageError( $text ); |
53 | 53 | wfProfileOut( __METHOD__ ); |
54 | 54 | return $error; |
55 | 55 | } |
— | — | @@ -77,9 +77,15 @@ |
78 | 78 | } |
79 | 79 | // Format |
80 | 80 | $out = $geshi->parse_code(); |
| 81 | + if ( $geshi->error == GESHI_ERROR_NO_SUCH_LANG ) { |
| 82 | + // Common error :D |
| 83 | + $error = self::formatLanguageError( $text ); |
| 84 | + wfProfileOut( __METHOD__ ); |
| 85 | + return $error; |
| 86 | + } |
81 | 87 | $err = $geshi->error(); |
82 | 88 | if( $err ) { |
83 | | - // Error! |
| 89 | + // Other unknown error! |
84 | 90 | $error = self::formatError( $err ); |
85 | 91 | wfProfileOut( __METHOD__ ); |
86 | 92 | return $error; |
— | — | @@ -278,6 +284,18 @@ |
279 | 285 | } |
280 | 286 | |
281 | 287 | /** |
| 288 | + * Format an 'unknown language' error message and append formatted |
| 289 | + * plain text to it. |
| 290 | + * |
| 291 | + * @param string $text |
| 292 | + * @return string HTML fragment |
| 293 | + */ |
| 294 | + private static function formatLanguageError( $text ) { |
| 295 | + $error = self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ), $text ); |
| 296 | + return $error . '<pre>' . htmlspecialchars( $text ) . '</pre>'; |
| 297 | + } |
| 298 | + |
| 299 | + /** |
282 | 300 | * Format an error message |
283 | 301 | * |
284 | 302 | * @param string $error |