lib/infoboxer/parser/table.rb in infoboxer-0.3.2 vs lib/infoboxer/parser/table.rb in infoboxer-0.3.3
- old
+ new
@@ -14,12 +14,13 @@
log "Table params found #{prms}"
table = Tree::Table.new(Nodes[], prms)
@context.next!
- loop do
+ guarded_loop do
table_next_line(table) or break
+ log 'Next table row'
@context.next!
end
# FIXME: not the most elegant way, huh?
table.children.reject! { |r| r.children.empty? }
@@ -64,12 +65,21 @@
def table_caption(table)
log 'Table caption found'
@context.skip(/^\s*\|\+\s*/)
+ params = if @context.check(/[^|{|\[]+\|([^\|]|$)/)
+ parse_params(@context.scan_until(/\|/))
+ else
+ {}
+ end
+
children = inline(/^\s*([|!]|{\|)/)
- @context.prev! if @context.eol? # compensate next! which will be done in table()
- table.push_children(TableCaption.new(children.strip))
+ if @context.matched
+ @context.unscan_matched!
+ @context.prev! # compensate next! which will be done in table()
+ end
+ table.push_children(TableCaption.new(children.strip, params))
end
def table_cells(table, cell_class = TableCell)
log 'Table cells found'
table.push_children(TableRow.new) unless table.children.last.is_a?(TableRow)