hobo_files/plugin/lib/rexml.rb in hobo-0.6.4 vs hobo_files/plugin/lib/rexml.rb in hobo-0.7.0

- old
+ new

@@ -32,14 +32,15 @@ end end class BaseParser + DRYML_NAME_STR= "#{NCNAME_STR}(?::(?:#{NCNAME_STR})?)?" DRYML_ATTRIBUTE_PATTERN = /\s*(#{NAME_STR})(?:\s*=\s*(["'])(.*?)\2)?/um + DRYML_TAG_MATCH = /^<((?>#{DRYML_NAME_STR}))\s*((?>\s+#{NAME_STR}(?:\s*=\s*(["']).*?\3)?)*)\s*(\/)?>/um + DRYML_CLOSE_MATCH = /^\s*<\/(#{DRYML_NAME_STR})\s*>/um - DRYML_TAG_MATCH = /^<((?>#{NAME_STR}))\s*((?>\s+#{NAME_STR}(?:\s*=\s*(["']).*?\3)?)*)\s*(\/)?>/um - attr_writer :dryml_mode def dryml_mode? @dryml_mode end @@ -169,11 +170,11 @@ begin if @source.buffer[0] == ?< if @source.buffer[1] == ?/ last_tag, line_no = @tags.pop #md = @source.match_to_consume('>', CLOSE_MATCH) - md = @source.match(CLOSE_MATCH, true) + md = @source.match(dryml_mode? ? DRYML_CLOSE_MATCH : CLOSE_MATCH, true) valid_end_tag = if dryml_mode? last_tag =~ /^#{Regexp.escape(md[1])}(:.*)?/ else last_tag == md[1] @@ -337,10 +338,14 @@ attr_writer :has_end_tag def has_end_tag? @has_end_tag end + def parameter_tag? + expanded_name =~ /:$/ + end + end class Attribute def initialize_with_dryml(first, second=nil, parent=nil) @@ -377,9 +382,11 @@ end module Hobo::Dryml + + # A REXML source that keeps track of where in the buffer it is class RexSource < REXML::Source def initialize(src) super(src) @buffer_offset = 0