Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98428867
CelerityManagementSyntaxWorkflow.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
Mon, Jan 13, 02:57
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Jan 15, 02:57 (2 d)
Engine
blob
Format
Raw Data
Handle
23575871
Attached To
rPH Phabricator
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
"
;
}
}
Event Timeline
Log In to Comment