summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-14 12:28:21 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-05-14 12:38:43 -0600
commit508ab3f5f2062fb856626ebfd6a6ec5d57b25b52 (patch)
tree0b1a8687adbe9b3ba95d023d8fda0afbf2b27c33
parent498aef00f4cfd1d8bc83d8618fd7d6ac77c31179 (diff)
reify convert handler for pass blocks and remove block decoration
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor/pdf/converter.rb7
-rw-r--r--spec/pass_spec.rb26
3 files changed, 23 insertions, 11 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 18425e58..f8af50fb 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -21,6 +21,7 @@ Improvements::
* configure spacing around thematic break using `thematic-break-padding` key instead of margin top and bottom (#2164)
* rename `convert_listing_or_literal` to `convert_code` and alias old name
* reify convert handler for STEM blocks (`convert_stem`)
+* reify convert handler for pass blocks (`convert_pass`) and remove block decoration
Bug Fixes::
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb
index d2c9f6ae..cf68f4dc 100644
--- a/lib/asciidoctor/pdf/converter.rb
+++ b/lib/asciidoctor/pdf/converter.rb
@@ -1912,9 +1912,10 @@ module Asciidoctor
alias convert_listing_or_literal convert_code
def convert_pass node
- node.instance_variable_set :@subs, ([:specialcharacters] + (prev_subs = node.subs)).uniq
- convert_code node
- node.instance_variable_set :@subs, prev_subs
+ theme_font :code do
+ typeset_formatted_text [text: (guard_indentation node.content), color: @theme.base_font_color], (calc_line_metrics @base_line_height)
+ end
+ theme_margin :block, :bottom, (next_enclosed_block node)
end
def convert_stem node
diff --git a/spec/pass_spec.rb b/spec/pass_spec.rb
index 02a14a1a..5e3a8416 100644
--- a/spec/pass_spec.rb
+++ b/spec/pass_spec.rb
@@ -3,21 +3,31 @@
require_relative 'spec_helper'
describe 'Asciidoctor::PDF::Converter - Pass' do
- it 'should render pass as code block' do
- pdf = to_pdf <<~'EOS', analyze: true
+ it 'should render pass as plain literal block' do
+ pdf = to_pdf <<~'EOS', pdf_theme: { base_font_color: '222222', code_font_color: '0000EE' }, analyze: true
++++
- <p>This is a pass block.</p>
+ <p>
+ stay
+ calm
+ and
+ <strong>pass</strong>
+ through
+ </p>
++++
EOS
- (expect pdf.text).to have_size 1
- text = pdf.text[0]
- (expect text[:string]).to eql '<p>This is a pass block.</p>'
- (expect text[:font_name]).to eql 'mplus1mn-regular'
+ all_text = pdf.text
+ (expect all_text.size).to be > 1
+ all_text.each do |text|
+ (expect text[:font_color]).to eql '222222'
+ (expect text[:font_name]).to eql 'mplus1mn-regular'
+ end
+ (expect all_text[0][:string]).to eql '<p>'
+ (expect all_text[4][:string]).to eql %(\u00a0 <strong>pass</strong>)
end
it 'should add bottom margin to pass block' do
- pdf = to_pdf <<~'EOS', pdf_theme: { code_padding: 0 }, analyze: true
+ pdf = to_pdf <<~'EOS', analyze: true
++++
This is a pass block.
++++