mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Allow specifying custom syntax highlighter
Summary: Related to D2873. Test Plan: Specified it and verified that highlighting still works. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D2874
This commit is contained in:
parent
6edd29de43
commit
7ca3401d03
4 changed files with 16 additions and 6 deletions
|
@ -1081,12 +1081,16 @@ return array(
|
|||
// of classes which extend PhabricatorEventListener here.
|
||||
'events.listeners' => array(),
|
||||
|
||||
// -- Pygments -------------------------------------------------------------- //
|
||||
// -- Syntax Highlighting --------------------------------------------------- //
|
||||
|
||||
// Phabricator can highlight PHP by default, but if you want syntax
|
||||
// highlighting for other languages you should install the python package
|
||||
// 'Pygments', make sure the 'pygmentize' script is available in the
|
||||
// $PATH of the webserver, and then enable this.
|
||||
// Phabricator can highlight PHP by default and use Pygments for other
|
||||
// languages if enabled. You can provide a custom highlighter engine by
|
||||
// extending class PhutilSyntaxHighlighterEngine.
|
||||
'syntax-highlighter.engine' => 'PhutilDefaultSyntaxHighlighterEngine',
|
||||
|
||||
// If you want syntax highlighting for other languages than PHP then you can
|
||||
// install the python package 'Pygments', make sure the 'pygmentize' script is
|
||||
// available in the $PATH of the webserver, and then enable this.
|
||||
'pygments.enabled' => false,
|
||||
|
||||
// In places that we display a dropdown to syntax-highlight code,
|
||||
|
|
|
@ -90,6 +90,8 @@ class PhabricatorMarkupEngine {
|
|||
'macros' => true,
|
||||
'uri.allowed-protocols' => PhabricatorEnv::getEnvConfig(
|
||||
'uri.allowed-protocols'),
|
||||
'syntax-highlighter.engine' => PhabricatorEnv::getEnvConfig(
|
||||
'syntax-highlighter.engine'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -106,6 +108,9 @@ class PhabricatorMarkupEngine {
|
|||
$options['uri.allowed-protocols']);
|
||||
$engine->setConfig('differential.diff', $options['differential.diff']);
|
||||
$engine->setConfig('header.generate-toc', $options['header.generate-toc']);
|
||||
$engine->setConfig(
|
||||
'syntax-highlighter.engine',
|
||||
$options['syntax-highlighter.engine']);
|
||||
|
||||
$rules = array();
|
||||
$rules[] = new PhutilRemarkupRuleEscapeRemarkup();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
final class PhabricatorSyntaxHighlighter {
|
||||
|
||||
public static function newEngine() {
|
||||
$engine = new PhutilDefaultSyntaxHighlighterEngine();
|
||||
$engine = PhabricatorEnv::newObjectFromConfig('syntax-highlighter.engine');
|
||||
|
||||
$config = array(
|
||||
'pygments.enabled' => PhabricatorEnv::getEnvConfig('pygments.enabled'),
|
||||
|
|
|
@ -316,6 +316,7 @@ final class PhabricatorEnv {
|
|||
'mysql.implementation' => 'AphrontMySQLDatabaseConnectionBase',
|
||||
'differential.attach-task-class' => 'DifferentialTasksAttacher',
|
||||
'mysql.configuration-provider' => 'DatabaseConfigurationProvider',
|
||||
'syntax-highlighter.engine' => 'PhutilSyntaxHighlighterEngine',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue