3 final class PhabricatorMemeRemarkupRule
extends PhutilRemarkupRule
{
7 public function getPriority() {
11 public function apply($text) {
12 return preg_replace_callback(
13 '@{meme,((?:[^}\\\\]+|\\\\.)+)}@m',
14 array($this, 'markupMeme'),
18 public function markupMeme(array $matches) {
19 if (!$this->isFlatText($matches[0])) {
29 $parser = new PhutilSimpleOptions();
30 $options = $parser->parse($matches[1]) +
$options;
32 $engine = id(new PhabricatorMemeEngine())
33 ->setViewer(PhabricatorUser
::getOmnipotentUser())
34 ->setTemplate($options['src'])
35 ->setAboveText($options['above'])
36 ->setBelowText($options['below']);
38 $asset = $engine->loadCachedFile();
40 $is_html_mail = $this->getEngine()->isHTMLMailMode();
41 $is_text = $this->getEngine()->isTextMode();
42 $must_inline = ($is_html_mail ||
$is_text);
47 $asset = $engine->newAsset();
48 } catch (Exception
$ex) {
55 $uri = $asset->getViewURI();
57 $uri = $engine->getGenerateURI();
63 $above = $options['above'];
65 $parts[] = pht('"%s"', $above);
68 $parts[] = $options['src'].' <'.$uri.'>';
70 $below = $options['below'];
72 $parts[] = pht('"%s"', $below);
75 $parts = implode("\n", $parts);
76 return $this->getEngine()->storeText($parts);
90 'class' => 'phabricator-remarkup-macro',
94 $img = id(new PHUIRemarkupImageView())
96 ->addClass('phabricator-remarkup-macro')
100 return $this->getEngine()->storeText($img);