Skip to content

Commit 59ca39b

Browse files
authored
Handle "width" in tables in direct_html (#1540)
Docbook handles `[width=50%]` on tables by adding the width to the `<table>` tag. So we should too, just to be even.
1 parent 8883d1c commit 59ca39b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

resources/asciidoctor/lib/docbook_compat/convert_table.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def convert_table_tag(node)
3838
'<table',
3939
' border="1" cellpadding="4px"',
4040
node.title ? %( summary="#{node.title}") : nil,
41+
(width = node.attr 'width') ? %( width="#{width}") : nil,
4142
'>',
4243
].compact.join
4344
end

resources/asciidoctor/spec/docbook_compat_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,5 +1723,20 @@ def expect_admonition(body)
17231723
HTML
17241724
end
17251725
end
1726+
context 'with width' do
1727+
let(:input) do
1728+
<<~ASCIIDOC
1729+
[width=50%]
1730+
|===
1731+
|Col 1 | Col 2
1732+
|===
1733+
ASCIIDOC
1734+
end
1735+
it 'has the width' do
1736+
expect(converted).to include <<~HTML
1737+
<table border="1" cellpadding="4px" width="50%">
1738+
HTML
1739+
end
1740+
end
17261741
end
17271742
end

0 commit comments

Comments
 (0)