@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 upstream/main 91 lines 2.1 kB view raw
1<?php 2 3final class PhutilRemarkupReplyBlockRule 4 extends PhutilRemarkupQuotedBlockRule { 5 6 public function getPriority() { 7 return 400; 8 } 9 10 public function getMatchingLineCount(array $lines, $cursor) { 11 $pos = $cursor; 12 13 if (preg_match('/^>>!/', $lines[$pos])) { 14 do { 15 ++$pos; 16 } while (isset($lines[$pos]) && preg_match('/^>/', $lines[$pos])); 17 } 18 19 return ($pos - $cursor); 20 } 21 22 public function extractChildText($text) { 23 $text = phutil_split_lines($text, true); 24 25 $head = substr(reset($text), 3); 26 27 $body = array_slice($text, 1); 28 $body = implode('', $body); 29 $body = $this->normalizeQuotedBody($body); 30 31 return array(trim($head), $body); 32 } 33 34 public function markupText($text, $children) { 35 $text = $this->applyRules($text); 36 37 if ($this->getEngine()->isTextMode()) { 38 $children = $this->getQuotedText($children); 39 return $text."\n\n".$children; 40 } 41 42 if ($this->getEngine()->isHTMLMailMode()) { 43 $block_attributes = array( 44 'style' => 'border-left: 3px solid #8C98B8; 45 color: #6B748C; 46 font-style: italic; 47 margin: 4px 0 12px 0; 48 padding: 8px 12px; 49 background-color: #F8F9FC;', 50 ); 51 $head_attributes = array( 52 'style' => 'font-style: normal; 53 padding-bottom: 4px;', 54 ); 55 $reply_attributes = array( 56 'style' => 'margin: 0; 57 padding: 0; 58 border: 0; 59 color: rgb(107, 116, 140);', 60 ); 61 } else { 62 $block_attributes = array( 63 'class' => 'remarkup-reply-block', 64 ); 65 $head_attributes = array( 66 'class' => 'remarkup-reply-head', 67 ); 68 $reply_attributes = array( 69 'class' => 'remarkup-reply-body', 70 ); 71 } 72 73 return phutil_tag( 74 'blockquote', 75 $block_attributes, 76 array( 77 "\n", 78 phutil_tag( 79 'div', 80 $head_attributes, 81 $text), 82 "\n", 83 phutil_tag( 84 'div', 85 $reply_attributes, 86 $children), 87 "\n", 88 )); 89 } 90 91}