Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F17939198
D7393.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D7393.id.diff
View Options
Index: conf/default.conf.php
===================================================================
--- conf/default.conf.php
+++ conf/default.conf.php
@@ -827,14 +827,6 @@
'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,
-
// List of file regexps where whitespace is meaningful and should not
// use 'ignore-all' by default
'differential.whitespace-matters' => array(
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1592,6 +1592,8 @@
'PhabricatorRemarkupBlockInterpreterFiglet' => 'infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterFiglet.php',
'PhabricatorRemarkupBlockInterpreterGraphviz' => 'infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterGraphviz.php',
'PhabricatorRemarkupControl' => 'view/form/control/PhabricatorRemarkupControl.php',
+ 'PhabricatorRemarkupCustomBlockRule' => 'infrastructure/markup/rule/PhabricatorRemarkupCustomBlockRule.php',
+ 'PhabricatorRemarkupCustomInlineRule' => 'infrastructure/markup/rule/PhabricatorRemarkupCustomInlineRule.php',
'PhabricatorRemarkupRuleEmbedFile' => 'applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php',
'PhabricatorRemarkupRuleImageMacro' => 'applications/macro/remarkup/PhabricatorRemarkupRuleImageMacro.php',
'PhabricatorRemarkupRuleMeme' => 'applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php',
@@ -3886,6 +3888,8 @@
'PhabricatorRemarkupBlockInterpreterFiglet' => 'PhutilRemarkupBlockInterpreter',
'PhabricatorRemarkupBlockInterpreterGraphviz' => 'PhutilRemarkupBlockInterpreter',
'PhabricatorRemarkupControl' => 'AphrontFormTextAreaControl',
+ 'PhabricatorRemarkupCustomBlockRule' => 'PhutilRemarkupEngineBlockRule',
+ 'PhabricatorRemarkupCustomInlineRule' => 'PhutilRemarkupRule',
'PhabricatorRemarkupRuleEmbedFile' => 'PhabricatorRemarkupRuleObject',
'PhabricatorRemarkupRuleImageMacro' => 'PhutilRemarkupRule',
'PhabricatorRemarkupRuleMeme' => 'PhutilRemarkupRule',
Index: src/applications/config/check/PhabricatorSetupCheckExtraConfig.php
===================================================================
--- src/applications/config/check/PhabricatorSetupCheckExtraConfig.php
+++ src/applications/config/check/PhabricatorSetupCheckExtraConfig.php
@@ -141,6 +141,11 @@
$ancient_config = array_fill_keys($auth_config, $reason_auth);
+ $markup_reason = pht(
+ 'Custom remarkup rules are now added by subclassing '.
+ 'PhabricatorRemarkupCustomInlineRule or '.
+ 'PhabricatorRemarkupCustomBlockRule.');
+
$ancient_config += array(
'phid.external-loaders' =>
pht(
@@ -155,6 +160,8 @@
'Maniphest fields are now defined in '.
'`maniphest.custom-field-definitions`. Existing definitions have '.
'been migrated.'),
+ 'differential.custom-remarkup-rules' => $markup_reason,
+ 'differential.custom-remarkup-block-rules' => $markup_reason,
);
return $ancient_config;
Index: src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
===================================================================
--- src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
+++ src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
@@ -20,25 +20,6 @@
->setBaseClass('DifferentialRevisionDetailRenderer')
->setDescription(pht("Custom revision detail renderer.")),
$this->newOption(
- 'differential.custom-remarkup-rules',
- 'list<string>',
- array())
- ->setSummary(pht('Custom remarkup rules.'))
- ->setDescription(
- pht(
- "Array for custom remarkup rules. The array should have a list ".
- "of class names of classes that extend PhutilRemarkupRule")),
- $this->newOption(
- 'differential.custom-remarkup-block-rules',
- 'list<string>',
- array())
- ->setSummary(pht('Custom remarkup block rules.'))
- ->setDescription(
- pht(
- "Array for custom remarkup block rules. The array should have a ".
- "list of class names of classes that extend ".
- "PhutilRemarkupEngineBlockRule")),
- $this->newOption(
'differential.whitespace-matters',
'list<regex>',
array(
Index: src/infrastructure/markup/PhabricatorMarkupEngine.php
===================================================================
--- src/infrastructure/markup/PhabricatorMarkupEngine.php
+++ src/infrastructure/markup/PhabricatorMarkupEngine.php
@@ -201,7 +201,16 @@
private function getMarkupFieldKey(
PhabricatorMarkupInterface $object,
$field) {
- return $object->getMarkupFieldKey($field).'@'.$this->version;
+
+ $custom = array_merge(
+ self::loadCustomInlineRules(),
+ self::loadCustomBlockRules());
+
+ $custom = mpull($custom, 'getRuleVersion', null);
+ ksort($custom);
+ $custom = PhabricatorHash::digestForIndex(serialize($custom));
+
+ return $object->getMarkupFieldKey($field).'@'.$this->version.'@'.$custom;
}
@@ -328,10 +337,6 @@
*/
public static function newDifferentialMarkupEngine(array $options = array()) {
return self::newMarkupEngine(array(
- 'custom-inline' => PhabricatorEnv::getEnvConfig(
- 'differential.custom-remarkup-rules'),
- 'custom-block' => PhabricatorEnv::getEnvConfig(
- 'differential.custom-remarkup-block-rules'),
'differential.diff' => idx($options, 'differential.diff'),
));
}
@@ -381,8 +386,6 @@
'pygments' => PhabricatorEnv::getEnvConfig('pygments.enabled'),
'youtube' => PhabricatorEnv::getEnvConfig(
'remarkup.enable-embedded-youtube'),
- 'custom-inline' => array(),
- 'custom-block' => array(),
'differential.diff' => null,
'header.generate-toc' => false,
'macros' => true,
@@ -419,12 +422,6 @@
$rules[] = new PhutilRemarkupRuleEscapeRemarkup();
$rules[] = new PhutilRemarkupRuleMonospace();
- $custom_rule_classes = $options['custom-inline'];
- if ($custom_rule_classes) {
- foreach ($custom_rule_classes as $custom_rule_class) {
- $rules[] = newv($custom_rule_class, array());
- }
- }
$rules[] = new PhutilRemarkupRuleDocumentLink();
@@ -450,6 +447,10 @@
$rules[] = new PhutilRemarkupRuleItalic();
$rules[] = new PhutilRemarkupRuleDel();
+ foreach (self::loadCustomInlineRules() as $rule) {
+ $rules[] = $rule;
+ }
+
$blocks = array();
$blocks[] = new PhutilRemarkupEngineRemarkupQuotesBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupLiteralBlockRule();
@@ -461,16 +462,12 @@
$blocks[] = new PhutilRemarkupEngineRemarkupTableBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupSimpleTableBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupInterpreterRule();
+ $blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule();
- $custom_block_rule_classes = $options['custom-block'];
- if ($custom_block_rule_classes) {
- foreach ($custom_block_rule_classes as $custom_block_rule_class) {
- $blocks[] = newv($custom_block_rule_class, array());
- }
+ foreach (self::loadCustomBlockRules() as $rule) {
+ $blocks[] = $rule;
}
- $blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule();
-
foreach ($blocks as $block) {
$block->setMarkupRules($rules);
}
@@ -564,4 +561,16 @@
return $best;
}
+ private static function loadCustomInlineRules() {
+ return id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorRemarkupCustomInlineRule')
+ ->loadObjects();
+ }
+
+ private static function loadCustomBlockRules() {
+ return id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorRemarkupCustomBlockRule')
+ ->loadObjects();
+ }
+
}
Index: src/infrastructure/markup/rule/PhabricatorRemarkupCustomBlockRule.php
===================================================================
--- /dev/null
+++ src/infrastructure/markup/rule/PhabricatorRemarkupCustomBlockRule.php
@@ -0,0 +1,10 @@
+<?php
+
+abstract class PhabricatorRemarkupCustomBlockRule
+ extends PhutilRemarkupEngineBlockRule {
+
+ public function getRuleVersion() {
+ return 1;
+ }
+
+}
Index: src/infrastructure/markup/rule/PhabricatorRemarkupCustomInlineRule.php
===================================================================
--- /dev/null
+++ src/infrastructure/markup/rule/PhabricatorRemarkupCustomInlineRule.php
@@ -0,0 +1,10 @@
+<?php
+
+abstract class PhabricatorRemarkupCustomInlineRule
+ extends PhutilRemarkupRule {
+
+ public function getRuleVersion() {
+ return 1;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 1 2025, 2:55 AM (6 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8610469
Default Alt Text
D7393.id.diff (9 KB)
Attached To
Mode
D7393: Make remarkup rules runtime-pluggable in a reasonable way
Attached
Detach File
Event Timeline
Log In to Comment