html-conditional-comment 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97464ae2f23046328299365a0878be4c2bf866b0
4
- data.tar.gz: b880bdd1eec80c11a7dd857b2da142b3fea68e2c
3
+ metadata.gz: 6eb0c6ec8e092042adb1eafc23fc9ab72545cd73
4
+ data.tar.gz: 34c5fb07c9da858757ae6c4779783836027a0c38
5
5
  SHA512:
6
- metadata.gz: 0f47fb2ed347cd31dd7ebcc1757354a87297dc2798e71190412fc7da2f9af085295d952bf7cbc70fe37a6498fc23686bc03080d7cf2dc33d9083b57e555d8ba8
7
- data.tar.gz: 5893de286574f16909c83a85829bcb87fad5765005957798a92dd8e143cdaf5a9be5d7ea84e9fde20757e7e785caf0767f7d220353410727268a6e8a47b3f591
6
+ metadata.gz: 7936397b2ad5346ef1ee50ea656535330e30984a896568819c98a38edc0a7660f36d7c3e1cb51eb876db1635cd6d2052f61a35459b5684b6da89a721948f4088
7
+ data.tar.gz: c89ac16b04a87d9361367c2cfb8ef2dd5cdbfdb0092a672a802ee9676779dc8a41fc707afe198f746c1aec9342da468daf7b0a35575f84a3cbac58c9610af288
@@ -1,7 +1,7 @@
1
1
  module HtmlConditionalComment
2
2
  class TokenError < StandardError
3
3
  def initialize(rest)
4
- super("Invalid token \"#{rest.slice(0, 25)}\"")
4
+ super("Invalid token \"#{rest.to_s.slice(0, 25)}\"")
5
5
  end
6
6
  end
7
7
 
@@ -24,9 +24,10 @@ module HtmlConditionalComment
24
24
  IF_STATEMENT = /if/i
25
25
  ENDIF_STATEMENT = /endif/i
26
26
  #Opening statement plus positive look ahead to avoid conflicts with other
27
- #comments
28
- OPEN = /<!(\-\-)?\s*\[(?=(end)?if)/
29
- CLOSE = /\]\s*(\-\-)?>/
27
+ #comments, could also have additional comments before "if"
28
+ OPEN = /<!(\-\-)?[^>]*?\[(?=(end)?if)/
29
+ #Closing statement with additional comments after "endif"
30
+ CLOSE = /\].*?(\-\-)?>/
30
31
  WHITE_SPACE = /\s+/
31
32
  FEATURE = /[a-z]+/i
32
33
  VERSION_VECTOR = /\d+(\.[\d]+)?/
@@ -1,7 +1,7 @@
1
1
  module HtmlConditionalComment
2
2
  class ParseError < StandardError
3
3
  def initialize(msg, example)
4
- super("#{msg} at \"#{example.slice(0, 25)}\"")
4
+ super("#{msg} at \"#{example.to_s.slice(0, 25)}\"")
5
5
  end
6
6
  end
7
7
 
@@ -22,6 +22,9 @@ module HtmlConditionalComment
22
22
  #browser = feature [ version_vector ]
23
23
  #
24
24
  class Parser
25
+ OPEN = /\-\->$/
26
+ CLOSE = /<!\-\-$/
27
+
25
28
  def initialize(tokens)
26
29
  @symbol = nil
27
30
  @tokens = tokens
@@ -153,13 +156,23 @@ protected
153
156
  expect(:open)
154
157
  expect(:if)
155
158
  node.left = expression()
159
+
160
+ #TODO Goofy confirmation of non-closing HTML comment
161
+ if current(:close)
162
+ error() if @value =~ OPEN
163
+ end
156
164
  expect(:close)
157
165
 
158
166
  unless current(:open) && peek(:endif)
159
167
  node.right = template()
160
168
  end
161
169
 
170
+ #TODO More goofyness
171
+ if current(:open)
172
+ error() if @value =~ CLOSE
173
+ end
162
174
  expect(:open)
175
+
163
176
  expect(:endif)
164
177
  expect(:close)
165
178
 
@@ -1,3 +1,3 @@
1
1
  module HtmlConditionalComment
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-conditional-comment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carson Reinke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-21 00:00:00.000000000 Z
11
+ date: 2017-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler