diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-10-25 21:56:28 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-25 21:56:28 -0600 |
| commit | 4d05ecb13cabfcc85dc7d1abab0b8ce871152d8f (patch) | |
| tree | ed4bede239f4da271d39d3eeb9b50022f5a3c3b0 /spec | |
| parent | 10c9c87dbc70ff1e7beff7bedce991b9510c8992 (diff) | |
resolves #2358 support horizontal alignment on AsciiDoc table cell that only contains paragraphs (PR #2359)
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/table_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/table_spec.rb b/spec/table_spec.rb index fb7dba36..09bd0e4a 100644 --- a/spec/table_spec.rb +++ b/spec/table_spec.rb @@ -1877,6 +1877,55 @@ describe 'Asciidoctor::PDF::Converter - Table' do (expect pdf.lines).to eql ['10. ten', '11. eleven', '12. twelve', 'buckle', 'my', 'shoe'] end + it 'should honor horizontal alignment on AsciiDoc table cell' do + pdf = to_pdf <<~'EOS', analyze: true + [cols=1a] + |=== + |left + |=== + + [cols=^1a] + |=== + |center + |=== + + [cols=>1a] + |=== + |right + |=== + EOS + + page_width = pdf.pages[0][:size][0] + midpoint = page_width * 0.5 + left_text = pdf.find_unique_text 'left' + center_text = pdf.find_unique_text 'center' + right_text = pdf.find_unique_text 'right' + (expect left_text[:x]).to be < midpoint + (expect center_text[:x]).to be < midpoint + (expect center_text[:x] + center_text[:width]).to be > midpoint + (expect right_text[:x]).to be > midpoint + end + + it 'should not honor horizontal alignment on AsciiDoc table cell that contains non-paragraph blocks' do + pdf = to_pdf <<~'EOS', analyze: true + [cols=>1a] + |=== + | + left + + ''' + + left + |=== + EOS + + page_width = pdf.pages[0][:size][0] + midpoint = page_width * 0.5 + left_texts = pdf.find_text 'left' + (expect left_texts[0][:x]).to be < midpoint + (expect left_texts[1][:x]).to be < midpoint + end + it 'should convert nested table' do pdf = to_pdf <<~'EOS', analyze: true [cols="1,2a"] |
