Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F546522
PhabricatorRemarkupFigletBlockInterpreter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorRemarkupFigletBlockInterpreter.php
View Options
<?php
final
class
PhabricatorRemarkupFigletBlockInterpreter
extends
PhutilRemarkupBlockInterpreter
implements
RemarkupSyntaxDocumentationProvider
{
public
function
getInterpreterName
()
{
return
'figlet'
;
}
/**
* @phutil-external-symbol class Text_Figlet
*/
public
function
markupContent
(
$content
,
array
$argv
)
{
$map
=
self
::
getFigletMap
();
$font
=
idx
(
$argv
,
'font'
);
$font
=
phutil_utf8_strtolower
(
$font
);
if
(
empty
(
$map
[
$font
]))
{
$font
=
'standard'
;
}
$root
=
dirname
(
phutil_get_library_root
(
'phabricator'
));
require_once
$root
.
'/externals/pear-figlet/Text/Figlet.php'
;
$figlet
=
new
Text_Figlet
();
$figlet
->
loadFont
(
$map
[
$font
]);
$result
=
$figlet
->
lineEcho
(
$content
);
$engine
=
$this
->
getEngine
();
if
(
$engine
->
isTextMode
())
{
return
$result
;
}
if
(
$engine
->
isHTMLMailMode
())
{
return
phutil_tag
(
'pre'
,
array
(),
$result
);
}
return
phutil_tag
(
'div'
,
array
(
'class'
=>
'PhabricatorMonospaced remarkup-figlet'
,
),
$result
);
}
private
static
function
getFigletMap
()
{
$root
=
dirname
(
phutil_get_library_root
(
'phabricator'
));
$dirs
=
array
(
$root
.
'/externals/figlet/fonts/'
,
$root
.
'/externals/pear-figlet/fonts/'
,
$root
.
'/resources/figlet/custom/'
,
);
$map
=
array
();
foreach
(
$dirs
as
$dir
)
{
foreach
(
Filesystem
::
listDirectory
(
$dir
,
false
)
as
$file
)
{
if
(
preg_match
(
'/
\.
flf
\z
/'
,
$file
))
{
$name
=
phutil_utf8_strtolower
(
$file
);
$name
=
preg_replace
(
'/
\.
flf
\z
/'
,
''
,
$name
);
$map
[
$name
]
=
$dir
.
$file
;
}
}
}
return
$map
;
}
public
function
getDocumentation
()
{
return
<<<EOT
= Figlet
The `figlet` interpreter allows you to write some large text.
For example, this:
```figlet{{{Some big text!}}}```
...produces this:
figlet{{{Some big text!}}}
[[/reference/figlet/ | More information about Figlet]] is available.
EOT;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:16 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
122675
Default Alt Text
PhabricatorRemarkupFigletBlockInterpreter.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment