Page MenuHomePhorge

PhutilRemarkupHighlightRule.php
No OneTemporary

Size
948 B
Referenced Files
None
Subscribers
None

PhutilRemarkupHighlightRule.php

<?php
final class PhutilRemarkupHighlightRule extends PhutilRemarkupRule {
public function getPriority() {
return 1000.0;
}
public function apply($text) {
if ($this->getEngine()->isTextMode()) {
return $text;
}
return $this->replaceHTML(
'@!!(.+?)(!{2,})@',
array($this, 'applyCallback'),
$text);
}
protected function applyCallback(array $matches) {
// Remove the two exclamation points that represent syntax.
$excitement = substr($matches[2], 2);
// If the internal content consists of ONLY exclamation points, leave it
// untouched so "!!!!!" is five exclamation points instead of one
// highlighted exclamation point.
if (preg_match('/^!+\z/', $matches[1])) {
return $matches[0];
}
// $excitement now has two fewer !'s than we started with.
return hsprintf('<span class="remarkup-highlight">%s%s</span>',
$matches[1], $excitement);
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, May 12, 1:53 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
111486
Default Alt Text
PhutilRemarkupHighlightRule.php (948 B)

Event Timeline