r23658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23657‎ | r23658 | r23659 >
Date:23:24, 2 July 2007
Author:simetrical
Status:old
Tags:
Comment:
Revert r23618 per Brion. Now, to get phase3 and extensions in the same repo locally so I can commit to both at once . . .
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
@@ -49,6 +49,7 @@
5050 );
5151
5252 $wgAutoloadClasses['SyntaxHighlight_GeSHi'] = dirname( __FILE__ ) . '/SyntaxHighlight_GeSHi.class.php';
 53+$wgHooks['ShowRawCssJs'][] = 'SyntaxHighlight_GeSHi::viewHook';
5354 $wgExtensionFunctions[] = 'efSyntaxHighlight_GeSHiSetup';
5455
5556 /**
@@ -57,4 +58,4 @@
5859 function efSyntaxHighlight_GeSHiSetup() {
5960 global $wgParser;
6061 $wgParser->setHook( 'source', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) );
61 -}
 62+}
\ No newline at end of file
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
@@ -69,6 +69,34 @@
7070 }
7171
7272 /**
 73+ * Hook into Article::view() to provide syntax highlighting for
 74+ * custom CSS and JavaScript pages
 75+ *
 76+ * @param string $text
 77+ * @param Title $title
 78+ * @param OutputPage $output
 79+ * @return bool
 80+ */
 81+ public static function viewHook( $text, $title, $output ) {
 82+ // Determine the language
 83+ preg_match( '!\.(css|js)$!u', $title->getText(), $matches );
 84+ $lang = $matches[1] == 'css' ? 'css' : 'javascript';
 85+ // Attempt to format
 86+ $geshi = self::prepare( $text, $lang );
 87+ if( $geshi instanceof GeSHi ) {
 88+ $out = $geshi->parse_code();
 89+ if( !$geshi->error() ) {
 90+ // Done
 91+ $output->addHeadItem( "source-$lang", self::buildHeadItem( $geshi ) );
 92+ $output->addHtml( "<div dir=\"ltr\">{$out}</div>" );
 93+ return false;
 94+ }
 95+ }
 96+ // Bottle out
 97+ return true;
 98+ }
 99+
 100+ /**
73101 * Initialise a GeSHi object to format some code, performing
74102 * common setup for all our uses of it
75103 *
@@ -177,4 +205,4 @@
178206 }
179207 }
180208
181 -}
 209+}
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r23618Remove function that hooks into ShowRawCssJs, which no longer exists (<source...simetrical19:58, 1 July 2007

Status & tagging log