Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14399770
PhutilRainbowSyntaxHighlighter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
993 B
Referenced Files
None
Subscribers
None
PhutilRainbowSyntaxHighlighter.php
View Options
<?php
/**
* Highlights source code with a rainbow of colors, regardless of the language.
* This highlighter is useless, absurd, and extremely slow.
*/
final
class
PhutilRainbowSyntaxHighlighter
extends
Phobject
{
private
$config
=
array
();
public
function
setConfig
(
$key
,
$value
)
{
$this
->
config
[
$key
]
=
$value
;
return
$this
;
}
public
function
getHighlightFuture
(
$source
)
{
$color
=
0
;
$colors
=
array
(
'rbw_r'
,
'rbw_o'
,
'rbw_y'
,
'rbw_g'
,
'rbw_b'
,
'rbw_i'
,
'rbw_v'
,
);
$result
=
array
();
foreach
(
phutil_utf8v
(
$source
)
as
$character
)
{
if
(
$character
==
' '
||
$character
==
"
\n
"
)
{
$result
[]
=
$character
;
continue
;
}
$result
[]
=
phutil_tag
(
'span'
,
array
(
'class'
=>
$colors
[
$color
]),
$character
);
$color
=
(
$color
+
1
)
%
count
(
$colors
);
}
$result
=
phutil_implode_html
(
''
,
$result
);
return
new
ImmediateFuture
(
$result
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Dec 24, 5:45 PM (1 d, 13 h)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6906889
Default Alt Text
PhutilRainbowSyntaxHighlighter.php (993 B)
Attached To
Mode
rPHU libphutil
Attached
Detach File
Event Timeline
Log In to Comment