diff --git a/conf/default.conf.php b/conf/default.conf.php index 897b0f5734..e811b54f76 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -334,6 +334,13 @@ return array( 'differential.revision-custom-detail-renderer' => null, + // Array for custom remarkup rules. The array should have a list of + // class names of classes that extend PhutilRemarkupRule + 'differential.custom-remarkup-rules' => null, + + // Array for custom remarkup block rules. The array should have a list of + // class names of classes that extend PhutilRemarkupEngineBlockRule + 'differential.custom-remarkup-block-rules' => null, // -- Maniphest ------------------------------------------------------------- // diff --git a/src/applications/differential/parser/markup/DifferentialMarkupEngineFactory.php b/src/applications/differential/parser/markup/DifferentialMarkupEngineFactory.php index 00c4e38849..abf48c5c0c 100644 --- a/src/applications/differential/parser/markup/DifferentialMarkupEngineFactory.php +++ b/src/applications/differential/parser/markup/DifferentialMarkupEngineFactory.php @@ -48,6 +48,15 @@ class DifferentialMarkupEngineFactory { $rules[] = new PhutilRemarkupRuleBold(); $rules[] = new PhutilRemarkupRuleItalic(); + $custom_rule_classes = + PhabricatorEnv::getEnvConfig('differential.custom-remarkup-rules'); + if ($custom_rule_classes) { + foreach ($custom_rule_classes as $custom_rule_class) { + PhutilSymbolLoader::loadClass($custom_rule_class); + $rules[] = newv($custom_rule_class, array()); + } + } + $blocks = array(); $blocks[] = new PhutilRemarkupEngineRemarkupQuotesBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupHeaderBlockRule(); @@ -55,6 +64,15 @@ class DifferentialMarkupEngineFactory { $blocks[] = new PhutilRemarkupEngineRemarkupCodeBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule(); + $custom_block_rule_classes = + PhabricatorEnv::getEnvConfig('differential.custom-remarkup-block-rules'); + if ($custom_block_rule_classes) { + foreach ($custom_block_rule_classes as $custom_block_rule_class) { + PhutilSymbolLoader::loadClass($custom_block_rule_class); + $blocks[] = newv($custom_block_rule_class, array()); + } + } + foreach ($blocks as $block) { if (!($block instanceof PhutilRemarkupEngineRemarkupCodeBlockRule)) { $block->setMarkupRules($rules); diff --git a/src/applications/differential/parser/markup/__init__.php b/src/applications/differential/parser/markup/__init__.php index bcd31d17e2..16e58bca7b 100644 --- a/src/applications/differential/parser/markup/__init__.php +++ b/src/applications/differential/parser/markup/__init__.php @@ -26,6 +26,8 @@ phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/escaperemarku phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/hyperlink'); phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/italics'); phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/monospace'); +phutil_require_module('phutil', 'symbols'); +phutil_require_module('phutil', 'utils'); phutil_require_source('DifferentialMarkupEngineFactory.php');