def parse_lines(lines)
mode = :normal
previous_line = nil
table_header_set = false
lines.each do |text|
line = Line.new text, self
if @parser_options[:allow_include_files]
if line.include_file? and not line.include_file_path.nil?
next if not check_include_file line.include_file_path
include_data = get_include_data line
include_lines = Orgmode::Parser.new(include_data, @parser_options).lines
parse_lines include_lines
end
end
if line.link_abbrev?
link_abbrev_data = line.link_abbrev_data
@link_abbrevs[link_abbrev_data[0]] = link_abbrev_data[1]
end
mode = :normal if line.end_block? and [line.paragraph_type, :comment].include?(mode)
mode = :normal if line.property_drawer_end_block? and mode == :property_drawer
case mode
when :normal, :quote, :center
if Headline.headline? line.to_s
line = Headline.new line.to_s, self, @parser_options[:offset]
elsif line.table_separator?
if previous_line and previous_line.paragraph_type == :table_row and !table_header_set
previous_line.assigned_paragraph_type = :table_header
table_header_set = true
end
end
table_header_set = false if !line.table?
when :example, :html, :src
if previous_line
set_name_for_code_block(previous_line, line)
set_mode_for_results_block_contents(previous_line, line)
end
line.assigned_paragraph_type = :code
end
if mode == :normal
@headlines << @current_headline = line if Headline.headline? line.to_s
line.in_buffer_setting? do |key, value|
store_in_buffer_setting key.upcase, value
end
mode = line.paragraph_type if line.begin_block?
if previous_line
set_name_for_code_block(previous_line, line)
set_mode_for_results_block_contents(previous_line, line)
mode = :property_drawer if previous_line.property_drawer_begin_block?
end
if line.begin_block?
if line.results_block_should_be_exported?
@next_results_block_should_be_exported = true
else
@next_results_block_should_be_exported = false
end
end
end
if mode == :property_drawer and @current_headline
@current_headline.property_drawer[line.property_drawer_item.first] = line.property_drawer_item.last
end
unless mode == :comment
if @current_headline
@current_headline.body_lines << line
else
@header_lines << line
end
end
previous_line = line
end
end