diff --git a/src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php b/src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php index 66801d9578..f24e1e7b3d 100644 --- a/src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php +++ b/src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php @@ -1,68 +1,74 @@ setTemplate($map[$cow]) ->setAction($action) ->setEyes($eyes) ->setTongue($tongue) ->setText($content) ->renderCow(); - if ($this->getEngine()->isTextMode()) { + $engine = $this->getEngine(); + + if ($engine->isTextMode()) { return $result; } + if ($engine->isHTMLMailMode()) { + return phutil_tag('pre', array(), $result); + } + return phutil_tag( 'div', array( 'class' => 'PhabricatorMonospaced remarkup-cowsay', ), $result); } private static function getCowMap() { $root = dirname(phutil_get_library_root('phabricator')); $directories = array( $root.'/externals/cowsay/cows/', $root.'/resources/cows/builtin/', $root.'/resources/cows/custom/', ); $map = array(); foreach ($directories as $directory) { foreach (Filesystem::listDirectory($directory, false) as $cow_file) { $matches = null; if (!preg_match('/^(.*)\.cow\z/', $cow_file, $matches)) { continue; } $cow_name = $matches[1]; $cow_name = phutil_utf8_strtolower($cow_name); $map[$cow_name] = Filesystem::readFile($directory.$cow_file); } } return $map; } } diff --git a/src/infrastructure/markup/interpreter/PhabricatorRemarkupFigletBlockInterpreter.php b/src/infrastructure/markup/interpreter/PhabricatorRemarkupFigletBlockInterpreter.php index e823d7bdeb..ee794bcc73 100644 --- a/src/infrastructure/markup/interpreter/PhabricatorRemarkupFigletBlockInterpreter.php +++ b/src/infrastructure/markup/interpreter/PhabricatorRemarkupFigletBlockInterpreter.php @@ -1,65 +1,71 @@ loadFont($map[$font]); $result = $figlet->lineEcho($content); - if ($this->getEngine()->isTextMode()) { + $engine = $this->getEngine(); + + if ($engine->isTextMode()) { return $result; } + if ($engine->isHTMLMailMode()) { + return phutil_tag('pre', array(), $result); + } + return phutil_tag( 'div', array( 'class' => 'PhabricatorMonospaced remarkup-figlet', ), $result); } private static function getFigletMap() { $root = dirname(phutil_get_library_root('phabricator')); $dirs = array( $root.'/externals/figlet/fonts/', $root.'/externals/pear-figlet/fonts/', $root.'/resources/figlet/custom/', ); $map = array(); foreach ($dirs as $dir) { foreach (Filesystem::listDirectory($dir, false) as $file) { if (preg_match('/\.flf\z/', $file)) { $name = phutil_utf8_strtolower($file); $name = preg_replace('/\.flf\z/', '', $name); $map[$name] = $dir.$file; } } } return $map; } }