Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F547183
CelerityManagementSyntaxWorkflow.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
CelerityManagementSyntaxWorkflow.php
View Options
<?php
final
class
CelerityManagementSyntaxWorkflow
extends
CelerityManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'syntax'
)
->
setExamples
(
'**syntax** [options]'
)
->
setSynopsis
(
pht
(
'Rebuild syntax highlighting CSS.'
))
->
setArguments
(
array
());
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$styles
=
PhabricatorSyntaxStyle
::
getAllStyles
();
$root
=
dirname
(
phutil_get_library_root
(
'phabricator'
));
$root
=
$root
.
'/webroot/rsrc/css/syntax/'
;
foreach
(
$styles
as
$key
=>
$style
)
{
$content
=
$this
->
generateCSS
(
$style
);
$path
=
$root
.
'/syntax-'
.
$key
.
'.css'
;
Filesystem
::
writeFile
(
$path
,
$content
);
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Rebuilt "%s" syntax CSS.'
,
basename
(
$path
)));
}
return
0
;
}
private
function
generateCSS
(
PhabricatorSyntaxStyle
$style
)
{
$key
=
$style
->
getSyntaxStyleKey
();
$provides
=
"syntax-{$key}-css"
;
$generated
=
'generated'
;
$header
=
"/**
\n
"
.
" * @provides {$provides}
\n
"
.
" * @{$generated}
\n
"
.
" */
\n\n
"
;
$groups
=
array
();
$map
=
$style
->
getStyleMap
();
ksort
(
$map
);
foreach
(
$map
as
$key
=>
$value
)
{
$groups
[
$value
][]
=
$key
;
}
$rules
=
array
();
foreach
(
$groups
as
$body
=>
$classes
)
{
$parts
=
array
();
foreach
(
$classes
as
$class
)
{
$parts
[]
=
".remarkup-code .{$class}"
;
}
$rules
[]
=
implode
(
",
\n
"
,
$parts
).
" {
\n
{$body}
\n
}"
;
}
$rules
=
implode
(
"
\n\n
"
,
$rules
);
return
$header
.
$rules
.
"
\n
"
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:28 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
104504
Default Alt Text
CelerityManagementSyntaxWorkflow.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment