Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F116722863
DivinerRemarkupRuleSymbol.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
Sun, Jun 8, 19:56
Size
795 B
Mime Type
text/x-php
Expires
Tue, Jun 10, 19:56 (2 d)
Engine
blob
Format
Raw Data
Handle
26632426
Attached To
rPH Phabricator
DivinerRemarkupRuleSymbol.php
View Options
<?php
final
class
DivinerRemarkupRuleSymbol
extends
PhutilRemarkupRule
{
public
function
apply
(
$text
)
{
return
$this
->
replaceHTML
(
'/(?:^|
\B
)@{(?:(?P<type>[^:]+?):)?(?P<name>[^}]+?)}/'
,
array
(
$this
,
'markupSymbol'
),
$text
);
}
public
function
markupSymbol
(
$matches
)
{
$type
=
$matches
[
'type'
];
$name
=
$matches
[
'name'
];
// Collapse sequences of whitespace into a single space.
$name
=
preg_replace
(
'/
\s
+/'
,
' '
,
$name
);
$book
=
null
;
if
(
strpos
(
$type
,
'@'
)
!==
false
)
{
list
(
$type
,
$book
)
=
explode
(
'@'
,
$type
,
2
);
}
// TODO: This doesn't actually do anything useful yet.
$link
=
phutil_tag
(
'a'
,
array
(
'href'
=>
'#'
,
),
$name
);
return
$this
->
getEngine
()->
storeText
(
$link
);
}
}
Event Timeline
Log In to Comment