def split_on_rule(rule, ad)
return [self] unless @txt =~ rule.match
hash_tp = Hash.new
res = rule.apply(@txt)
match_ind = @txt =~ rule.match
tp_b4 = TextPortion.new(@txt.slice(0,match_ind), @pos)
hash_tp[@pos] = tp_b4
ext_atts = Hash.new
res.each do |n,v|
h = ad.atts[@pos+match_ind]
h = Hash.new unless h
h[n] = v
ad.atts[@pos+match_ind] = h
ext_atts[n] = v
end
tp_match = TextPortion.new($~[0], @pos+match_ind, true, ext_atts)
hash_tp[@pos+match_ind] = tp_match
end_ind = $~.end(0)
tp_after = TextPortion.new(@txt.slice(end_ind,@txt.length), @pos+end_ind)
if tp_after.txt =~ rule.match
hash2 = tp_after.split_on_rule(rule, ad)
hash_tp.merge!(hash2)
else
hash_tp[@pos+end_ind] = tp_after
end
return hash_tp
end