From 0e06cd85b783ba1fe0ef21fe8d479f148862f8a6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 30 Apr 2011 14:00:14 -0700 Subject: [PATCH] Pygments support for Phabricator Summary: Thread a config option through, see D197. Test Plan: Source code gets highlighted. Reviewed By: aran Reviewers: aran, tomo, jungejason, tuomaspelkonen CC: aran Differential Revision: 198 --- conf/default.conf.php | 7 +++++++ .../parser/markup/DifferentialMarkupEngineFactory.php | 3 +++ src/applications/differential/parser/markup/__init__.php | 1 + 3 files changed, 11 insertions(+) diff --git a/conf/default.conf.php b/conf/default.conf.php index 0548384a65..f5d14d3408 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -265,6 +265,13 @@ return array( 'phabricator.timezone' => null, + // 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. + 'pygments.enabled' => false, + + // -- Files ----------------------------------------------------------------- // // Lists which uploaded file types may be viewed in the browser. If a file diff --git a/src/applications/differential/parser/markup/DifferentialMarkupEngineFactory.php b/src/applications/differential/parser/markup/DifferentialMarkupEngineFactory.php index 15ed808532..a3f909298a 100644 --- a/src/applications/differential/parser/markup/DifferentialMarkupEngineFactory.php +++ b/src/applications/differential/parser/markup/DifferentialMarkupEngineFactory.php @@ -22,6 +22,9 @@ class DifferentialMarkupEngineFactory { $engine = new PhutilRemarkupEngine(); $engine->setConfig('preserve-linebreaks', true); + $engine->setConfig( + 'pygments.enabled', + PhabricatorEnv::getEnvConfig('pygments.enabled')); $rules = array(); $rules[] = new PhutilRemarkupRuleEscapeRemarkup(); diff --git a/src/applications/differential/parser/markup/__init__.php b/src/applications/differential/parser/markup/__init__.php index 3bd80e23da..87d1030636 100644 --- a/src/applications/differential/parser/markup/__init__.php +++ b/src/applications/differential/parser/markup/__init__.php @@ -6,6 +6,7 @@ +phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/differential'); phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/diffusion'); phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/imagemacro');