lib/html-conditional-comment/lexer.rb in html-conditional-comment-0.0.2 vs lib/html-conditional-comment/lexer.rb in html-conditional-comment-0.0.3
- old
+ new
@@ -1,9 +1,9 @@
module HtmlConditionalComment
class TokenError < StandardError
def initialize(rest)
- super("Invalid token \"#{rest.slice(0, 25)}\"")
+ super("Invalid token \"#{rest.to_s.slice(0, 25)}\"")
end
end
##
# Converts string into array of tokens. Token is an array, first element is
@@ -22,12 +22,13 @@
TRUE = /true/i
FALSE = /false/i
IF_STATEMENT = /if/i
ENDIF_STATEMENT = /endif/i
#Opening statement plus positive look ahead to avoid conflicts with other
- #comments
- OPEN = /<!(\-\-)?\s*\[(?=(end)?if)/
- CLOSE = /\]\s*(\-\-)?>/
+ #comments, could also have additional comments before "if"
+ OPEN = /<!(\-\-)?[^>]*?\[(?=(end)?if)/
+ #Closing statement with additional comments after "endif"
+ CLOSE = /\].*?(\-\-)?>/
WHITE_SPACE = /\s+/
FEATURE = /[a-z]+/i
VERSION_VECTOR = /\d+(\.[\d]+)?/
TOKENS = [