mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-31 18:01:00 +01:00
Use remarkup rule priorities in Phabricator
Summary: Depends on D6329. This fixes `http://www.example.com/D123`, which currently gets the "D123" rendered, after addition of the Asana rule. It also removes a hack for object refernces. Basically, the "hyperlink" rule needs to happen after rules which specialize hyperlinks (Youtube, Asana) but before rules which apply to general text (like the Differential and Maniphest rules). Allow these rules to specify that they have higher or lower priority. Test Plan: Asana rules, Differential rules and Diffusion rules now all markup correctly. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6330
This commit is contained in:
parent
eb49d8a52b
commit
e4eeff8140
3 changed files with 9 additions and 5 deletions
|
@ -15,16 +15,12 @@ final class DiffusionRemarkupRule
|
|||
$min_unqualified = PhabricatorRepository::MINIMUM_UNQUALIFIED_HASH;
|
||||
$min_qualified = PhabricatorRepository::MINIMUM_QUALIFIED_HASH;
|
||||
|
||||
// NOTE: The "(?<!/)" negative lookbehind prevents this rule from matching
|
||||
// hashes or hash-like substrings in most URLs. For example, this will not
|
||||
// match: http://www.example.com/article/28903218328/
|
||||
|
||||
return
|
||||
'r[A-Z]+[1-9]\d*'.
|
||||
'|'.
|
||||
'r[A-Z]+[a-f0-9]{'.$min_qualified.',40}'.
|
||||
'|'.
|
||||
'(?<!/)[a-f0-9]{'.$min_unqualified.',40}';
|
||||
'[a-f0-9]{'.$min_unqualified.',40}';
|
||||
}
|
||||
|
||||
protected function loadObjects(array $ids) {
|
||||
|
|
|
@ -5,6 +5,10 @@ final class DoorkeeperRemarkupRuleAsana
|
|||
|
||||
const KEY_TAGS = 'doorkeeper.tags';
|
||||
|
||||
public function getPriority() {
|
||||
return 350.0;
|
||||
}
|
||||
|
||||
public function apply($text) {
|
||||
return preg_replace_callback(
|
||||
'@https://app\\.asana\\.com/0/(\\d+)/(\\d+)@',
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
final class PhabricatorRemarkupRuleYoutube
|
||||
extends PhutilRemarkupRule {
|
||||
|
||||
public function getPriority() {
|
||||
return 350.0;
|
||||
}
|
||||
|
||||
public function apply($text) {
|
||||
$this->uri = new PhutilURI($text);
|
||||
|
||||
|
|
Loading…
Reference in a new issue