diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2020-02-10 01:47:36 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2020-02-10 01:49:53 -0700 |
| commit | 74a5ebb28d6cac5bbf5f1f42e1b448448dc5bd50 (patch) | |
| tree | 923d596dacd550b25ba6aef061ea2294fda54e69 | |
| parent | 9d24a34fe82fa218d6a68289bba677872c3c2a41 (diff) | |
render pass block as listing block, using raw source as contents
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 8 | ||||
| -rw-r--r-- | spec/listing_spec.rb | 12 | ||||
| -rw-r--r-- | spec/pass_spec.rb | 30 |
4 files changed, 39 insertions, 12 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 2e29ccb0..56835fbb 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,6 +14,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[ * allow running content image to be specified using a data URI * support creating empty front or back cover by assigning empty value to front-cover-image or back-cover-image attribute * only warn once per missing character (#1545) +* render pass block as listing block, using raw source as contents == 1.5.0.rc.3 (2020-02-04) - @mojavelinux diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index a47ebd62..fd4dcd35 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -1787,6 +1787,14 @@ module Asciidoctor alias convert_listing convert_listing_or_literal alias convert_literal convert_listing_or_literal + + def convert_pass node + node = node.dup + (subs = node.subs.dup).unshift :specialcharacters + node.instance_variable_set :@subs, subs.uniq + convert_listing_or_literal node + end + alias convert_stem convert_listing_or_literal # Extract callout marks from string, indexed by 0-based line number diff --git a/spec/listing_spec.rb b/spec/listing_spec.rb index c1611ce6..a819e42f 100644 --- a/spec/listing_spec.rb +++ b/spec/listing_spec.rb @@ -205,16 +205,4 @@ describe 'Asciidoctor::PDF::Converter - Listing' do bold_text = (pdf.find_text '99')[0] (expect bold_text[:font_name]).to eql 'mplus1mn-bold' end - - it 'should render stem as literal block if stem extension not present' do - pdf = to_pdf <<~'EOS', analyze: true - [stem] - ++++ - sig = enc(H(D), s) - ++++ - EOS - - equation_text = (pdf.find_text 'sig = enc(H(D), s)')[0] - (expect equation_text[:font_name]).to eql 'mplus1mn-regular' - end end diff --git a/spec/pass_spec.rb b/spec/pass_spec.rb new file mode 100644 index 00000000..d1b5e975 --- /dev/null +++ b/spec/pass_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require_relative 'spec_helper' + +describe 'Asciidoctor::PDF::Converter - Pass' do + it 'should render pass as literal block' do + pdf = to_pdf <<~'EOS', analyze: true + ++++ + <p>This is a pass block.</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' + end + + it 'should render stem as literal block if stem extension not present' do + pdf = to_pdf <<~'EOS', analyze: true + [stem] + ++++ + sig = enc(H(D), s) + ++++ + EOS + + equation_text = (pdf.find_text 'sig = enc(H(D), s)')[0] + (expect equation_text[:font_name]).to eql 'mplus1mn-regular' + end +end |
