# File lib/maruku/input/parse_block.rb, line 45
        def parse_blocks(src)
                output = BlockContext.new
                
                # run state machine
                while src.cur_line
                        
                        next if check_block_extensions(src, output, src.cur_line)
                        
#  Prints detected type (useful for debugging)
#                       puts "#{src.cur_line.md_type}|#{src.cur_line}"
                        case src.cur_line.md_type
                                when :empty; 
                                        output.push :empty
                                        src.ignore_line
                                when :ial
                                        m =  InlineAttributeList.match src.shift_line
                                        content = m[1] ||  "" 
#                                       puts "Content: #{content.inspect}"
                                        src2 = CharSource.new(content, src)
                                        interpret_extension(src2, output, [nil])
                                when :ald
                                        output.push read_ald(src)
                                when :text
                                        # paragraph, or table, or definition list
                                        read_text_material(src, output)
                                when :header2, :hrule
                                        # hrule
                                        src.shift_line
                                        output.push md_hrule()
                                when :header3
                                        output.push read_header3(src)
                                when :ulist, :olist
                                        list_type = src.cur_line.md_type == :ulist ? :ul : :ol
                                        li = read_list_item(src)
                                        # append to current list if we have one
                                        if output.last.kind_of?(MDElement) && 
                                                output.last.node_type == list_type then
                                                output.last.children << li
                                        else
                                                output.push md_el(list_type, [li])
                                        end
                                when :quote;    output.push read_quote(src)
                                when :code;     e = read_code(src); output << e if e
                                when :raw_html; e = read_raw_html(src); output << e if e

                                when :footnote_text;   output.push read_footnote_text(src)
                                when :ref_definition;  
                                        if src.parent && (src.cur_index == 0)
                                                read_text_material(src, output)
                                        else
                                                read_ref_definition(src, output)
                                        end
                                when :abbreviation;    output.push read_abbreviation(src)
                                when :xml_instr;       read_xml_instruction(src, output)
                                when :metadata;        
                                        maruku_error "Please use the new meta-data syntax: \n"+
                                        "  http://maruku.rubyforge.org/proposal.html\n", src
                                        src.ignore_line
                                else # warn if we forgot something
                                        md_type = src.cur_line.md_type
                                        line = src.cur_line
                                        maruku_error "Ignoring line '#{line}' type = #{md_type}", src
                                        src.shift_line
                        end
                end

                merge_ial(output, src, output)
                output.delete_if {|x| x.kind_of?(MDElement) &&
                        x.node_type == :ial}
                
                # get rid of empty line markers
                output.delete_if {|x| x == :empty}
                # See for each list if we can omit the paragraphs and use li_span
                # TODO: do this after
                output.each do |c| 
                        # Remove paragraphs that we can get rid of
                        if [:ul,:ol].include? c.node_type 
                                if c.children.all? {|li| !li.want_my_paragraph} then
                                        c.children.each do |d|
                                                d.node_type = :li_span
                                                d.children = d.children[0].children 
                                        end
                                end
                        end 
                        if c.node_type == :definition_list
                                if c.children.all?{|defi| !defi.want_my_paragraph} then
                                        c.children.each do |definition| 
                                                definition.definitions.each do |dd|
                                                        dd.children = dd.children[0].children 
                                                end
                                        end
                                end
                        end 
                end
                
                output
        end