r37495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37494‎ | r37495 | r37496 >
Date:12:45, 10 July 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Add highlight support: highlight=3,6-7
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
@@ -45,7 +45,7 @@
4646 'name' => 'SyntaxHighlight',
4747 'svn-date' => '$LastChangedDate$',
4848 'svn-revision' => '$LastChangedRevision$',
49 - 'author' => array( 'Brion Vibber', 'Tim Starling', 'Rob Church' ),
 49+ 'author' => array( 'Brion Vibber', 'Tim Starling', 'Rob Church', 'Niklas Laxström' ),
5050 'description' => 'Provides syntax highlighting using [http://qbnz.com/highlighter/ GeSHi Highlighter]',
5151 'descriptionmsg' => 'syntaxhighlight-desc',
5252 'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
@@ -45,6 +45,27 @@
4646 $enclose = GESHI_HEADER_DIV;
4747 $geshi->enable_line_numbers( GESHI_FANCY_LINE_NUMBERS );
4848 }
 49+ // Highlightning
 50+ if( isset( $args['highlight'] ) ) {
 51+ $lines = array();
 52+ $values = array_map( 'trim', explode( ',', $args['highlight'] ) );
 53+ foreach ( $values as $value ) {
 54+ if ( ctype_digit($value) ) {
 55+ $lines[] = (int) $value;
 56+ } elseif ( strpos( $value, '-' ) !== false ) {
 57+ list( $start, $end ) = array_map( 'trim', explode( '-', $value ) );
 58+ if ( ctype_digit($start) && ctype_digit($end) && $start < $end ) {
 59+ for ($i = $start; $i <= $end; $i++ ) $lines[] = $i;
 60+ } else {
 61+ wfDebugLog( 'geshi', "Invalid range: $value\n" );
 62+ }
 63+ } else {
 64+ wfDebugLog( 'geshi', "Invalid line: $value\n" );
 65+ }
 66+ }
 67+ if ( count($lines) ) $geshi->highlight_lines_extra( $lines );
 68+ }
 69+
4970 // Starting line number
5071 if( isset( $args['start'] ) )
5172 $geshi->start_line_numbers_at( $args['start'] );

Follow-up revisions

RevisionCommit summaryAuthorDate
r37532Cleanup for r37495 (adds line highlighting support to geshi plugin):...brion20:55, 10 July 2008

Status & tagging log