summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor-pdf/converter.rb1
-rw-r--r--spec/reference/table-cellbgcolor-override.pdfbin0 -> 11818 bytes
-rw-r--r--spec/reference/table-cellbgcolor.pdfbin0 -> 11818 bytes
-rw-r--r--spec/table_spec.rb30
5 files changed, 32 insertions, 0 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 2b76fa3e..4fc8703d 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -12,6 +12,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
* allow multiple font dirs to be specified (#80)
* allow theme to specifiy initial zoom (#305)
* allow attribute references to be used in image paths in theme (#588)
+* honor the cellbgcolor attribute defined in a table cell to set the cell background color (#234) (*mch*)
* add the .notdef glyph to the bundled fonts (a box which is used as the default glyph if the font is missing a character) (#1194)
* don't drop headings if base font family is not set in theme
* don't crash if heading margins are not set in theme
diff --git a/lib/asciidoctor-pdf/converter.rb b/lib/asciidoctor-pdf/converter.rb
index 341f6919..67966227 100644
--- a/lib/asciidoctor-pdf/converter.rb
+++ b/lib/asciidoctor-pdf/converter.rb
@@ -1975,6 +1975,7 @@ class Converter < ::Prawn::Document
cell_data[:inline_format] = [normalize: true]
end
end
+ cell_data[:background_color] = (node.document.attr 'cellbgcolor')[1..-1] if node.document.attr? 'cellbgcolor'
row_data << cell_data
end
table_data << row_data
diff --git a/spec/reference/table-cellbgcolor-override.pdf b/spec/reference/table-cellbgcolor-override.pdf
new file mode 100644
index 00000000..5c19db16
--- /dev/null
+++ b/spec/reference/table-cellbgcolor-override.pdf
Binary files differ
diff --git a/spec/reference/table-cellbgcolor.pdf b/spec/reference/table-cellbgcolor.pdf
new file mode 100644
index 00000000..f471ea90
--- /dev/null
+++ b/spec/reference/table-cellbgcolor.pdf
Binary files differ
diff --git a/spec/table_spec.rb b/spec/table_spec.rb
index e85e6794..d26d3b68 100644
--- a/spec/table_spec.rb
+++ b/spec/table_spec.rb
@@ -142,6 +142,36 @@ describe 'Asciidoctor::PDF::Converter - Table' do
(expect line[:color]).to eql '00000000'
end
end
+
+ it 'should honor cellbgcolor attribute in table cell to set background color of cell', integration: true do
+ to_file = to_pdf_file <<~'EOS', 'table-cellbgcolor.pdf'
+ :attribute-undefined: drop
+
+ [%autowidth,cols=3*]
+ |===
+ | default background color
+ | {set:cellbgcolor:#FF0000}red background color
+ | {set:cellbgcolor!}default background color again
+ |===
+ EOS
+
+ (expect to_file).to visually_match 'table-cellbgcolor.pdf'
+ end
+
+ it 'should use value of cellbgcolor attribute in table cell to override background color set by theme', integration: true do
+ to_file = to_pdf_file <<~'EOS','table-cellbgcolor-override.pdf', pdf_theme: { table_body_background_color: 'CCCCCC' }
+ :attribute-undefined: drop
+
+ [%autowidth,cols=3*]
+ |===
+ | default background color
+ | {set:cellbgcolor:#FF0000}red background color
+ | {set:cellbgcolor!}default background color again
+ |===
+ EOS
+
+ (expect to_file).to visually_match 'table-cellbgcolor-override.pdf'
+ end
end
context 'Dimensions' do