sutty-liquid 0.11.3 → 0.11.4

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: ce0868d47ddff4cd4039fa6b0c34cb0584616607a6a1cc90d1c261b3b21ad2d0
4
+ data.tar.gz: fd6da83300172da4f5e97e92580572d13eef4b9267d121cd7a0381de9475cfe2
5
5
  SHA512:
6
- metadata.gz: 42e4a38bdab65fd6b6e20a21e9a494f06af97860a53c0e5f150ff74ee182a9aeac5de4e497e530832a7166b4f66b6fcfc14d53cfe52300c8cea71a96a625a4c7
7
- data.tar.gz: 62903a5329c71c770f47956fda99d3233f7607548a78df21d879dda03b3b6f50e88c81f7547cea16bcdb891b73bc090e659ee242627e515d19d83c9fa8b5eff8
6
+ metadata.gz: e45850dd01a4f13744a43365b76985ad9a5a09059a59a0606cb027513881c15d9ab011ff640a9014917dbcd0e7159804189d38b80c0778e0ab43ae0e6bb0d35b
7
+ data.tar.gz: 1fbc0417719b7b8f07902b27748fca574acf5ad199644c45ac5374523140049ba45b8560df427d25bb8e39bf3a9eac5d768bbc8ffdfc07417dfe923da449ab41
@@ -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-?[^0-9\s]+\z/
9
+ CSS_IDENTIFIER_LONG = /\A--[^\s]+\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.4
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