summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2020-10-23 02:55:49 -0600
committerDan Allen <dan.j.allen@gmail.com>2020-10-23 02:55:49 -0600
commitde6cd407dc679fa25a3e072fc23ba77eaec1abf6 (patch)
tree2ac872230fcfcca47dfd412dfa562a7814784d2c
parent4f155298308b646f3327619f6b0dfdbe52124366 (diff)
store body rows in a local variable when partitioning table header/footer
-rw-r--r--lib/asciidoctor/table.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/asciidoctor/table.rb b/lib/asciidoctor/table.rb
index aac25a8b..98870b1a 100644
--- a/lib/asciidoctor/table.rb
+++ b/lib/asciidoctor/table.rb
@@ -154,21 +154,17 @@ class Table < AbstractBlock
# returns nothing
def partition_header_footer(attrs)
# set rowcount before splitting up body rows
- @attributes['rowcount'] = @rows.body.size
+ num_body_rows = @attributes['rowcount'] = (body = @rows.body).size
- num_body_rows = @rows.body.size
if num_body_rows > 0 && @has_header_option
- head = @rows.body.shift
- num_body_rows -= 1
+ @rows.head = [(head = body.shift)]
# styles aren't applied to header row
head.each {|c| c.style = nil }
- # QUESTION why does AsciiDoc use an array for head? is it
- # possible to have more than one based on the syntax?
- @rows.head = [head]
+ num_body_rows -= 1
end
if num_body_rows > 0 && attrs['footer-option']
- @rows.foot = [@rows.body.pop]
+ @rows.foot = [body.pop]
end
nil