sutty-liquid 0.11.3 → 0.11.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d40dce8e97152d3e3a62e8c615ba0cd9705550858742c408438e4a4fdf23024
4
- data.tar.gz: 4f4779513b7182098a8d7d31a718d8ee330800a35f06ee11b4692c55d7d430c9
3
+ metadata.gz: fbea4639befe5fa090125f1f820f2d54128daef26382ce37ca87eb0260c9b559
4
+ data.tar.gz: 17fdf076023eaa6f0af383f779f3d42e470b92b41cc28f66f35688751fd2b62b
5
5
  SHA512:
6
- metadata.gz: 42e4a38bdab65fd6b6e20a21e9a494f06af97860a53c0e5f150ff74ee182a9aeac5de4e497e530832a7166b4f66b6fcfc14d53cfe52300c8cea71a96a625a4c7
7
- data.tar.gz: 62903a5329c71c770f47956fda99d3233f7607548a78df21d879dda03b3b6f50e88c81f7547cea16bcdb891b73bc090e659ee242627e515d19d83c9fa8b5eff8
6
+ metadata.gz: cf5d40db995baf63acc1ef8dac83c75d4aab6ed57f0cdf62f98c0e0c1f47bcd61a17a8c82396134db458071452d7b396a0b1300e64556f82741e6ba7b1969b65
7
+ data.tar.gz: 1aebbb6f79d474c1932c927d9c856807c14ba3438ed796929f80f9f12cfd86ce22464a561a46579cc761185edf95bd9bc234f703a17a4c3a934b6db42a975d14
@@ -4,6 +4,11 @@ module Jekyll
4
4
  module Filters
5
5
  # YAML to SCSS
6
6
  module YamlToScss
7
+ # @see {https://sass-lang.com/documentation/values/strings#unquoted}
8
+ CSS_IDENTIFIER_SHORT = /\A-?\w+\z/
9
+ CSS_IDENTIFIER_LONG = /\A--[\w0-9]+\z/
10
+ SCSS_FUNCTION = /\A[0-9a-z]+\(/
11
+
7
12
  # Converts a YAML object into SCSS. Only supports one level
8
13
  # values.
9
14
  #
@@ -28,7 +33,9 @@ module Jekyll
28
33
 
29
34
  case value
30
35
  when Array
31
- values = value.compact.map(&:to_s).reject(&:empty?)
36
+ values = value.compact.map(&:to_s).reject(&:empty?).map do |v|
37
+ scss_expression?(v) ? v : v.dump
38
+ end
32
39
 
33
40
  "$#{key}: (#{values.join(',')},);"
34
41
  when Hash
@@ -37,12 +44,15 @@ module Jekyll
37
44
  next if v.nil?
38
45
  next if v.to_s.empty?
39
46
 
47
+ v = v.dump unless scss_expression? v
48
+
40
49
  "\"#{key_to_scss k}\": #{v}"
41
50
  end
42
51
 
43
52
  "$#{key}: (#{values.join(',')},);"
44
53
  else
45
54
  next if value.to_s.empty?
55
+ value = value.dump unless scss_expression? value
46
56
 
47
57
  "$#{key}: #{value};"
48
58
  end
@@ -58,6 +68,37 @@ module Jekyll
58
68
  def key_to_scss(key)
59
69
  key.to_s.tr '_', '-'
60
70
  end
71
+
72
+ # Detects if value is a SCSS/SASS expression
73
+ #
74
+ # @param :value [Any]
75
+ # @return [Bool]
76
+ def scss_expression?(value)
77
+ return true unless value.is_a? String
78
+ # Quoted?
79
+ return false if value.start_with? '"'
80
+ return false if value.start_with? '\''
81
+ # Array/hash?
82
+ return true if value.start_with? '('
83
+ # Variable?
84
+ return true if value.start_with? '$'
85
+ # RGB color?
86
+ return true if value.start_with? '#'
87
+ # Negative number or CSS identifier?
88
+ return true if value.start_with? '-'
89
+
90
+ # Number?
91
+ (0..9).each do |i|
92
+ return true if value.start_with? i.to_s
93
+ end
94
+
95
+ # CSS identifier?
96
+ return true if CSS_IDENTIFIER_SHORT =~ value
97
+ return true if CSS_IDENTIFIER_LONG =~ value
98
+ return true if SCSS_FUNCTION =~ value
99
+
100
+ false
101
+ end
61
102
  end
62
103
  end
63
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sutty-liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-22 00:00:00.000000000 Z
11
+ date: 2022-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fast_blank
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
- rubygems_version: 3.3.25
183
+ rubygems_version: 3.1.6
184
184
  signing_key:
185
185
  specification_version: 4
186
186
  summary: Liquid filters