lib/html-conditional-comment/parser.rb in html-conditional-comment-0.0.2 vs lib/html-conditional-comment/parser.rb in html-conditional-comment-0.0.3

- old
+ new

@@ -1,9 +1,9 @@ module HtmlConditionalComment class ParseError < StandardError def initialize(msg, example) - super("#{msg} at \"#{example.slice(0, 25)}\"") + super("#{msg} at \"#{example.to_s.slice(0, 25)}\"") end end ## # @@ -20,10 +20,13 @@ #operator = "gt" | "gte" | "lt" | "lte" #boolean = "true" | "false" #browser = feature [ version_vector ] # class Parser + OPEN = /\-\->$/ + CLOSE = /<!\-\-$/ + def initialize(tokens) @symbol = nil @tokens = tokens @max_pos = tokens.size() - 1 @pos = -1 @@ -151,16 +154,26 @@ node = Nodes::Condition.new() expect(:open) expect(:if) node.left = expression() + + #TODO Goofy confirmation of non-closing HTML comment + if current(:close) + error() if @value =~ OPEN + end expect(:close) unless current(:open) && peek(:endif) node.right = template() end + #TODO More goofyness + if current(:open) + error() if @value =~ CLOSE + end expect(:open) + expect(:endif) expect(:close) node end