summaryrefslogtreecommitdiff
path: root/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
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/SyntaxHighlight_GeSHi.class.php
parenta1789ddde42033f1b05cc4929491214ee6e79383 (diff)
Update to MediaWiki 1.26.1
Diffstat (limited to 'extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php')
-rw-r--r--extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php29
1 files changed, 20 insertions, 9 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 );
}