21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/ruby-bbcode-to-md/tag_sifter.rb', line 21
def process_text
regex_string = '((\[ (\/)? (\w+) ((=[^\[\]]+) | (\s\w+=\w+)* | ([^\]]*))? \]) | ([^\[]+))'
@text.scan(/#{regex_string}/ix) do |tag_info|
@ti = TagInfo.new(tag_info, @dictionary)
@ti.handle_unregistered_tags_as_text handle_closing_tags_that_are_multi_as_text_if_it_doesnt_match_the_latest_opener_tag_on_the_stack
return if !valid_element?
case @ti.type when :opening_tag
element = {:is_tag => true, :tag => @ti[:tag].to_sym, :definition => @ti.definition, :nodes => TagCollection.new }
element[:params] = {:tag_param => get_formatted_element_params} if @ti.can_have_params? and @ti.has_params?
@bbtree.build_up_new_tag(element)
@bbtree.escalate_bbtree(element)
when :text
set_parent_tag_from_multi_tag_to_concrete! if @bbtree.current_node.definition && @bbtree.current_node.definition[:multi_tag] == true
element = {:is_tag => false, :text => @ti.text }
if within_open_tag?
tag = @bbtree.current_node.definition
if tag[:require_between]
@bbtree.current_node[:between] = get_formatted_element_params
if candidate_for_using_between_as_param?
use_between_as_tag_param end
next end
end
@bbtree.build_up_new_tag(element)
when :closing_tag
@bbtree.retrogress_bbtree
end
end
validate_all_tags_closed_off validate_stack_level_too_deep_potential
end
|