summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-26 23:47:58 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-05-27 13:38:11 -0600
commita340ee35cf82c743bbb97fff51c91fcb61682a46 (patch)
tree19f18606c8257445ad2aed7cf57048ccb22681c0
parent4f227ee25a3d5aaed919cd1dbe95e0d9c04b82b0 (diff)
don't crash if inline role defines border width but not border color
-rw-r--r--CHANGELOG.adoc6
-rw-r--r--lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb3
-rw-r--r--spec/formatted_text_formatter_spec.rb10
3 files changed, 17 insertions, 2 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 6c620e26..30a864b7 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -5,6 +5,12 @@
This document provides a high-level view of the changes to the {project-name} by release.
For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
+== Unreleased
+
+Bug Fixes::
+
+* don't crash if inline role defines border width but not border color
+
== 2.0.5 (2022-05-26) - @mojavelinux
Bug Fixes::
diff --git a/lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb b/lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb
index 82a2f579..b0357ee3 100644
--- a/lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb
+++ b/lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb
@@ -36,8 +36,7 @@ module Asciidoctor::PDF::FormattedText
end
pdf.fill_color prev_fill_color
end
- if (border_width = data[:border_width])
- border_color = data[:border_color]
+ if (border_width = data[:border_width]) && (border_color = data[:border_color])
prev_stroke_color = pdf.stroke_color
prev_line_width = pdf.line_width
pdf.stroke_color border_color
diff --git a/spec/formatted_text_formatter_spec.rb b/spec/formatted_text_formatter_spec.rb
index 7712c042..07d0754c 100644
--- a/spec/formatted_text_formatter_spec.rb
+++ b/spec/formatted_text_formatter_spec.rb
@@ -1034,6 +1034,16 @@ describe Asciidoctor::PDF::FormattedText::Formatter do
(expect to_file).to visually_match 'text-formatter-inline-role-border.pdf'
end
+ it 'should not crash if role defines background color and border width, but not border color' do
+ pdf_theme = {
+ role_shade_background_color: 'CCCCCC',
+ role_shade_border_width: 1,
+ }
+ input = '1 [.shade]#cup# of beans'
+ rects = (to_pdf input, pdf_theme: pdf_theme, analyze: :rect).rectangles
+ (expect rects).to have_size 1
+ end
+
it 'should support role that sets font color in section title and toc' do
pdf_theme = {
role_red_font_color: 'FF0000',