summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-22 13:01:20 -0600
committerGitHub <noreply@github.com>2022-05-22 13:01:20 -0600
commit3853f10d3c8c73b5233d19a7ac83f31d58d9fb51 (patch)
treea888d9dde34a5f5ceb4bce41fca71f3bae861c6c /spec
parent4c03f53b8ab3b3a691cd3a190362ae873db49dc0 (diff)
resolves #1368 use specified column widths to avoid bugs in column width calculation when using colspans (PR #2200)
Diffstat (limited to 'spec')
-rw-r--r--spec/table_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/table_spec.rb b/spec/table_spec.rb
index b3e00aa2..70d45614 100644
--- a/spec/table_spec.rb
+++ b/spec/table_spec.rb
@@ -2834,6 +2834,67 @@ describe 'Asciidoctor::PDF::Converter - Table' do
(expect pdf.find_text 'cell').to have_size 2
end
+ it 'should not allow colspan to cause table to exceed width of bounds' do
+ pdf_theme = { page_margin: 36 }
+ input = <<~'EOS'
+ [cols="1,1,1,2",grid=none,frame=sides]
+ |===
+ |a 3+|b
+ 2+|c |d >|z
+ |===
+ EOS
+
+ pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true
+ lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines
+ page_width = pdf.pages[0][:size][0]
+ right_margin_x = page_width - 36
+ right_border_x = lines.max_by {|l| l[:from][:x] }[:from][:x]
+ z_text = pdf.find_unique_text 'z'
+ (expect right_border_x).to eql right_margin_x
+ (expect z_text[:x]).to be < right_margin_x
+ end
+
+ it 'should not allow colspan to cause stretch table with autowidth columns to exceed width of bounds' do
+ pdf_theme = { page_margin: 36 }
+ input = <<~'EOS'
+ [.stretch%autowidth,grid=none,frame=sides]
+ |===
+ |a 3+|b
+ 2+|c |dddddddddddddddddddddddddddddddddddddddddddddddddd >|z
+ |===
+ EOS
+
+ pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true
+ lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines
+ page_width = pdf.pages[0][:size][0]
+ right_margin_x = page_width - 36
+ right_border_x = lines.max_by {|l| l[:from][:x] }[:from][:x]
+ z_text = pdf.find_unique_text 'z'
+ (expect right_border_x).to eql right_margin_x
+ (expect z_text[:x]).to be < right_margin_x
+ end
+
+ it 'should not allow colspan to cause table to exceed width of bounds when also using rowspan' do
+ pdf_theme = { page_margin: 36 }
+ input = <<~'EOS'
+ [cols="1,1,1,1,1,4",grid=none,frame=sides]
+ |===
+ .3+|a 5.+|bcd
+ .2+|e |f |g |h >|z
+ |one |more |time |fin
+ |===
+ EOS
+
+ pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true
+ lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines
+ page_width = pdf.pages[0][:size][0]
+ right_margin_x = page_width - 36
+ right_border_x = lines.max_by {|l| l[:from][:x] }[:from][:x]
+ z_text = pdf.find_unique_text 'z'
+ (expect right_border_x).to eql right_margin_x
+ (expect z_text[:x]).to be < right_margin_x
+ end
+
it 'should honor rowspan on cell in body row' do
pdf = to_pdf <<~'EOS', analyze: true
[cols=2*^.^]