lib/kramdown/parser/kramdown/table.rb in kramdown-1.4.1 vs lib/kramdown/parser/kramdown/table.rb in kramdown-1.4.2
- old
+ new
@@ -23,10 +23,11 @@
# Parse the table at the current location.
def parse_table
return false if !after_block_boundary?
+ saved_pos = @src.save_pos
orig_pos = @src.pos
table = new_block_el(:table, nil, nil, :alignment => [], :location => @src.current_line_number)
leading_pipe = (@src.check(TABLE_LINE) =~ /^\s*\|/)
@src.scan(TABLE_SEP_LINE)
@@ -102,11 +103,11 @@
break
end
end
if !before_block_boundary?
- @src.pos = orig_pos
+ @src.revert_pos(saved_pos)
return false
end
# Parse all lines of the table with the code span parser
env = save_env
@@ -133,16 +134,16 @@
else
break if lines.size > 1 && !pipe_on_line && lines.first !~ /^#{TABLE_PIPE_CHECK}/
pipe_on_line = (lines.size > 1 ? false : pipe_on_line) || (lines.last =~ /^#{TABLE_PIPE_CHECK}/)
end
end
- @src.pos = orig_pos and return false if !pipe_on_line
+ @src.revert_pos(saved_pos) and return false if !pipe_on_line
add_container.call(has_footer ? :tfoot : :tbody, false) if !rows.empty?
if !table.children.any? {|el| el.type == :tbody}
warning("Found table without body on line #{table.options[:location]} - ignoring it")
- @src.pos = orig_pos
+ @src.revert_pos(saved_pos)
return false
end
# adjust all table rows to have equal number of columns, same for alignment defs
table.children.each do |kind|