Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90859573
PhabricatorRemarkupFigletBlockInterpreter.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
Tue, Nov 5, 10:22
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 7, 10:22 (2 d)
Engine
blob
Format
Raw Data
Handle
22147969
Attached To
rPH Phabricator
PhabricatorRemarkupFigletBlockInterpreter.php
View Options
<?php
final
class
PhabricatorRemarkupFigletBlockInterpreter
extends
PhutilRemarkupBlockInterpreter
{
public
function
getInterpreterName
()
{
return
'figlet'
;
}
public
function
markupContent
(
$content
,
array
$argv
)
{
if
(!
Filesystem
::
binaryExists
(
'figlet'
))
{
return
$this
->
markupError
(
pht
(
'Unable to locate the `figlet` binary. Install figlet.'
));
}
$font
=
idx
(
$argv
,
'font'
,
'standard'
);
$safe_font
=
preg_replace
(
'/[^0-9a-zA-Z-_.]/'
,
''
,
$font
);
$future
=
id
(
new
ExecFuture
(
'figlet -f %s'
,
$safe_font
))
->
setTimeout
(
15
)
->
write
(
trim
(
$content
,
"
\n
"
));
list
(
$err
,
$stdout
,
$stderr
)
=
$future
->
resolve
();
if
(
$err
)
{
return
$this
->
markupError
(
pht
(
'Execution of `%s` failed: %s'
,
'figlet'
,
$stderr
));
}
if
(
$this
->
getEngine
()->
isTextMode
())
{
return
$stdout
;
}
return
phutil_tag
(
'div'
,
array
(
'class'
=>
'PhabricatorMonospaced remarkup-figlet'
,
),
$stdout
);
}
}
Event Timeline
Log In to Comment