mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +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:
parent
90e75d4e50
commit
8efae19655
4 changed files with 24 additions and 4 deletions
|
@ -5,7 +5,7 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
|
||||||
const KEY_RULE_ATOM_REF = 'rule.diviner.atomref';
|
const KEY_RULE_ATOM_REF = 'rule.diviner.atomref';
|
||||||
|
|
||||||
public function getPriority() {
|
public function getPriority() {
|
||||||
return 40.0;
|
return 200.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apply($text) {
|
public function apply($text) {
|
||||||
|
@ -34,6 +34,10 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markupSymbol($matches) {
|
public function markupSymbol($matches) {
|
||||||
|
if ($this->isTextFlat($matches[0])) {
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
$type = (string)idx($matches, 'type');
|
$type = (string)idx($matches, 'type');
|
||||||
$name = (string)$matches['name'];
|
$name = (string)$matches['name'];
|
||||||
$title = (string)idx($matches, 'title');
|
$title = (string)idx($matches, 'title');
|
||||||
|
|
|
@ -4,7 +4,7 @@ final class PhabricatorRemarkupRuleIcon
|
||||||
extends PhutilRemarkupRule {
|
extends PhutilRemarkupRule {
|
||||||
|
|
||||||
public function getPriority() {
|
public function getPriority() {
|
||||||
return 50.0;
|
return 200.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apply($text) {
|
public function apply($text) {
|
||||||
|
@ -15,6 +15,10 @@ final class PhabricatorRemarkupRuleIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markupIcon($matches) {
|
public function markupIcon($matches) {
|
||||||
|
if (!$this->isFlatText($matches[0])) {
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
$extra = idx($matches, 1);
|
$extra = idx($matches, 1);
|
||||||
|
|
||||||
// We allow various forms, like these:
|
// We allow various forms, like these:
|
||||||
|
|
|
@ -9,7 +9,7 @@ final class PhabricatorRemarkupRuleMeme
|
||||||
private $images;
|
private $images;
|
||||||
|
|
||||||
public function getPriority() {
|
public function getPriority() {
|
||||||
return 50.0;
|
return 200.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apply($text) {
|
public function apply($text) {
|
||||||
|
@ -20,6 +20,10 @@ final class PhabricatorRemarkupRuleMeme
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markupMeme($matches) {
|
public function markupMeme($matches) {
|
||||||
|
if (!$this->isFlatText($matches[0])) {
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
'src' => null,
|
'src' => null,
|
||||||
'above' => null,
|
'above' => null,
|
||||||
|
|
|
@ -13,7 +13,7 @@ abstract class PhabricatorRemarkupRuleObject
|
||||||
abstract protected function loadObjects(array $ids);
|
abstract protected function loadObjects(array $ids);
|
||||||
|
|
||||||
public function getPriority() {
|
public function getPriority() {
|
||||||
return 50.0;
|
return 200.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getObjectNamePrefixBeginsWithWordCharacter() {
|
protected function getObjectNamePrefixBeginsWithWordCharacter() {
|
||||||
|
@ -133,6 +133,10 @@ abstract class PhabricatorRemarkupRuleObject
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markupObjectEmbed($matches) {
|
public function markupObjectEmbed($matches) {
|
||||||
|
if (!$this->isFlatText($matches[0])) {
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
return $this->markupObject(array(
|
return $this->markupObject(array(
|
||||||
'type' => 'embed',
|
'type' => 'embed',
|
||||||
'id' => $matches[1],
|
'id' => $matches[1],
|
||||||
|
@ -142,6 +146,10 @@ abstract class PhabricatorRemarkupRuleObject
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markupObjectReference($matches) {
|
public function markupObjectReference($matches) {
|
||||||
|
if (!$this->isFlatText($matches[0])) {
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
return $this->markupObject(array(
|
return $this->markupObject(array(
|
||||||
'type' => 'ref',
|
'type' => 'ref',
|
||||||
'id' => $matches[1],
|
'id' => $matches[1],
|
||||||
|
|
Loading…
Reference in a new issue