Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92597584
PhutilRemarkupRuleMonospace.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
Thu, Nov 21, 20:46
Size
502 B
Mime Type
text/x-php
Expires
Sat, Nov 23, 20:46 (2 d)
Engine
blob
Format
Raw Data
Handle
22466352
Attached To
rPHU libphutil
PhutilRemarkupRuleMonospace.php
View Options
<?php
/**
* @group markup
*/
final
class
PhutilRemarkupRuleMonospace
extends
PhutilRemarkupRule
{
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'@##([
\s\S
]+?)##|
\B
`(.+?)`
\B
@'
,
array
(
$this
,
'markupMonospacedText'
),
$text
);
}
private
function
markupMonospacedText
(
$matches
)
{
$match
=
isset
(
$matches
[
2
])
?
$matches
[
2
]
:
$matches
[
1
];
$result
=
'<tt>'
.
phutil_escape_html
(
$match
).
'</tt>'
;
return
$this
->
getEngine
()->
storeText
(
$result
);
}
}
Event Timeline
Log In to Comment