summaryrefslogtreecommitdiff
path: root/extensions/SyntaxHighlight_GeSHi
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-18 06:04:58 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-18 06:04:58 +0100
commit257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (patch)
treef8c25e7fa0c2ba18f27c52415c19cb579a316178 /extensions/SyntaxHighlight_GeSHi
parenta1789ddde42033f1b05cc4929491214ee6e79383 (diff)
Update to MediaWiki 1.26.1
Diffstat (limited to 'extensions/SyntaxHighlight_GeSHi')
-rw-r--r--extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php29
-rw-r--r--extensions/SyntaxHighlight_GeSHi/composer.json2
-rw-r--r--extensions/SyntaxHighlight_GeSHi/maintenance/updateCSS.php22
-rw-r--r--extensions/SyntaxHighlight_GeSHi/maintenance/updateLexerList.php23
4 files changed, 60 insertions, 16 deletions
diff --git a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
index 535e37af..9eed2763 100644
--- a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
+++ b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
@@ -16,7 +16,7 @@
* http://www.gnu.org/copyleft/gpl.html
*/
-use KzykHys\Pygments\Pygments;
+use Symfony\Component\Process\ProcessBuilder;
// @codingStandardsIgnoreStart
class SyntaxHighlight_GeSHi {
@@ -276,18 +276,29 @@ class SyntaxHighlight_GeSHi {
$output = $cache->get( $cacheKey );
if ( $output === false ) {
- try {
- $pygments = new Pygments( $wgPygmentizePath );
- $output = $pygments->highlight( $code, $lexer, 'html', $options );
- } catch ( RuntimeException $e ) {
+ $optionPairs = array();
+ foreach ( $options as $k => $v ) {
+ $optionPairs[] = "{$k}={$v}";
+ }
+ $builder = new ProcessBuilder();
+ $builder->setPrefix( $wgPygmentizePath );
+ $process = $builder
+ ->add( '-l' )->add( $lexer )
+ ->add( '-f' )->add( 'html' )
+ ->add( '-O' )->add( implode( ',', $optionPairs ) )
+ ->getProcess();
+
+ $process->setInput( $code );
+ $process->run();
+
+ if ( !$process->isSuccessful() ) {
$status->warning( 'syntaxhighlight-error-pygments-invocation-failure' );
- wfWarn(
- 'Failed to invoke Pygments. Please check that Pygments is installed ' .
- 'and that $wgPygmentizePath is accurate.'
- );
+ wfWarn( 'Failed to invoke Pygments: ' . $process->getErrorOutput() );
$status->value = self::highlight( $code, null, $args )->getValue();
return $status;
}
+
+ $output = $process->getOutput();
$cache->set( $cacheKey, $output );
}
diff --git a/extensions/SyntaxHighlight_GeSHi/composer.json b/extensions/SyntaxHighlight_GeSHi/composer.json
index 709c1fb0..d8b8cc8e 100644
--- a/extensions/SyntaxHighlight_GeSHi/composer.json
+++ b/extensions/SyntaxHighlight_GeSHi/composer.json
@@ -2,7 +2,7 @@
"name": "mediawiki/syntax-highlight_geshi",
"description": "Syntax highlighting extension for MediaWiki",
"require": {
- "kzykhys/pygments": "1.0"
+ "symfony/process": "~2.5"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.9",
diff --git a/extensions/SyntaxHighlight_GeSHi/maintenance/updateCSS.php b/extensions/SyntaxHighlight_GeSHi/maintenance/updateCSS.php
index a3c0c817..9299cd74 100644
--- a/extensions/SyntaxHighlight_GeSHi/maintenance/updateCSS.php
+++ b/extensions/SyntaxHighlight_GeSHi/maintenance/updateCSS.php
@@ -22,7 +22,7 @@
* @ingroup Maintenance
*/
-use KzykHys\Pygments\Pygments;
+use Symfony\Component\Process\ProcessBuilder;
$IP = getenv( 'MW_INSTALL_PATH' ) ?: __DIR__ . '/../../..';
@@ -39,9 +39,25 @@ class UpdateCSS extends Maintenance {
global $wgPygmentizePath;
$target = __DIR__ . '/../modules/pygments.generated.css';
- $pygments = new Pygments( $wgPygmentizePath );
$css = "/* Stylesheet generated by updateCSS.php */\n";
- $css .= $pygments->getCss( 'default', '.' . SyntaxHighlight_GeSHi::HIGHLIGHT_CSS_CLASS );
+
+ $builder = new ProcessBuilder();
+ $builder->setPrefix( $wgPygmentizePath );
+
+ $process = $builder
+ ->add( '-f' )->add( 'html' )
+ ->add( '-S' )->add( 'default' )
+ ->add( '-a' )->add( '.' . SyntaxHighlight_GeSHi::HIGHLIGHT_CSS_CLASS )
+ ->getProcess();
+
+ $process->run();
+
+ if ( !$process->isSuccessful() ) {
+ throw new \RuntimeException( $process->getErrorOutput() );
+ }
+
+ $css .= $process->getOutput();
+
if ( file_put_contents( $target, $css ) === false ) {
$this->output( "Failed to write to {$target}\n" );
} else {
diff --git a/extensions/SyntaxHighlight_GeSHi/maintenance/updateLexerList.php b/extensions/SyntaxHighlight_GeSHi/maintenance/updateLexerList.php
index 75beb9b5..b5a7fc5a 100644
--- a/extensions/SyntaxHighlight_GeSHi/maintenance/updateLexerList.php
+++ b/extensions/SyntaxHighlight_GeSHi/maintenance/updateLexerList.php
@@ -22,7 +22,7 @@
* @ingroup Maintenance
*/
-use KzykHys\Pygments\Pygments;
+use Symfony\Component\Process\ProcessBuilder;
$IP = getenv( 'MW_INSTALL_PATH' ) ?: __DIR__ . '/../../..';
@@ -43,8 +43,25 @@ class UpdateLanguageList extends Maintenance {
$header = '// Generated by ' . basename( __FILE__ ) . "\n\n";
- $pygments = new Pygments( $wgPygmentizePath );
- $lexers = array_keys( $pygments->getLexers() );
+ $lexers = array();
+
+ $builder = new ProcessBuilder();
+ $builder->setPrefix( $wgPygmentizePath );
+
+ $process = $builder->add( '-L' )->add( 'lexer' )->getProcess();
+ $process->run();
+
+ if ( !$process->isSuccessful() ) {
+ throw new \RuntimeException( $process->getErrorOutput() );
+ }
+
+ $output = $process->getOutput();
+ foreach ( explode( "\n", $output ) as $line ) {
+ if ( substr( $line, 0, 1 ) === '*' ) {
+ $newLexers = explode( ', ', trim( $line, "* :\n" ) );
+ $lexers = array_merge( $lexers, $newLexers );
+ }
+ }
sort( $lexers );
$code = "<?php\n" . $header . 'return ' . var_export( $lexers, true ) . ";\n";