Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mincss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
mincss
Commits
ef3a6884
Commit
ef3a6884
authored
Oct 02, 2014
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for CSS3 pseudo-elements
parent
cccf4c43
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
19 deletions
+30
-19
Makefile
Makefile
+2
-2
lexer.mll
lexer.mll
+1
-0
parser.mly
parser.mly
+10
-6
selector.ml
selector.ml
+4
-3
stringify.ml
stringify.ml
+5
-3
types.ml
types.ml
+2
-1
util.ml
util.ml
+6
-4
No files found.
Makefile
View file @
ef3a6884
RESULT
:=
mincss
DIST
:=
dist/mincss
PRE_TGTS
:=
types
MODULES
:=
color_names util stringify parser lexer parse s
elector simple
\
shorthand
duplicates main
MODULES
:=
color_names util stringify parser lexer parse s
imple shorthand
\
duplicates main
ALL_NAMES
:=
$(PRE_TGTS)
$(MODULES)
OCAMLCFLAGS
:=
-g
...
...
lexer.mll
View file @
ef3a6884
...
...
@@ -146,6 +146,7 @@ rule token = parse
| ']' { RBRACK }
| ';' { SEMICOL }
| ':' { COLON }
| "
::
" { DOUBLE_COLON }
| ',' { COMMA }
| '.' { DOT }
...
...
parser.mly
View file @
ef3a6884
...
...
@@ -47,8 +47,10 @@
append_addons
(
Class
(
base
,
cls
))
tl
|
`Attribute
(
attr
,
value
)
::
tl
->
append_addons
(
Attribute
(
base
,
attr
,
value
))
tl
|
`Pseudo
(
f
,
args
)
::
tl
->
append_addons
(
Pseudo
(
base
,
f
,
args
))
tl
|
`Pseudo_class
(
f
,
args
)
::
tl
->
append_addons
(
Pseudo_class
(
base
,
f
,
args
))
tl
|
`Pseudo_element
elem
::
tl
->
append_addons
(
Pseudo_element
(
base
,
elem
))
tl
%
}
(* Tokens *)
...
...
@@ -57,8 +59,8 @@
%
token
<
float
>
PERCENTAGE
NUMBER
%
token
<
float
*
string
>
UNIT_VALUE
%
token
<
string
>
KEYFRAMES_SYM
COMBINATOR
RELATION
STRING
IDENT
HASH
URI
FUNCTION
%
token
LPAREN
RPAREN
LBRACE
RBRACE
LBRACK
RBRACK
SEMICOL
COLON
COMMA
DOT
PLUS
%
token
MINUS
SLASH
STAR
ONLY
AND
(*OR*)
NOT
FROM
TO
EOF
%
token
LPAREN
RPAREN
LBRACE
RBRACE
LBRACK
RBRACK
SEMICOL
COLON
DOUBLE_COLON
%
token
COMMA
DOT
PLUS
MINUS
SLASH
STAR
ONLY
AND
(*OR*)
NOT
FROM
TO
EOF
%
token
WS_AND
WS_OR
(* Start symbol *)
...
...
@@ -254,9 +256,11 @@ attrib:
|
S
*
s
=
STRING
S
*
{
Strlit
s
}
pseudo
:
|
COLON
id
=
IDENT
{
`Pseudo
(
String
.
lowercase
id
,
None
)
}
{
`Pseudo
_class
(
String
.
lowercase
id
,
None
)
}
|
COLON
f
=
FUNCTION
args
=
wslist
(
COMMA
,
simple_selector
)
RPAREN
{
`Pseudo
(
String
.
lowercase
f
,
Some
args
)
}
{
`Pseudo_class
(
String
.
lowercase
f
,
Some
args
)
}
|
DOUBLE_COLON
id
=
IDENT
{
`Pseudo_element
(
String
.
lowercase
id
)
}
declaration
:
|
name
=
property
S
*
COLON
S
*
value
=
expr
important
=
boption
(
ig2
(
IMPORTANT_SYM
,
S
*
))
...
...
selector.ml
View file @
ef3a6884
...
...
@@ -6,7 +6,7 @@ open Types
*)
let
is_pseudo_class
=
function
|
Pseudo
(
_
,
(
"link"
|
"hover"
|
"visited"
|
"active"
)
,
None
)
->
true
|
Pseudo
_class
(
_
,
(
"link"
|
"hover"
|
"visited"
|
"active"
)
,
None
)
->
true
|
_
->
false
(* Specificity (a, b, c, d):
...
...
@@ -26,10 +26,11 @@ let rec specificity =
add
(
0
,
1
,
0
,
0
)
(
specificity
base
)
|
Class
(
base
,
_
)
|
Attribute
(
base
,
_
,
_
)
->
add
(
0
,
0
,
1
,
0
)
(
specificity
base
)
|
Pseudo
(
base
,
_
,
_
)
as
addon
when
is_pseudo_class
addon
->
|
Pseudo
_class
(
base
,
_
,
_
)
as
addon
when
is_pseudo_class
addon
->
add
(
0
,
0
,
1
,
0
)
(
specificity
base
)
|
Pseudo
(
base
,
_
,
_
)
->
|
Pseudo
_class
(
base
,
_
,
_
)
->
add
(
0
,
0
,
0
,
1
)
(
specificity
base
)
(* XXX: Pseudo_element *)
|
Combinator
(
left
,
_
,
right
)
->
add
(
specificity
left
)
(
specificity
right
)
...
...
stringify.ml
View file @
ef3a6884
...
...
@@ -53,10 +53,12 @@ let rec stringify_selector w selector =
str
base
^
"["
^
attr
^
"]"
|
Attribute
(
base
,
attr
,
Some
(
op
,
value
))
->
str
base
^
"["
^
attr
^
w
^
op
^
w
^
string_of_expr
value
^
"]"
|
Pseudo
(
base
,
sel
,
None
)
->
str
base
^
":"
^
sel
|
Pseudo
(
base
,
fn
,
Some
args
)
->
|
Pseudo
_class
(
base
,
cls
,
None
)
->
str
base
^
":"
^
cls
|
Pseudo
_class
(
base
,
fn
,
Some
args
)
->
str
base
^
":"
^
fn
^
"("
^
cat
(
","
^
w
)
str
args
^
")"
|
Pseudo_element
(
base
,
elem
)
->
str
base
^
"::"
^
elem
|
Combinator
(
left
,
" "
,
right
)
->
str
left
^
" "
^
str
right
|
Combinator
(
left
,
com
,
right
)
->
...
...
types.ml
View file @
ef3a6884
...
...
@@ -17,7 +17,8 @@ type selector =
|
Element
of
string
|
Id
of
selector
*
string
|
Class
of
selector
*
string
|
Pseudo
of
selector
*
string
*
selector
list
option
|
Pseudo_class
of
selector
*
string
*
selector
list
option
|
Pseudo_element
of
selector
*
string
|
Attribute
of
selector
*
string
*
(
string
*
expr
)
option
|
Combinator
of
selector
*
string
*
selector
...
...
util.ml
View file @
ef3a6884
...
...
@@ -139,11 +139,13 @@ let transform_stylesheet f stylesheet =
f
(
Selector
(
Class
(
expect_selector
base
,
cls
)))
|
Attribute
(
base
,
attr
,
value
)
->
f
(
Selector
(
Attribute
(
expect_selector
base
,
attr
,
value
)))
|
Pseudo
(
base
,
sel
,
None
)
->
f
(
Selector
(
Pseudo
(
expect_selector
base
,
sel
,
None
)))
|
Pseudo
(
base
,
fn
,
Some
args
)
->
|
Pseudo
_class
(
base
,
cls
,
None
)
->
f
(
Selector
(
Pseudo
_class
(
expect_selector
base
,
cls
,
None
)))
|
Pseudo
_class
(
base
,
fn
,
Some
args
)
->
let
args
=
trav_all_selector
args
in
f
(
Selector
(
Pseudo
(
expect_selector
base
,
fn
,
Some
args
)))
f
(
Selector
(
Pseudo_class
(
expect_selector
base
,
fn
,
Some
args
)))
|
Pseudo_element
(
base
,
elem
)
->
f
(
Selector
(
Pseudo_element
(
expect_selector
base
,
elem
)))
|
Combinator
(
left
,
com
,
right
)
->
let
left
=
expect_selector
left
in
let
right
=
expect_selector
right
in
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment