Path: blob/master/src/infrastructure/markup/markuprule/PhutilRemarkupHighlightRule.php
12241 views
<?php12final class PhutilRemarkupHighlightRule extends PhutilRemarkupRule {34public function getPriority() {5return 1000.0;6}78public function apply($text) {9if ($this->getEngine()->isTextMode()) {10return $text;11}1213return $this->replaceHTML(14'@!!(.+?)(!{2,})@',15array($this, 'applyCallback'),16$text);17}1819protected function applyCallback(array $matches) {20// Remove the two exclamation points that represent syntax.21$excitement = substr($matches[2], 2);2223// If the internal content consists of ONLY exclamation points, leave it24// untouched so "!!!!!" is five exclamation points instead of one25// highlighted exclamation point.26if (preg_match('/^!+\z/', $matches[1])) {27return $matches[0];28}2930// $excitement now has two fewer !'s than we started with.31return hsprintf('<span class="remarkup-highlight">%s%s</span>',32$matches[1], $excitement);3334}3536}373839