*** parser.rb.orig Wed Jan 12 02:33:55 2005 --- parser.rb.ibis Thu Jan 13 19:30:03 2005 *************** *** 61,68 **** --- 61,83 ---- @stack.clear @cur_stack.clear @last_blocktype.clear + @pre_flag = nil s.each do |line| + + ########### + # from this line added by ibis 04/12/30 - 05/01/11 + if @pre_flag == true then + if /^\}\}\}$/ =~ line then + @cur_stack.push( {:e => :pre_close2} ) + @pre_flag = nil + else + @cur_stack.push( {:e => :normal_text, :s => line } ) + end + else + # to this line added by ibis 04/12/30 - 05/01/11 + ########### + case line when /^(\!{1,5})(.+)$/ @cur_stack.push( {:e => :heading_open, :lv => $1.size} ) *************** *** 70,75 **** --- 85,102 ---- @cur_stack.push( {:e => :heading_close, :lv => $1.size} ) when /^----/ @cur_stack.push( {:e => :horizontal_rule} ) + ########### + # from this line added by ibis 04/12/30 - 05/01/11 + when /^<<<(.*)$/ + @cur_stack.push( {:e => :div_open, :c => $1} ) + when /^>>>$/ + @cur_stack.push( {:e => :div_close} ) + when /^\{\{\{(.*)$/ + @cur_stack.push( {:e => :pre_open2, :c => $1} ) + @pre_flag = true + + # to this line added by ibis 04/12/30 - 05/01/11 + ########### when /^(\*{1,3})(.+)$/ @cur_stack.push( {:e => :unordered_list, :lv => $1.size} ) @cur_stack.push( {:e => :listitem_open} ) *************** *** 117,122 **** --- 144,150 ---- else inline( line ) end + end # added by ibis 04/12/30 - 05/01/11 if @pre_flag @stack << normalize_line( @cur_stack ).dup @cur_stack.clear end *************** *** 189,197 **** @cur_stack.push( {:e => :normal_text, :s => str} ) str = '' end ! when WIKINAME_RE ! str = ($2 || '') + $' ! @cur_stack.push( {:e => :wikiname, :s => $1, :href => $1} ) when NORMAL_TEXT_RE m = $& after = $' --- 217,226 ---- @cur_stack.push( {:e => :normal_text, :s => str} ) str = '' end ! # comment out by ibis 04/12/30 ! # when WIKINAME_RE ! # str = ($2 || '') + $' ! # @cur_stack.push( {:e => :wikiname, :s => $1, :href => $1} ) when NORMAL_TEXT_RE m = $& after = $' *************** *** 220,225 **** --- 249,256 ---- ns = HikiStack::new last_type = nil block_level = Hash::new(0) + div_level = 0 + pre_flag = nil s.each do |e| type = e[:e] *************** *** 232,237 **** --- 263,293 ---- e[:e] = "heading#{e[:lv]}_open".intern ns.push( e ) @last_blocktype.push(type) + + ########### + # from this line added by ibis 04/12/30 - 05/01/11 + when :div_open + close_blocks( ns, block_level ) + ns.push( e ) + div_level = div_level + 1 + when :div_close + if div_level > 0 then + close_blocks( ns, block_level ) + ns.push( e ) + div_level = div_level -1 + else + ns.push( {:e => :normal_text, :s => ">>>\n"} ) + end + when :pre_open2 + close_blocks( ns, block_level ) + ns.push( e ) if ( ! pre_flag ) + pre_flag = true + when :pre_close2 + ns.push( e ) if pre_flag + pre_flag = nil + # to this line added by ibis 04/12/30 - 05/01/11 + ########### + when :heading_close e[:e] = "heading#{e[:lv]}_close".intern ns.push( e ) *************** *** 310,316 **** close_blocks( ns, block_level ) end ! if @last_blocktype.empty? ns.push( {:e => :p_open} ) @last_blocktype.push(:p) end --- 366,372 ---- close_blocks( ns, block_level ) end ! if @last_blocktype.empty? && !pre_flag # changed by ibis ns.push( {:e => :p_open} ) @last_blocktype.push(:p) end *************** *** 320,325 **** --- 376,395 ---- last_type = e[:e] end close_blocks( ns, block_level ) + + ########### + # from this line added by ibis 05/01/11 + while div_level > 0 do + ns.push( :e => :div_close ) + div_level = div_level - 1 + end + if pre_flag then + ns.push( :e => :pre_close ) + pre_flag = nil + end + # to this line added by ibis 05/01/11 + ########### + ns end