* Add highlight support: highlight=3,6-7

This commit is contained in:
Niklas Laxström 2008-07-10 12:45:20 +00:00
parent 2f0b3c78b7
commit 9bb924174a
2 changed files with 22 additions and 1 deletions

View file

@ -45,6 +45,27 @@ class SyntaxHighlight_GeSHi {
$enclose = GESHI_HEADER_DIV;
$geshi->enable_line_numbers( GESHI_FANCY_LINE_NUMBERS );
}
// Highlightning
if( isset( $args['highlight'] ) ) {
$lines = array();
$values = array_map( 'trim', explode( ',', $args['highlight'] ) );
foreach ( $values as $value ) {
if ( ctype_digit($value) ) {
$lines[] = (int) $value;
} elseif ( strpos( $value, '-' ) !== false ) {
list( $start, $end ) = array_map( 'trim', explode( '-', $value ) );
if ( ctype_digit($start) && ctype_digit($end) && $start < $end ) {
for ($i = $start; $i <= $end; $i++ ) $lines[] = $i;
} else {
wfDebugLog( 'geshi', "Invalid range: $value\n" );
}
} else {
wfDebugLog( 'geshi', "Invalid line: $value\n" );
}
}
if ( count($lines) ) $geshi->highlight_lines_extra( $lines );
}
// Starting line number
if( isset( $args['start'] ) )
$geshi->start_line_numbers_at( $args['start'] );

View file

@ -45,7 +45,7 @@ $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array(
'name' => 'SyntaxHighlight',
'svn-date' => '$LastChangedDate$',
'svn-revision' => '$LastChangedRevision$',
'author' => array( 'Brion Vibber', 'Tim Starling', 'Rob Church' ),
'author' => array( 'Brion Vibber', 'Tim Starling', 'Rob Church', 'Niklas Laxström' ),
'description' => 'Provides syntax highlighting using [http://qbnz.com/highlighter/ GeSHi Highlighter]',
'descriptionmsg' => 'syntaxhighlight-desc',
'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',