diff --git a/src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php b/src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php index 55df97db5f..765225b4cb 100644 --- a/src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php +++ b/src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php @@ -19,9 +19,19 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule { if (!$countdown) { return $matches[0]; } - $id = celerity_generate_unique_node_id(); $engine = $this->getEngine(); + + if ($engine->isTextMode()) { + $date = $countdown->getDatepoint(); + $viewer = $engine->getConfig('viewer'); + if ($viewer) { + $date = phabricator_datetime($date, $viewer); + } + return $engine->storeText($date); + } + + $id = celerity_generate_unique_node_id(); $token = $engine->storeText(''); $metadata_key = self::KEY_RULE_COUNTDOWN; diff --git a/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php b/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php index 48a2438c1b..81e3a70cc3 100644 --- a/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php +++ b/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php @@ -100,14 +100,20 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule { $href = $renderer->getHrefForAtomRef($ref); } } else { - // Here, we're generating commment text or something like that. Just + // Here, we're generating comment text or something like that. Just // link to Diviner and let it sort things out. $href = id(new PhutilURI('/diviner/find/')) ->setQueryParams($ref_dict + array('jump' => true)); } - if ($href) { + if ($this->getEngine()->isTextMode()) { + if ($href) { + $link = $title.' <'.PhabricatorEnv::getProductionURI($href).'>'; + } else { + $link = $title; + } + } else if ($href) { $link = phutil_tag( 'a', array( diff --git a/src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php b/src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php index 9ef0ac8ad9..89c901572d 100644 --- a/src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php +++ b/src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php @@ -27,9 +27,15 @@ final class PhabricatorRemarkupRuleEmbedFile if (!$file) { return $matches[0]; } - $phid = $file->getPHID(); $engine = $this->getEngine(); + + if ($engine->isTextMode()) { + return $engine->storeText($file->getBestURI()); + } + + $phid = $file->getPHID(); + $token = $engine->storeText(''); $metadata_key = self::KEY_RULE_EMBED_FILE; $metadata = $engine->getTextMetadata($metadata_key, array()); diff --git a/src/applications/macro/remarkup/PhabricatorRemarkupRuleImageMacro.php b/src/applications/macro/remarkup/PhabricatorRemarkupRuleImageMacro.php index 48eefd12f7..2de07bbeaa 100644 --- a/src/applications/macro/remarkup/PhabricatorRemarkupRuleImageMacro.php +++ b/src/applications/macro/remarkup/PhabricatorRemarkupRuleImageMacro.php @@ -35,6 +35,14 @@ final class PhabricatorRemarkupRuleImageMacro $phid = $this->images[$name]; $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $phid); + + if ($this->getEngine()->isTextMode()) { + if ($file) { + $name .= ' <'.$file->getBestURI().'>'; + } + return $this->getEngine()->storeText($name); + } + $style = null; $src_uri = null; if ($file) { diff --git a/src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php b/src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php index 665fbf7a95..637d25ffa7 100644 --- a/src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php +++ b/src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php @@ -30,11 +30,18 @@ final class PhabricatorRemarkupRuleMeme ->alter('uppertext', $options['above']) ->alter('lowertext', $options['below']); - $img = phutil_tag( - 'img', - array( - 'src' => (string)$uri, - )); + if ($this->getEngine()->isTextMode()) { + $img = + ($options['above'] != '' ? "\"{$options['above']}\"\n" : ''). + $options['src'].' <'.PhabricatorEnv::getProductionURI($uri).'>'. + ($options['below'] != '' ? "\n\"{$options['below']}\"" : ''); + } else { + $img = phutil_tag( + 'img', + array( + 'src' => (string)$uri, + )); + } return $this->getEngine()->storeText($img); } diff --git a/src/applications/people/remarkup/PhabricatorRemarkupRuleMention.php b/src/applications/people/remarkup/PhabricatorRemarkupRuleMention.php index 7f05ff95a1..c4f8dc1729 100644 --- a/src/applications/people/remarkup/PhabricatorRemarkupRuleMention.php +++ b/src/applications/people/remarkup/PhabricatorRemarkupRuleMention.php @@ -29,6 +29,11 @@ final class PhabricatorRemarkupRuleMention protected function markupMention($matches) { $engine = $this->getEngine(); + + if ($engine->isTextMode()) { + return $engine->storeText($matches[0]); + } + $token = $engine->storeText(''); // Store the original text exactly so we can preserve casing if it doesn't diff --git a/src/applications/phriction/remarkup/PhrictionRemarkupRule.php b/src/applications/phriction/remarkup/PhrictionRemarkupRule.php index de2e71029f..97ceec3f6f 100644 --- a/src/applications/phriction/remarkup/PhrictionRemarkupRule.php +++ b/src/applications/phriction/remarkup/PhrictionRemarkupRule.php @@ -29,14 +29,16 @@ final class PhrictionRemarkupRule if ($this->getEngine()->getState('toc')) { $text = $name; + } else if ($this->getEngine()->isTextMode()) { + return PhabricatorEnv::getProductionURI($href); } else { $text = phutil_tag( - 'a', - array( - 'href' => $href, - 'class' => 'phriction-link', - ), - $name); + 'a', + array( + 'href' => $href, + 'class' => 'phriction-link', + ), + $name); } return $this->getEngine()->storeText($text); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php index f8559235f5..2c6694a827 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObject.php @@ -50,6 +50,10 @@ abstract class PhabricatorRemarkupRuleObject } } + if ($this->getEngine()->isTextMode()) { + return PhabricatorEnv::getProductionURI($href); + } + $status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED; $attr = array( @@ -63,6 +67,11 @@ abstract class PhabricatorRemarkupRuleObject protected function renderObjectEmbed($object, $handle, $options) { $name = $handle->getFullName(); $href = $handle->getURI(); + + if ($this->getEngine()->isTextMode()) { + return $name.' <'.PhabricatorEnv::getProductionURI($href).'>'; + } + $attr = array( 'phid' => $handle->getPHID(), ); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleYoutube.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleYoutube.php index 3b099ef3be..5f13b4f09b 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleYoutube.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleYoutube.php @@ -20,6 +20,11 @@ final class PhabricatorRemarkupRuleYoutube public function markupYoutubeLink() { $v = idx($this->uri->getQueryParams(), 'v'); + + if ($this->getEngine()->isTextMode()) { + return $this->getEngine()->storeText('http://youtu.be/'.$v); + } + $youtube_src = 'https://www.youtube.com/embed/'.$v; $iframe = hsprintf( '
%s
',