@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<?php
2
3final class PhutilRemarkupHighlightRule extends PhutilRemarkupRule {
4
5 public function getPriority() {
6 return 1000.0;
7 }
8
9 public function apply($text) {
10 if ($this->getEngine()->isTextMode()) {
11 return $text;
12 }
13
14 return $this->replaceHTML(
15 '@!!(.+?)(!{2,})@',
16 array($this, 'applyCallback'),
17 $text);
18 }
19
20 protected function applyCallback(array $matches) {
21 // Remove the two exclamation points that represent syntax.
22 $excitement = substr($matches[2], 2);
23
24 // If the internal content consists of ONLY exclamation points, leave it
25 // untouched so "!!!!!" is five exclamation points instead of one
26 // highlighted exclamation point.
27 if (preg_match('/^!+\z/', $matches[1])) {
28 return $matches[0];
29 }
30
31 // $excitement now has two fewer !'s than we started with.
32 return hsprintf('<span class="remarkup-highlight">%s%s</span>',
33 $matches[1], $excitement);
34
35 }
36
37}