Skip to content

Commit

Permalink
resolves #1164 add support for default theme alignment for tables
Browse files Browse the repository at this point in the history
  • Loading branch information
habamax authored and mojavelinux committed Jul 20, 2019
1 parent 4642974 commit 1390e35
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
* allow theme to control background and border of inline kbd (#313, #1004)
* add support for link on image in running content (#1002)
* allow theme to disable font kerning
* add support for default theme alignment for tables (#1164)

== 1.5.0.beta.1 (2019-07-08) - @mojavelinux

Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ def convert_table node
(alignment = (node.roles & BlockAlignmentNames)[-1])
alignment = alignment.to_sym
else
alignment = :left
alignment = (theme.table_align || :left).to_sym
end

caption_side = (theme.table_caption_side || :top).to_sym
Expand Down
25 changes: 25 additions & 0 deletions spec/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -497,4 +497,29 @@
(expect caption_texts.map {|it| it[:x] }.uniq).to have_size 1
end
end

context 'Table alignment' do
it 'should allow theme to customize default alignment of table ' do
pdf = to_pdf <<~'EOS', pdf_theme: { table_align: 'right' }, analyze: true
[cols=3*,width=50%]
|===
|RIGHT |B1 |C1
|A2 |B2 |C2
|A3 |B3 |C3
|===
[cols=3*,width=50%,align=left]
|===
|LEFT |B1 |C1
|A2 |B2 |C2
|A3 |B3 |C3
|===
EOS

cell_right = (pdf.find_text 'RIGHT')[0]
cell_left = (pdf.find_text 'LEFT')[0]

(expect cell_right[:x]).to be > cell_left[:x]
end
end
end

0 comments on commit 1390e35

Please sign in to comment.