Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99017456
PhutilRemarkupHighlightRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 18, 12:17
Size
948 B
Mime Type
text/x-php
Expires
Mon, Jan 20, 12:17 (1 d, 16 h)
Engine
blob
Format
Raw Data
Handle
23691030
Attached To
rPHU libphutil
PhutilRemarkupHighlightRule.php
View Options
<?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
);
}
}
Event Timeline
Log In to Comment