Skip to content

Commit

Permalink
resolves asciidoctor#2363 replace use of AbstractBlock#role= method t…
Browse files Browse the repository at this point in the history
…o ensure compatbility with Asciidoctor 2.0.10
  • Loading branch information
mojavelinux committed Oct 27, 2022
1 parent b8c5db2 commit 779b7a8
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 27 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,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
Expand All @@ -60,17 +61,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
Expand Down Expand Up @@ -123,9 +125,10 @@ jobs:
run: |
echo 'PRAWN_GMAGICK_VERSION=0.0.9' >> $GITHUB_ENV
brew install GraphicsMagick
- 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: |
Expand All @@ -134,6 +137,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
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co

== Unreleased

_No changes since previous release._
Bug Fixes::

* remove 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

Expand Down
5 changes: 4 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,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.
Expand All @@ -93,6 +94,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].
Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ def convert_index_term term, pagenum_sequence_style = nil
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)
Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/pdf/ext/asciidoctor/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def promote_preface_block
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
Expand Down
44 changes: 32 additions & 12 deletions spec/footnote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,24 @@
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

Expand Down Expand Up @@ -347,14 +357,24 @@
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

Expand Down
2 changes: 1 addition & 1 deletion spec/section_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@
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

Expand Down
4 changes: 2 additions & 2 deletions spec/source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1032,14 +1032,14 @@ class Type; end
[,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
Expand Down

0 comments on commit 779b7a8

Please sign in to comment.