Skip to content

Commit 8efae19

Browse files
author
epriestley
committedJul 1, 2014
Adjust remarkup rule precedence for embeds
Summary: The monospaced rule should still have higher precedence than these rules, so use flat text tests to cover some rule interactions. Auditors: btrahan
1 parent 90e75d4 commit 8efae19

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed
 

‎src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
55
const KEY_RULE_ATOM_REF = 'rule.diviner.atomref';
66

77
public function getPriority() {
8-
return 40.0;
8+
return 200.0;
99
}
1010

1111
public function apply($text) {
@@ -34,6 +34,10 @@ public function apply($text) {
3434
}
3535

3636
public function markupSymbol($matches) {
37+
if ($this->isTextFlat($matches[0])) {
38+
return $matches[0];
39+
}
40+
3741
$type = (string)idx($matches, 'type');
3842
$name = (string)$matches['name'];
3943
$title = (string)idx($matches, 'title');

‎src/applications/macro/remarkup/PhabricatorRemarkupRuleIcon.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ final class PhabricatorRemarkupRuleIcon
44
extends PhutilRemarkupRule {
55

66
public function getPriority() {
7-
return 50.0;
7+
return 200.0;
88
}
99

1010
public function apply($text) {
@@ -15,6 +15,10 @@ public function apply($text) {
1515
}
1616

1717
public function markupIcon($matches) {
18+
if (!$this->isFlatText($matches[0])) {
19+
return $matches[0];
20+
}
21+
1822
$extra = idx($matches, 1);
1923

2024
// We allow various forms, like these:

‎src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ final class PhabricatorRemarkupRuleMeme
99
private $images;
1010

1111
public function getPriority() {
12-
return 50.0;
12+
return 200.0;
1313
}
1414

1515
public function apply($text) {
@@ -20,6 +20,10 @@ public function apply($text) {
2020
}
2121

2222
public function markupMeme($matches) {
23+
if (!$this->isFlatText($matches[0])) {
24+
return $matches[0];
25+
}
26+
2327
$options = array(
2428
'src' => null,
2529
'above' => null,

‎src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ abstract protected function getObjectNamePrefix();
1313
abstract protected function loadObjects(array $ids);
1414

1515
public function getPriority() {
16-
return 50.0;
16+
return 200.0;
1717
}
1818

1919
protected function getObjectNamePrefixBeginsWithWordCharacter() {
@@ -133,6 +133,10 @@ public function apply($text) {
133133
}
134134

135135
public function markupObjectEmbed($matches) {
136+
if (!$this->isFlatText($matches[0])) {
137+
return $matches[0];
138+
}
139+
136140
return $this->markupObject(array(
137141
'type' => 'embed',
138142
'id' => $matches[1],
@@ -142,6 +146,10 @@ public function markupObjectEmbed($matches) {
142146
}
143147

144148
public function markupObjectReference($matches) {
149+
if (!$this->isFlatText($matches[0])) {
150+
return $matches[0];
151+
}
152+
145153
return $this->markupObject(array(
146154
'type' => 'ref',
147155
'id' => $matches[1],

0 commit comments

Comments
 (0)
Failed to load comments.