mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-15 02:24:07 +00:00
* Add highlight support: highlight=3,6-7
This commit is contained in:
parent
2f0b3c78b7
commit
9bb924174a
|
@ -45,6 +45,27 @@ class SyntaxHighlight_GeSHi {
|
||||||
$enclose = GESHI_HEADER_DIV;
|
$enclose = GESHI_HEADER_DIV;
|
||||||
$geshi->enable_line_numbers( GESHI_FANCY_LINE_NUMBERS );
|
$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
|
// Starting line number
|
||||||
if( isset( $args['start'] ) )
|
if( isset( $args['start'] ) )
|
||||||
$geshi->start_line_numbers_at( $args['start'] );
|
$geshi->start_line_numbers_at( $args['start'] );
|
||||||
|
|
|
@ -45,7 +45,7 @@ $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array(
|
||||||
'name' => 'SyntaxHighlight',
|
'name' => 'SyntaxHighlight',
|
||||||
'svn-date' => '$LastChangedDate$',
|
'svn-date' => '$LastChangedDate$',
|
||||||
'svn-revision' => '$LastChangedRevision$',
|
'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]',
|
'description' => 'Provides syntax highlighting using [http://qbnz.com/highlighter/ GeSHi Highlighter]',
|
||||||
'descriptionmsg' => 'syntaxhighlight-desc',
|
'descriptionmsg' => 'syntaxhighlight-desc',
|
||||||
'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
|
'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
|
||||||
|
|
Loading…
Reference in a new issue