css_parser 1.3.7 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/css_parser/regexps.rb +1 -0
- data/lib/css_parser/rule_set.rb +20 -1
- data/lib/css_parser/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b24b01cc09a9975b249b7f68331c44a4b2e6d00
|
4
|
+
data.tar.gz: 7dc6b7777312134d63abf3ba61154ec152f5ee40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf202f430205ba83586fbc04ebe084ca12fe552303b70691ae69755ea8d8753cdc94cc1dc87ef4d22bff55b134880f2c23133764539d75b7a4080c67e834fccd
|
7
|
+
data.tar.gz: 9384222c4c92f027b0869a2941459ab5ad408b054b7180d4f2aef5e0e784b2a8601057065d1e03794e3710b8744c7f0b5ea280382e386ab3a31b1ac1fcf85785
|
data/lib/css_parser/regexps.rb
CHANGED
@@ -47,6 +47,7 @@ module CssParser
|
|
47
47
|
BOX_MODEL_UNITS_RX = /(auto|inherit|0|([\-]*([0-9]+|[0-9]*\.[0-9]+)(e[mx]+|px|[cm]+m|p[tc+]|in|\%)))([\s;]|\Z)/imx
|
48
48
|
RE_LENGTH_OR_PERCENTAGE = Regexp.new('([\-]*(([0-9]*\.[0-9]+)|[0-9]+)(e[mx]+|px|[cm]+m|p[tc+]|in|\%))', Regexp::IGNORECASE)
|
49
49
|
RE_BACKGROUND_POSITION = Regexp.new("((((#{RE_LENGTH_OR_PERCENTAGE})|left|center|right|top|bottom)[\s]*){1,2})", Regexp::IGNORECASE | Regexp::EXTENDED)
|
50
|
+
RE_BACKGROUND_SIZE = Regexp.new("\\s*/\\s*((((#{RE_LENGTH_OR_PERCENTAGE})|auto|cover|contain|initial|inherit)[\\s]*){1,2})", Regexp::IGNORECASE | Regexp::EXTENDED)
|
50
51
|
FONT_UNITS_RX = /(([x]+\-)*small|medium|large[r]*|auto|inherit|([0-9]+|[0-9]*\.[0-9]+)(e[mx]+|px|[cm]+m|p[tc+]|in|\%)*)/i
|
51
52
|
RE_BORDER_STYLE = /([\s]*^)?(none|hidden|dotted|dashed|solid|double|dot-dash|dot-dot-dash|wave|groove|ridge|inset|outset)([\s]*$)?/imx
|
52
53
|
RE_BORDER_UNITS = Regexp.union(BOX_MODEL_UNITS_RX, /(thin|medium|thick)/i)
|
data/lib/css_parser/rule_set.rb
CHANGED
@@ -4,7 +4,7 @@ module CssParser
|
|
4
4
|
RE_ELEMENTS_AND_PSEUDO_ELEMENTS = /((^|[\s\+\>]+)[\w]+|\:(first\-line|first\-letter|before|after))/i
|
5
5
|
RE_NON_ID_ATTRIBUTES_AND_PSEUDO_CLASSES = /(\.[\w]+)|(\[[\w]+)|(\:(link|first\-child|lang))/i
|
6
6
|
|
7
|
-
BACKGROUND_PROPERTIES = ['background-color', 'background-image', 'background-repeat', 'background-position', 'background-attachment']
|
7
|
+
BACKGROUND_PROPERTIES = ['background-color', 'background-image', 'background-repeat', 'background-position', 'background-size', 'background-attachment']
|
8
8
|
LIST_STYLE_PROPERTIES = ['list-style-type', 'list-style-position', 'list-style-image']
|
9
9
|
|
10
10
|
# Array of selector strings.
|
@@ -149,11 +149,18 @@ module CssParser
|
|
149
149
|
split_declaration('background', 'background-attachment', value.slice!(CssParser::RE_SCROLL_FIXED))
|
150
150
|
split_declaration('background', 'background-repeat', value.slice!(CssParser::RE_REPEAT))
|
151
151
|
split_declaration('background', 'background-color', value.slice!(CssParser::RE_COLOUR))
|
152
|
+
split_declaration('background', 'background-size', extract_background_size_from(value))
|
152
153
|
split_declaration('background', 'background-position', value.slice(CssParser::RE_BACKGROUND_POSITION))
|
153
154
|
|
154
155
|
@declarations.delete('background')
|
155
156
|
end
|
156
157
|
|
158
|
+
def extract_background_size_from(value)
|
159
|
+
size = value.slice!(CssParser::RE_BACKGROUND_SIZE)
|
160
|
+
|
161
|
+
size.sub(/^\s*\/\s*/, '') if size
|
162
|
+
end
|
163
|
+
|
157
164
|
# Split shorthand border declarations (e.g. <tt>border: 1px red;</tt>)
|
158
165
|
# Additional splitting happens in expand_dimensions_shorthand!
|
159
166
|
def expand_border_shorthand! # :nodoc:
|
@@ -327,6 +334,18 @@ module CssParser
|
|
327
334
|
#
|
328
335
|
# Leaves properties declared !important alone.
|
329
336
|
def create_background_shorthand! # :nodoc:
|
337
|
+
# When we have a background-size property we must separate it and distinguish it from
|
338
|
+
# background-position by preceeding it with a backslash. In this case we also need to
|
339
|
+
# have a background-position property, so we set it if it's missing.
|
340
|
+
# http://www.w3schools.com/cssref/css3_pr_background.asp
|
341
|
+
if @declarations.has_key?('background-size') and not @declarations['background-size'][:is_important]
|
342
|
+
unless @declarations.has_key?('background-position')
|
343
|
+
@declarations['background-position'] = {value => 'initial'}
|
344
|
+
end
|
345
|
+
|
346
|
+
@declarations['background-size'][:value] = "/ #{@declarations['background-size'][:value]}"
|
347
|
+
end
|
348
|
+
|
330
349
|
create_shorthand_properties! BACKGROUND_PROPERTIES, 'background'
|
331
350
|
end
|
332
351
|
|
data/lib/css_parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: css_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dunae
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
55
|
version: '0'
|
56
56
|
requirements: []
|
57
57
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.
|
58
|
+
rubygems_version: 2.4.5.1
|
59
59
|
signing_key:
|
60
60
|
specification_version: 4
|
61
61
|
summary: Ruby CSS parser.
|