1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00

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
This commit is contained in:
epriestley 2014-07-01 11:19:59 -07:00
parent 90e75d4e50
commit 8efae19655
4 changed files with 24 additions and 4 deletions

View file

@ -5,7 +5,7 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
const KEY_RULE_ATOM_REF = 'rule.diviner.atomref';
public function getPriority() {
return 40.0;
return 200.0;
}
public function apply($text) {
@ -34,6 +34,10 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
}
public function markupSymbol($matches) {
if ($this->isTextFlat($matches[0])) {
return $matches[0];
}
$type = (string)idx($matches, 'type');
$name = (string)$matches['name'];
$title = (string)idx($matches, 'title');

View file

@ -4,7 +4,7 @@ final class PhabricatorRemarkupRuleIcon
extends PhutilRemarkupRule {
public function getPriority() {
return 50.0;
return 200.0;
}
public function apply($text) {
@ -15,6 +15,10 @@ final class PhabricatorRemarkupRuleIcon
}
public function markupIcon($matches) {
if (!$this->isFlatText($matches[0])) {
return $matches[0];
}
$extra = idx($matches, 1);
// We allow various forms, like these:

View file

@ -9,7 +9,7 @@ final class PhabricatorRemarkupRuleMeme
private $images;
public function getPriority() {
return 50.0;
return 200.0;
}
public function apply($text) {
@ -20,6 +20,10 @@ final class PhabricatorRemarkupRuleMeme
}
public function markupMeme($matches) {
if (!$this->isFlatText($matches[0])) {
return $matches[0];
}
$options = array(
'src' => null,
'above' => null,

View file

@ -13,7 +13,7 @@ abstract class PhabricatorRemarkupRuleObject
abstract protected function loadObjects(array $ids);
public function getPriority() {
return 50.0;
return 200.0;
}
protected function getObjectNamePrefixBeginsWithWordCharacter() {
@ -133,6 +133,10 @@ abstract class PhabricatorRemarkupRuleObject
}
public function markupObjectEmbed($matches) {
if (!$this->isFlatText($matches[0])) {
return $matches[0];
}
return $this->markupObject(array(
'type' => 'embed',
'id' => $matches[1],
@ -142,6 +146,10 @@ abstract class PhabricatorRemarkupRuleObject
}
public function markupObjectReference($matches) {
if (!$this->isFlatText($matches[0])) {
return $matches[0];
}
return $this->markupObject(array(
'type' => 'ref',
'id' => $matches[1],