lib/jekyll-maps/options_parser.rb in jekyll-maps-1.0.2 vs lib/jekyll-maps/options_parser.rb in jekyll-maps-1.1.0

- old
+ new

@@ -1,15 +1,28 @@ module Jekyll module Maps class OptionsParser + OPTIONS_SYNTAX = %r!([^\s]+)\s*:\s*([^\s]+)! + ALLOWED_ATTRIBUTES = %w( + id + width + height + class + ).freeze + class << self def parse(raw_options) - options = { :filters => {} } - raw_options.strip.split(" ").each do |pair| - key = pair.split(":").first.strip - value = pair.split(":").last.strip + options = { + :attributes => {}, + :filters => {} + } + raw_options.scan(OPTIONS_SYNTAX).each do |key, value| value = value.split(",") if value.include?(",") - options[:filters][key] = value + if ALLOWED_ATTRIBUTES.include?(key) + options[:attributes][key.to_sym] = value + else + options[:filters][key] = value + end end options end end end