[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/infrastructure/markup/interpreter/ -> PhabricatorRemarkupFigletBlockInterpreter.php (source)

   1  <?php
   2  
   3  final class PhabricatorRemarkupFigletBlockInterpreter
   4    extends PhutilRemarkupBlockInterpreter {
   5  
   6    public function getInterpreterName() {
   7      return 'figlet';
   8    }
   9  
  10    public function markupContent($content, array $argv) {
  11      if (!Filesystem::binaryExists('figlet')) {
  12        return $this->markupError(
  13          pht('Unable to locate the `figlet` binary. Install figlet.'));
  14      }
  15  
  16      $font = idx($argv, 'font', 'standard');
  17      $safe_font = preg_replace('/[^0-9a-zA-Z-_.]/', '', $font);
  18      $future = id(new ExecFuture('figlet -f %s', $safe_font))
  19        ->setTimeout(15)
  20        ->write(trim($content, "\n"));
  21  
  22      list($err, $stdout, $stderr) = $future->resolve();
  23  
  24      if ($err) {
  25        return $this->markupError(
  26          pht(
  27            'Execution of `figlet` failed:', $stderr));
  28      }
  29  
  30  
  31      if ($this->getEngine()->isTextMode()) {
  32        return $stdout;
  33      }
  34  
  35      return phutil_tag(
  36        'div',
  37        array(
  38          'class' => 'PhabricatorMonospaced remarkup-figlet',
  39        ),
  40        $stdout);
  41    }
  42  
  43  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1