mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-15 10:39:53 +00:00
Merge "Make sure $wgPygmentizePath is sane only when we need it"
This commit is contained in:
commit
73618fa360
|
@ -41,15 +41,6 @@ class SyntaxHighlight {
|
|||
'text/xml' => 'xml',
|
||||
];
|
||||
|
||||
public static function onSetup() {
|
||||
global $wgPygmentizePath;
|
||||
|
||||
// If $wgPygmentizePath is unset, use the bundled copy.
|
||||
if ( $wgPygmentizePath === false ) {
|
||||
$wgPygmentizePath = __DIR__ . '/pygments/pygmentize';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Pygments lexer name for a particular language.
|
||||
*
|
||||
|
@ -187,6 +178,20 @@ class SyntaxHighlight {
|
|||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getPygmentizePath() {
|
||||
global $wgPygmentizePath;
|
||||
|
||||
// If $wgPygmentizePath is unset, use the bundled copy.
|
||||
if ( $wgPygmentizePath === false ) {
|
||||
$wgPygmentizePath = __DIR__ . '/pygments/pygmentize';
|
||||
}
|
||||
|
||||
return $wgPygmentizePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight a code-block using a particular lexer.
|
||||
*
|
||||
|
@ -203,8 +208,6 @@ class SyntaxHighlight {
|
|||
* code as its value.
|
||||
*/
|
||||
public static function highlight( $code, $lang = null, $args = [] ) {
|
||||
global $wgPygmentizePath;
|
||||
|
||||
$status = new Status;
|
||||
|
||||
$lexer = self::getLexer( $lang );
|
||||
|
@ -287,7 +290,7 @@ class SyntaxHighlight {
|
|||
$optionPairs[] = "{$k}={$v}";
|
||||
}
|
||||
$builder = new ProcessBuilder();
|
||||
$builder->setPrefix( $wgPygmentizePath );
|
||||
$builder->setPrefix( self::getPygmentizePath() );
|
||||
$process = $builder
|
||||
->add( '-l' )->add( $lexer )
|
||||
->add( '-f' )->add( 'html' )
|
||||
|
|
|
@ -30,9 +30,6 @@
|
|||
"ResourceLoaderGeSHiVisualEditorModule": "ResourceLoaderSyntaxHighlightVisualEditorModule.php",
|
||||
"ResourceLoaderSyntaxHighlightVisualEditorModule": "ResourceLoaderSyntaxHighlightVisualEditorModule.php"
|
||||
},
|
||||
"ExtensionFunctions": [
|
||||
"SyntaxHighlight::onSetup"
|
||||
],
|
||||
"ResourceFileModulePaths": {
|
||||
"localBasePath": "modules",
|
||||
"remoteExtPath": "SyntaxHighlight_GeSHi/modules"
|
||||
|
|
|
@ -36,13 +36,11 @@ class UpdateCSS extends Maintenance {
|
|||
}
|
||||
|
||||
public function execute() {
|
||||
global $wgPygmentizePath;
|
||||
|
||||
$target = __DIR__ . '/../modules/pygments.generated.css';
|
||||
$css = "/* Stylesheet generated by updateCSS.php */\n";
|
||||
|
||||
$builder = new ProcessBuilder();
|
||||
$builder->setPrefix( $wgPygmentizePath );
|
||||
$builder->setPrefix( SyntaxHighlight_GeSHi::getPygmentizePath() );
|
||||
|
||||
$process = $builder
|
||||
->add( '-f' )->add( 'html' )
|
||||
|
|
|
@ -35,8 +35,6 @@ class UpdateLanguageList extends Maintenance {
|
|||
}
|
||||
|
||||
public function execute() {
|
||||
global $wgPygmentizePath;
|
||||
|
||||
function lang_filter( $val ) {
|
||||
return preg_match( '/^[a-zA-Z0-9\-_]+$/', $val );
|
||||
}
|
||||
|
@ -46,7 +44,7 @@ class UpdateLanguageList extends Maintenance {
|
|||
$lexers = [];
|
||||
|
||||
$builder = new ProcessBuilder();
|
||||
$builder->setPrefix( $wgPygmentizePath );
|
||||
$builder->setPrefix( SyntaxHighlight_GeSHi::getPygmentizePath() );
|
||||
|
||||
$process = $builder->add( '-L' )->add( 'lexer' )->getProcess();
|
||||
$process->run();
|
||||
|
|
Loading…
Reference in a new issue