diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleDiffusion.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleDiffusion.php index 18bf6831aa..0b74d3f35a 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleDiffusion.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleDiffusion.php @@ -4,18 +4,14 @@ * @group markup */ final class PhabricatorRemarkupRuleDiffusion - extends PhutilRemarkupRule { + extends PhabricatorRemarkupRuleObjectName { - public function apply($text) { - return preg_replace_callback( - '@\br([A-Z]+[a-f0-9]+)\b@', - array($this, 'markupDiffusionLink'), - $text); + protected function getObjectNamePrefix() { + return 'r'; } - public function markupDiffusionLink($matches) { - return $this->getEngine()->storeText( - 'r'.$matches[1].''); + protected function getObjectIDPattern() { + return '[A-Z]+[a-f0-9]+'; } } diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectName.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectName.php index 188da30235..5d11ae0131 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectName.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectName.php @@ -8,10 +8,15 @@ abstract class PhabricatorRemarkupRuleObjectName abstract protected function getObjectNamePrefix(); + protected function getObjectIDPattern() { + return '[1-9]\d*'; + } + public function apply($text) { $prefix = $this->getObjectNamePrefix(); + $id = $this->getObjectIDPattern(); return preg_replace_callback( - "@\b({$prefix})([1-9]\d*)(?:#([-\w\d]+))?\b@", + "@\b({$prefix})({$id})(?:#([-\w\d]+))?\b@", array($this, 'markupObjectNameLink'), $text); }