@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 33 lines 806 B view raw
1<?php 2 3final class PhutilDefaultSyntaxHighlighterEnginePygmentsFuture 4 extends FutureProxy { 5 6 private $source; 7 private $scrub; 8 9 public function __construct(Future $proxied, $source, $scrub = false) { 10 parent::__construct($proxied); 11 $this->source = $source; 12 $this->scrub = $scrub; 13 } 14 15 protected function didReceiveResult($result) { 16 list($err, $stdout, $stderr) = $result; 17 18 if (!$err && strlen($stdout)) { 19 // Strip off fluff Pygments adds. 20 $stdout = preg_replace( 21 '@^<div class="highlight"><pre>(.*)</pre></div>\s*$@s', 22 '\1', 23 $stdout); 24 if ($this->scrub) { 25 $stdout = preg_replace('/^.*\n/', '', $stdout); 26 } 27 return phutil_safe_html($stdout); 28 } 29 30 throw new PhutilSyntaxHighlighterException($stderr, $err); 31 } 32 33}