@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 49 lines 1.3 kB view raw
1<?php 2 3final class PhutilRemarkupMonospaceRule extends PhutilRemarkupRule { 4 5 public function getPriority() { 6 return 100.0; 7 } 8 9 public function apply($text) { 10 // NOTE: We don't require a trailing non-boundary on the backtick syntax, 11 // to permit the use case of naming and pluralizing a class, like 12 // "Load all the `PhutilArray`s and then iterate over them." In theory, the 13 // required \B on the leading backtick should protect us from most 14 // collateral damage. 15 16 return preg_replace_callback( 17 '@##([\s\S]+?)##|\B`(.+?)`@', 18 array($this, 'markupMonospacedText'), 19 $text); 20 } 21 22 protected function markupMonospacedText(array $matches) { 23 if ($this->getEngine()->isTextMode()) { 24 $result = $matches[0]; 25 26 } else 27 if ($this->getEngine()->isHTMLMailMode()) { 28 $match = isset($matches[2]) ? $matches[2] : $matches[1]; 29 $result = phutil_tag( 30 'tt', 31 array( 32 'style' => 'background: #ebebeb; font-size: 13px;', 33 ), 34 $match); 35 36 } else { 37 $match = isset($matches[2]) ? $matches[2] : $matches[1]; 38 $result = phutil_tag( 39 'tt', 40 array( 41 'class' => 'remarkup-monospaced', 42 ), 43 $match); 44 } 45 46 return $this->getEngine()->storeText($result); 47 } 48 49}