diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-10-27 03:21:51 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-27 03:21:51 -0600 |
| commit | 18345df420311b9a8d00c30a3d3aede21e189d3e (patch) | |
| tree | 8571de0fbfb72cb9a2bab11a91a9a90d72ea2fe9 | |
| parent | 6e7340348914f622607c9bf829c18f91e3313dca (diff) | |
resolves #2363 replace use of AbstractBlock#role= method to ensure compatbility with Asciidoctor 2.0.10 (PR #2364)
| -rw-r--r-- | .github/workflows/ci.yml | 22 | ||||
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | README.adoc | 5 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 2 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/ext/asciidoctor/document.rb | 2 | ||||
| -rw-r--r-- | spec/footnote_spec.rb | 44 | ||||
| -rw-r--r-- | spec/section_spec.rb | 2 | ||||
| -rw-r--r-- | spec/source_spec.rb | 4 |
8 files changed, 56 insertions, 26 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50e5468d..ccb6a310 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,9 +46,10 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] ruby: [jruby-9.3.7.0, '2.7', '3.1'] - rouge-version: [~] + asciidoctor-version: [~] asciidoctor-diagram-version: ['~> 2.2'] asciidoctor-kroki-version: [~] + rouge-version: [~] upstream: [~] exclude: # remove 3.1 on ubuntu-latest to mark as primary @@ -61,17 +62,18 @@ jobs: ruby: '3.0' - os: macos-latest ruby: '3.1' - # NOTE: enable once Asciidoctor 2.1.0 is released - #- os: ubuntu-latest - # ruby: '2.7' - # asciidoctor-version: '~> 2.0.0' - os: ubuntu-latest ruby: '2.7' + asciidoctor-version: '2.0.10' rouge-version: '~> 2.0.0' - os: windows-latest ruby: '3.1' asciidoctor-diagram-version: ~ asciidoctor-kroki-version: '0.5.0' + # NOTE: enable once Asciidoctor 2.1.0 is released + #- os: ubuntu-latest + # ruby: '3.1' + # asciidoctor-version: '~> 2.0.0' - os: ubuntu-latest ruby: '3.1' upstream: upstream @@ -128,9 +130,10 @@ jobs: if: matrix.primary run: | echo 'FFI_ICU_VERSION=0.4.3' >> $GITHUB_ENV - - name: Set Rouge version - if: matrix.rouge-version - run: echo 'ROUGE_VERSION=${{ matrix.rouge-version }}' >> $GITHUB_ENV + - name: Set Asciidoctor version + if: matrix.asciidoctor-version + run: | + echo 'ASCIIDOCTOR_VERSION=${{ matrix.asciidoctor-version }}' >> $GITHUB_ENV - name: Set Asciidoctor Diagram version if: matrix.asciidoctor-diagram-version run: | @@ -139,6 +142,9 @@ jobs: if: matrix.asciidoctor-kroki-version run: | echo 'ASCIIDOCTOR_KROKI_VERSION=${{ matrix.asciidoctor-kroki-version }}' >> $GITHUB_ENV + - name: Set Rouge version + if: matrix.rouge-version + run: echo 'ROUGE_VERSION=${{ matrix.rouge-version }}' >> $GITHUB_ENV - name: Install dependencies run: bundle --jobs 3 --retry 3 - name: Switch to upstream dependencies diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6b403054..fb19c540 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -43,6 +43,7 @@ Bug Fixes:: * only load Treetop runtime so it does not overload `require` method * fix collation order of index terms that differ only in case * don't crash if page background image value is empty (interpret as "none") +* replace use of AbstractNode#role= method to ensure compatiblity with minimum supported version of Asciidoctor (Asciidoctor 2.0.10) (#2363) == 2.3.3 (2022-10-21) - @mojavelinux diff --git a/README.adoc b/README.adoc index 0293cfd2..3cedcb56 100644 --- a/README.adoc +++ b/README.adoc @@ -67,7 +67,8 @@ TIP: For the latest Asciidoctor PDF features and fixes, see {url-project-docs}/w == Prerequisites -Asciidoctor PDF is a Ruby application. +Asciidoctor PDF is built on Asciidoctor. +Like Asciidoctor, Asciidoctor PDF is a Ruby application. Therefore, to use it, you'll need a Ruby runtime. The supported Ruby runtimes are Ruby 2.7 or greater and JRuby 9.2 or greater. @@ -92,6 +93,8 @@ Pass the name of the gem to the `gem install` command as follows: Installing Asciidoctor PDF will install a number of other gems mentioned in these docs, including asciidoctor, prawn, prawn-svg, prawn-table, prawn-icon, and ttfunk. For the most part, the versions of these dependencies are locked to the version of Asciidoctor PDF. +The patch versions are allowed to vary. +Please note that the minimum supported version of the asciidoctor gem (Asciidoctor) is 2.0.10. For further installation information about installing Asciidoctor PDF, see {url-project-docs}/install/[the installation documentation]. For troubleshooting help, see {url-project-docs}/install/#installation-troubleshooting[Installation troubleshooting]. diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 6fecd738..0a73a915 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -771,7 +771,7 @@ module Asciidoctor def convert_preamble node # FIXME: core should not be promoting paragraph to preamble if there are no sections if (first_block = node.first_child)&.context == :paragraph && node.document.sections? && !first_block.role? - first_block.role = 'lead' + first_block.set_attr 'role', 'lead' end traverse node theme_margin :block, :bottom, (next_enclosed_block node) diff --git a/lib/asciidoctor/pdf/ext/asciidoctor/document.rb b/lib/asciidoctor/pdf/ext/asciidoctor/document.rb index 4eff49dc..88fdcef9 100644 --- a/lib/asciidoctor/pdf/ext/asciidoctor/document.rb +++ b/lib/asciidoctor/pdf/ext/asciidoctor/document.rb @@ -13,7 +13,7 @@ class Asciidoctor::Document preface.id = preface.generate_id if (first_child = blk0.blocks[0])&.option? 'notitle' preface.set_option 'notitle' - first_child.role = 'lead' if first_child.context == :paragraph && !first_child.role? + first_child.set_attr 'role', 'lead' if first_child.context == :paragraph && !first_child.role? end preface.blocks.replace (blk0.blocks.map do |b| b.parent = preface diff --git a/spec/footnote_spec.rb b/spec/footnote_spec.rb index ac5f5139..4e959055 100644 --- a/spec/footnote_spec.rb +++ b/spec/footnote_spec.rb @@ -258,14 +258,24 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do Another audacious statement.{fn-disclaimer} EOS - expected_lines = <<~'EOS'.lines.map(&:chomp) - A bold statement.[1] - Another audacious statement.[1] - 1. Opinions are my own. - EOS + if (Gem::Version.new Asciidoctor::VERSION) < (Gem::Version.new '2.0.11') + expected_lines = <<~'EOS'.lines.map(&:chomp) + A bold statement.[1] + Another audacious statement.[2] + 1. Opinions are my own. + 2. Opinions are my own. + EOS + footnote_text = (pdf.find_text %r/Opinions/)[-1] + else + expected_lines = <<~'EOS'.lines.map(&:chomp) + A bold statement.[1] + Another audacious statement.[1] + 1. Opinions are my own. + EOS + footnote_text = pdf.find_unique_text %r/Opinions/ + end (expect pdf.lines).to eql expected_lines - footnote_text = pdf.find_unique_text %r/Opinions/ (expect footnote_text[:y]).to be < 60 end @@ -346,14 +356,24 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do You can download patches from the product page.{fn-disclaimer} EOS - expected_lines = <<~'EOS'.lines.map(&:chomp) - You will receive notifications of all product updates.[1] - You can download patches from the product page.[1] - 1. Only available if you have an active subscription. - EOS + if (Gem::Version.new Asciidoctor::VERSION) < (Gem::Version.new '2.0.11') + expected_lines = <<~'EOS'.lines.map(&:chomp) + You will receive notifications of all product updates.[1] + You can download patches from the product page.[2] + 1. Only available if you have an active subscription. + 2. Only available if you have an active subscription. + EOS + active_text = (pdf.find_text 'active')[-1] + else + expected_lines = <<~'EOS'.lines.map(&:chomp) + You will receive notifications of all product updates.[1] + You can download patches from the product page.[1] + 1. Only available if you have an active subscription. + EOS + active_text = pdf.find_unique_text 'active' + end (expect pdf.lines).to eql expected_lines - active_text = pdf.find_unique_text 'active' (expect active_text[:font_name]).to eql 'NotoSerif-Italic' end diff --git a/spec/section_spec.rb b/spec/section_spec.rb index 1cb192b4..6df058f8 100644 --- a/spec/section_spec.rb +++ b/spec/section_spec.rb @@ -1087,7 +1087,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do pdf = to_pdf input, analyze: true (expect pdf.find_unique_text 'Preface', page_number: 2).not_to be_nil (expect pdf.find_unique_text 'Preface', page_number: 3).to be_nil - # NOTE: lead role on first paragraph is retained + # NOTE: test that lead role on first paragraph is retained (expect (pdf.find_unique_text 'anonymous preface', page_number: 3)[:font_size]).to eql 13 end diff --git a/spec/source_spec.rb b/spec/source_spec.rb index 22cf7a42..9fbce6b5 100644 --- a/spec/source_spec.rb +++ b/spec/source_spec.rb @@ -1032,14 +1032,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do [,ruby,subs="+quotes,+macros"] ---- - require 'https://asciidoctor.org[asciidoctor]' + require %(https://asciidoctor.org[asciidoctor]) Asciidoctor._convert_file_ 'README.adoc', *safe: :safe* ---- EOS lines = pdf.lines pdf.text - (expect lines).to eql [%(require 'asciidoctor'), %(Asciidoctor.convert_file 'README.adoc', safe: :safe)] + (expect lines).to eql ['require %(asciidoctor)', %(Asciidoctor.convert_file 'README.adoc', safe: :safe)] require_text = pdf.find_unique_text 'require' (expect require_text[:font_color]).not_to eql '333333' end |
