Differential D20393 Diff 48698 src/markup/engine/remarkup/blockrule/PhutilRemarkupReplyBlockRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/markup/engine/remarkup/blockrule/PhutilRemarkupReplyBlockRule.php
<?php | <?php | ||||
final class PhutilRemarkupReplyBlockRule extends PhutilRemarkupBlockRule { | final class PhutilRemarkupReplyBlockRule | ||||
extends PhutilRemarkupQuotedBlockRule { | |||||
public function getPriority() { | public function getPriority() { | ||||
return 400; | return 400; | ||||
} | } | ||||
public function getMatchingLineCount(array $lines, $cursor) { | public function getMatchingLineCount(array $lines, $cursor) { | ||||
$pos = $cursor; | $pos = $cursor; | ||||
if (preg_match('/^>>!/', $lines[$pos])) { | if (preg_match('/^>>!/', $lines[$pos])) { | ||||
do { | do { | ||||
++$pos; | ++$pos; | ||||
} while (isset($lines[$pos]) && preg_match('/^>/', $lines[$pos])); | } while (isset($lines[$pos]) && preg_match('/^>/', $lines[$pos])); | ||||
} | } | ||||
return ($pos - $cursor); | return ($pos - $cursor); | ||||
} | } | ||||
public function supportsChildBlocks() { | |||||
return true; | |||||
} | |||||
public function extractChildText($text) { | public function extractChildText($text) { | ||||
$text = phutil_split_lines($text, true); | $text = phutil_split_lines($text, true); | ||||
$head = array(); | |||||
$body = array(); | |||||
$head = substr(reset($text), 3); | $head = substr(reset($text), 3); | ||||
$body = array_slice($text, 1); | $body = array_slice($text, 1); | ||||
$body = implode('', $body); | |||||
$body = $this->normalizeQuotedBody($body); | |||||
// Remove the carets. | return array(trim($head), $body); | ||||
foreach ($body as $key => $line) { | |||||
$body[$key] = substr($line, 1); | |||||
} | |||||
// Strip leading empty lines. | |||||
foreach ($body as $key => $line) { | |||||
if (strlen(trim($line))) { | |||||
break; | |||||
} | |||||
unset($body[$key]); | |||||
} | |||||
return array(trim($head), implode('', $body)); | |||||
} | } | ||||
public function markupText($text, $children) { | public function markupText($text, $children) { | ||||
$text = $this->applyRules($text); | $text = $this->applyRules($text); | ||||
if ($this->getEngine()->isTextMode()) { | if ($this->getEngine()->isTextMode()) { | ||||
$children = phutil_split_lines($children, true); | $children = $this->getQuotedText($children); | ||||
foreach ($children as $key => $child) { | |||||
if (strlen(trim($child))) { | |||||
$children[$key] = '> '.$child; | |||||
} else { | |||||
$children[$key] = '>'.$child; | |||||
} | |||||
} | |||||
$children = implode('', $children); | |||||
return $text."\n\n".$children; | return $text."\n\n".$children; | ||||
} | } | ||||
if ($this->getEngine()->isHTMLMailMode()) { | if ($this->getEngine()->isHTMLMailMode()) { | ||||
$block_attributes = array( | $block_attributes = array( | ||||
'style' => 'border-left: 3px solid #8C98B8; | 'style' => 'border-left: 3px solid #8C98B8; | ||||
color: #6B748C; | color: #6B748C; | ||||
font-style: italic; | font-style: italic; | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |