diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-10-29 23:57:32 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2022-10-30 00:48:38 -0600 |
| commit | 6a10b70be201a98ffd3d2fb99e5f8ef237ace3d2 (patch) | |
| tree | 827cfa88ac94bd5e590c5d6f89444e889e404e4b | |
| parent | 22b98c054c940d10f5eef8db03169ac0fa5823b7 (diff) | |
switch from EOS to END as heredoc delimiter
54 files changed, 3853 insertions, 3851 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 6fc73943..ee14bfa1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -193,7 +193,9 @@ Naming/ConstantName: Naming/FileName: Enabled: false # reason: needed to conform to Prawn ecosystem Naming/HeredocDelimiterNaming: - Enabled: false # reason: EOS is meaningful + Enabled: true + ForbiddenDelimiters: + - !ruby/regexp '/^\s*EO[A-Z]\s*$/' Naming/InclusiveLanguage: Enabled: true Naming/MethodParameterName: diff --git a/cops/to_pdf_no_debug.rb b/cops/to_pdf_no_debug.rb index 7b7a1408..01f60402 100644 --- a/cops/to_pdf_no_debug.rb +++ b/cops/to_pdf_no_debug.rb @@ -4,9 +4,9 @@ module RuboCop module Cop module RSpec class ToPDFNoDebug < Base - def_node_matcher :to_pdf_with_debug?, <<~'EOS' + def_node_matcher :to_pdf_with_debug?, <<~'END' (send nil? :to_pdf <(dstr ...) (hash ... (pair (sym :debug) (true)))>) - EOS + END MSG = 'debug flag not permitted' RESTRICT_ON_SEND = [:to_pdf] diff --git a/lib/asciidoctor/pdf/pdfmark.rb b/lib/asciidoctor/pdf/pdfmark.rb index 13d74243..2940e3b3 100644 --- a/lib/asciidoctor/pdf/pdfmark.rb +++ b/lib/asciidoctor/pdf/pdfmark.rb @@ -25,7 +25,7 @@ module Asciidoctor author = sanitize doc.attr 'author' end # see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdfmark_reference.pdf - <<~EOS + <<~END [ /Title #{(sanitize doc.header? ? doc.doctitle : (doc.attr 'untitled-label')).to_pdf_object} /Author #{author.to_pdf_object} /Subject #{((doc.attr? 'subject') ? (sanitize doc.attr 'subject') : nil).to_pdf_object} @@ -35,7 +35,7 @@ module Asciidoctor /Creator (Asciidoctor PDF #{::Asciidoctor::PDF::VERSION}, based on Prawn #{::Prawn::VERSION}) /Producer #{((doc.attr? 'publisher') ? (sanitize doc.attr 'publisher') : nil).to_pdf_object} /DOCINFO pdfmark - EOS + END end def generate_file pdf_file diff --git a/spec/abstract_spec.rb b/spec/abstract_spec.rb index efffcabb..2484d585 100644 --- a/spec/abstract_spec.rb +++ b/spec/abstract_spec.rb @@ -4,10 +4,10 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Abstract' do it 'should convert document with only abstract' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [abstract] This article is hot air. - EOS + END abstract_text = (pdf.find_text 'This article is hot air.')[0] (expect abstract_text).not_to be_nil @@ -15,7 +15,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should outdent abstract title and body' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36, abstract_title_text_align: :left }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36, abstract_title_text_align: :left }, analyze: true = Document Title :doctype: book @@ -26,7 +26,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Chapter What came to pass. - EOS + END abstract_title_text = (pdf.find_text 'Abstract')[0] (expect abstract_title_text[:x]).to eql 48.24 @@ -37,7 +37,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should indent first line of abstract if prose_text_indent key is set in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { prose_text_indent: 18 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { prose_text_indent: 18 }, analyze: true = Document Title [abstract] @@ -45,7 +45,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do This option is controlled by the prose_text_indent key in the theme. And on it goes. - EOS + END (expect pdf.text[1][:string]).to start_with 'This document' (expect pdf.text[1][:x]).to be > pdf.text[2][:x] @@ -53,7 +53,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should apply inner margin between inner paragraphs in abstract' do - pdf = to_pdf <<~EOS, pdf_theme: { prose_margin_inner: 0 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { prose_margin_inner: 0 }, analyze: true = Document Title [abstract] @@ -62,7 +62,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do -- And on it goes. - EOS + END expected_line_spacing = pdf.text[1][:y] - pdf.text[2][:y] second_paragraph_text = pdf.find_unique_text %r/^Magna / @@ -71,7 +71,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should apply indent to inner paragraphs in abstract when prose_text_indent_inner is set' do - pdf = to_pdf <<~EOS, pdf_theme: { prose_text_indent_inner: 18, prose_margin_inner: 0 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { prose_text_indent_inner: 18, prose_margin_inner: 0 }, analyze: true = Document Title [abstract] @@ -80,7 +80,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do -- And on it goes. - EOS + END text_left_margin = (pdf.find_unique_text 'And on it goes.')[:x] (expect pdf.text[1][:x]).to eql text_left_margin @@ -92,7 +92,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should support non-paragraph blocks inside abstract block' do - input = <<~'EOS' + input = <<~'END' = Document Title [abstract] @@ -105,7 +105,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Intro And so it begins. - EOS + END pdf = to_pdf input, analyze: :line lines = pdf.lines @@ -131,7 +131,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do heading_margin_top: 0, heading_margin_bottom: 12, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title [abstract] @@ -146,7 +146,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section Title Now we are getting to the main event. - EOS + END texts = pdf.text margins = [] @@ -159,7 +159,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should decorate first line of abstract when abstract has multiple lines' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title [abstract] @@ -169,7 +169,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_text_line1 = pdf.find_text 'First line of abstract.' abstract_text_line2 = pdf.find_text 'Second line of abstract.' @@ -182,7 +182,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should decorate first line of first paragraph of abstract with multiple paragraphs' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title [abstract] @@ -196,7 +196,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END first_line_text = pdf.find_unique_text 'First line of abstract.' (expect first_line_text[:font_name]).to end_with '-BoldItalic' @@ -209,7 +209,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do abstract_font_color: 'AA0000', abstract_first_line_text_transform: 'uppercase', } - input = <<~'EOS' + input = <<~'END' = Document Title [abstract] @@ -218,7 +218,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do The text in the first line has been transformed to into uppercase for extra emphasis. This is the main content. - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true first_line_text, second_line_text, third_line_text = pdf.lines pdf.find_text font_color: 'AA0000' @@ -237,22 +237,22 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do it 'should not force justify first line of abstract with text transform if ends with hard break', visual: true do pdf_theme = { abstract_first_line_text_transform: 'uppercase' } - to_file = to_pdf_file <<~'EOS', 'abstract-first-line-text-transform-hard-break.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'abstract-first-line-text-transform-hard-break.pdf', pdf_theme: pdf_theme [abstract] Welcome young Jedi. + This tutorial will show you the way. - EOS + END (expect to_file).to visually_match 'abstract-first-line-text-transform-hard-break.pdf' end it 'should not force justify first line of abstract with text transform if not justified', visual: true do pdf_theme = { abstract_text_align: 'left', abstract_first_line_text_transform: 'uppercase' } - to_file = to_pdf_file <<~'EOS', 'abstract-first-line-text-transform-hard-break-not-justified.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'abstract-first-line-text-transform-hard-break-not-justified.pdf', pdf_theme: pdf_theme [abstract] Welcome young Jedi. + This tutorial will show you the way. - EOS + END (expect to_file).to visually_match 'abstract-first-line-text-transform-hard-break.pdf' end @@ -271,14 +271,14 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do pdf_theme = { abstract_font_color: '0000FF', abstract_first_line_text_transform: 'uppercase' } - input = <<~'EOS' + input = <<~'END' = Document Title [abstract] This *_story_* chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish on their journey to discovering the true power of Open Source. == Section Title - EOS + END pdf = to_pdf input, backend: backend, pdf_theme: pdf_theme, analyze: true lines = pdf.lines (pdf.text.select {|it| it[:font_color] == '0000FF' }) @@ -287,7 +287,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should use base font color if font color is not defined for abstract in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { abstract_font_color: nil, base_font_color: '0000EE' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { abstract_font_color: nil, base_font_color: '0000EE' }, analyze: true = Document Title [abstract] @@ -295,7 +295,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do This is the second line. This is the main content. - EOS + END abstract_first_line_text, abstract_second_line_text = pdf.find_text font_size: 13 main_text = pdf.find_unique_text 'This is the main content.' @@ -304,7 +304,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should set font color on first line of abstract if specified in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { abstract_font_color: '444444', abstract_first_line_font_color: 'AA0000' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { abstract_font_color: '444444', abstract_first_line_font_color: 'AA0000' }, analyze: true = Document Title [abstract] @@ -314,7 +314,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_texts = pdf.find_text %r/line of abstract/ (expect abstract_texts).to have_size 2 @@ -324,7 +324,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should not style first line of abstract if theme sets font style to normal' do - pdf = to_pdf <<~'EOS', pdf_theme: { abstract_first_line_font_style: 'normal' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { abstract_first_line_font_style: 'normal' }, analyze: true = Document Title [abstract] @@ -334,7 +334,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_texts = pdf.find_text %r/line of abstract/ (expect abstract_texts).to have_size 2 @@ -345,7 +345,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do it 'should style first line of abstract if theme sets font style to italic but abstract font style to normal' do pdf_theme = { abstract_font_style: 'normal', abstract_first_line_font_style: 'italic' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title [abstract] @@ -355,7 +355,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_texts = pdf.find_text %r/line of abstract/ (expect abstract_texts).to have_size 2 @@ -366,7 +366,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do it 'should style first line of abstract if theme sets font style to bold but abstract font style to normal' do pdf_theme = { abstract_font_style: 'normal', abstract_first_line_font_style: 'bold' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title [abstract] @@ -376,7 +376,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_texts = pdf.find_text %r/line of abstract/ (expect abstract_texts).to have_size 2 @@ -387,7 +387,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do it 'should style first line in abstract if theme sets font style to normal_italic and abstract font style to bold' do pdf_theme = { abstract_font_style: 'bold', abstract_first_line_font_style: 'normal_italic' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title [abstract] @@ -397,7 +397,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_texts = pdf.find_text %r/line in abstract/ (expect abstract_texts).to have_size 2 @@ -407,14 +407,14 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should allow theme to set text alignment of abstract' do - pdf = to_pdf <<~'EOS', pdf_theme: { abstract_text_align: 'center' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { abstract_text_align: 'center' }, analyze: true = Document Title [abstract] This is the abstract. This is the main content. - EOS + END abstract_text = pdf.find_unique_text 'This is the abstract.' main_text = pdf.find_unique_text 'This is the main content.' @@ -422,14 +422,14 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should not indent first line of abstract if text alignment is center' do - input = <<~'EOS' + input = <<~'END' = Document Title [abstract] abstract This is the main content. - EOS + END expected_x = ((to_pdf input, pdf_theme: { abstract_text_align: 'center' }, analyze: true).find_unique_text 'abstract')[:x] actual_x = ((to_pdf input, pdf_theme: { abstract_text_align: 'center', prose_text_indent: 18 }, analyze: true).find_unique_text 'abstract')[:x] @@ -438,14 +438,14 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should not indent first line of abstract if text alignment is right' do - input = <<~'EOS' + input = <<~'END' = Document Title [abstract] abstract This is the main content. - EOS + END expected_x = ((to_pdf input, pdf_theme: { abstract_text_align: 'right' }, analyze: true).find_unique_text 'abstract')[:x] actual_x = ((to_pdf input, pdf_theme: { abstract_text_align: 'right', prose_text_indent: 18 }, analyze: true).find_unique_text 'abstract')[:x] @@ -454,7 +454,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should allow theme to set text alignment of abstract title' do - pdf = to_pdf <<~'EOS', pdf_theme: { abstract_title_text_align: 'center' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { abstract_title_text_align: 'center' }, analyze: true = Document Title :doctype: book @@ -465,7 +465,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Chapter This is the main content. - EOS + END abstract_text = pdf.find_unique_text 'This is the abstract.' abstract_title_text = pdf.find_unique_text 'Abstract' @@ -473,7 +473,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should use base text align to align abstract title if theme does not specify alignment' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_text_align: 'center', abstract_title_text_align: nil }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_text_align: 'center', abstract_title_text_align: nil }, analyze: true = Document Title :doctype: book @@ -485,7 +485,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do [.text-left] This is the main content. - EOS + END abstract_title_text = pdf.find_unique_text 'Abstract' main_text = pdf.find_unique_text 'This is the main content.' @@ -493,7 +493,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should use consistent spacing between lines in abstract when theme uses AFM font' do - pdf = to_pdf <<~'EOS', pdf_theme: { extends: 'base', abstract_first_line_font_color: 'AA0000' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { extends: 'base', abstract_first_line_font_color: 'AA0000' }, analyze: true = Document Title [abstract] @@ -504,7 +504,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_text_line1 = (pdf.find_text 'First line of abstract.')[0] abstract_text_line2 = (pdf.find_text 'Second line of abstract.')[0] @@ -516,7 +516,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should decorate first line of abstract when abstract has single line' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title [abstract] @@ -525,7 +525,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_text = pdf.find_text 'First and only line of abstract.' (expect abstract_text).to have_size 1 @@ -535,7 +535,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should be able to disable first line decoration on abstract using theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { abstract_first_line_font_style: nil }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { abstract_first_line_font_style: nil }, analyze: true = Document Title [abstract] @@ -544,7 +544,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END abstract_text = pdf.find_text 'First and only line of abstract.' (expect abstract_text).to have_size 1 @@ -552,7 +552,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should honor text alignment role on abstract paragraph' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title [abstract.text-right] @@ -561,7 +561,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END halfway_point = (pdf.page 1)[:size][0] * 0.5 abstract_text = pdf.find_text 'Enter stage right.' @@ -570,7 +570,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should honor text alignment role on nested abstract paragraph' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title [abstract] @@ -584,7 +584,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END halfway_point = (pdf.page 1)[:size][0] * 0.5 abstract_text1 = pdf.find_text 'Enter stage right.' @@ -596,7 +596,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should apply same line height to all paragraphs in abstract' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title [abstract] @@ -611,7 +611,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section content - EOS + END p1_l1_text = (pdf.find_text 'paragraph 1, line 1')[0] p1_l2_text = (pdf.find_text 'paragraph 1, line 2')[0] @@ -630,7 +630,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do heading_margin_top: 0, heading_margin_bottom: 12, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title [abstract] @@ -643,7 +643,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do == Section Title Now we are getting to the main event. - EOS + END texts = pdf.text margins = [] @@ -656,14 +656,14 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should support padding around block' do - pdf = to_pdf <<~'EOS', pdf_theme: { abstract_padding: 72 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { abstract_padding: 72 }, analyze: true = Article Title [abstract] This is the abstract. This is the opening paragraph. - EOS + END doctitle_text = pdf.find_unique_text 'Article Title' abstract_text = pdf.find_unique_text 'This is the abstract.' @@ -674,7 +674,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do end it 'should collapse bottom padding if simple abstract will fit on current page' do - pdf = to_pdf <<~EOS, pdf_theme: { abstract_padding: 72 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { abstract_padding: 72 }, analyze: true = Article Title [abstract] @@ -683,13 +683,13 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do #{lorem_ipsum '1-line'} And so it goes. - EOS + END (expect (pdf.find_text page_number: 2)[0][:string]).to eql 'And so it goes.' end it 'should collapse bottom padding if compound abstract will fit on current page' do - pdf = to_pdf <<~EOS, pdf_theme: { abstract_padding: 72 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { abstract_padding: 72 }, analyze: true = Article Title [abstract] @@ -700,7 +700,7 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do -- And so it goes. - EOS + END (expect (pdf.find_text page_number: 2)[0][:string]).to eql 'And so it goes.' end diff --git a/spec/admonition_spec.rb b/spec/admonition_spec.rb index 86f46ebc..fd4aea39 100644 --- a/spec/admonition_spec.rb +++ b/spec/admonition_spec.rb @@ -4,28 +4,28 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should advance unbreakable block shorter than page to next page to avoid splitting it' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['paragraph'] * 20).join %(\n\n)} [NOTE%unbreakable] ==== #{(['admonition'] * 20).join %(\n\n)} ==== - EOS + END admon_page_numbers = (pdf.find_text 'admonition').map {|it| it[:page_number] }.uniq (expect admon_page_numbers).to eql [2] end it 'should place anchor directly at top of block' do - input = <<~EOS + input = <<~END paragraph [NOTE#admon-1] ==== filler ==== - EOS + END lines = (to_pdf input, analyze: :line).lines pdf = to_pdf input @@ -36,14 +36,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should offset anchor from top of block by amount of block_anchor_top' do pdf_theme = { block_anchor_top: -12 } - input = <<~EOS + input = <<~END paragraph [NOTE#admon-1] ==== filler ==== - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines pdf = to_pdf input, pdf_theme: pdf_theme @@ -52,14 +52,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should keep anchor with block if block is advanced to next page' do - input = <<~EOS + input = <<~END paragraph [NOTE#admon-1%unbreakable] ==== #{(['filler'] * 27).join %(\n\n)} ==== - EOS + END lines = (to_pdf input, analyze: :line).lines pdf = to_pdf input @@ -69,12 +69,12 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should vertically center label on first page if block is split across pages' do - pdf = to_pdf <<~EOS, pdf_theme: { page_margin: '0.5in' }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { page_margin: '0.5in' }, analyze: true [NOTE] ==== #{(['admonition'] * 40).join %(\n\n)} ==== - EOS + END (expect pdf.pages).to have_size 2 page_height = (get_page_size pdf)[1] @@ -84,12 +84,12 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should draw vertical rule on all pages if block is split across pages' do - pdf = to_pdf <<~EOS, pdf_theme: { page_margin: '0.5in' }, analyze: :line + pdf = to_pdf <<~END, pdf_theme: { page_margin: '0.5in' }, analyze: :line [NOTE] ==== #{(['admonition'] * 40).join %(\n\n)} ==== - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -106,7 +106,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_rule_color: 'FFFFFF', } - to_file = to_pdf_file <<~EOS, 'admonition-page-split.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'admonition-page-split.pdf', pdf_theme: pdf_theme before [NOTE] @@ -115,7 +115,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== after - EOS + END (expect to_file).to visually_match 'admonition-page-split.pdf' end @@ -127,7 +127,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_column_rule_width: 0, } pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] [NOTE] @@ -135,7 +135,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do content + that wraps ==== - EOS + END end pages = pdf.pages @@ -146,7 +146,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do (expect last_text_y - pdf_theme[:admonition_padding]).to be > 48.24 pdf = with_content_spacer 10, 692 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] [NOTE] @@ -154,7 +154,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do content + that wraps ==== - EOS + END end pages = pdf.pages @@ -170,23 +170,23 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do pdf_theme = { admonition_caption_font_color: '00AA00', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Admonition title [NOTE] ==== There's something you should know. ==== - EOS + END title_text = (pdf.find_text 'Admonition title')[0] (expect title_text[:font_color]).to eql '00AA00' end it 'should use value of caption attribute as label' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [NOTE,caption=Pro Tip] Use bundler! - EOS + END label_text = pdf.text[0] (expect label_text[:font_name]).to eql 'NotoSerif-Bold' @@ -195,10 +195,10 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should not transform label text if admonition_label_text_transform key is nil, none, or invalid' do [nil, 'none', 'invalid'].each do |transform| - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_text_transform: transform }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_label_text_transform: transform }, analyze: true [NOTE,caption=Pro Tip] Use bundler! - EOS + END label_text = pdf.text[0] (expect label_text[:font_name]).to eql 'NotoSerif-Bold' @@ -208,10 +208,10 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do # TODO: this could use a deeper assertion it 'should compute width of label even when glyph is missing' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [TIP,caption=⏻ Tip] Use bundler! - EOS + END label_text = pdf.text[0] (expect label_text[:font_name]).to eql 'NotoSerif-Bold' @@ -219,10 +219,10 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should resize label text to fit if it overflows available space' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_font_size: 18 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_label_font_size: 18 }, analyze: true [IMPORTANT] Make sure the device is powered off before servicing it. - EOS + END label_text = pdf.find_unique_text 'IMPORTANT' (expect label_text).not_to be_nil @@ -230,10 +230,10 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should allow padding to be specified for label and content using single value' do - input = <<~'EOS' + input = <<~'END' [IMPORTANT] Make sure the device is powered off before servicing it. - EOS + END pdf = to_pdf input, pdf_theme: { admonition_padding: 0, admonition_label_padding: 0 }, analyze: true ref_label_text = pdf.find_unique_text 'IMPORTANT' @@ -248,10 +248,10 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should allow padding to be specified for label and content using array value' do - input = <<~'EOS' + input = <<~'END' [IMPORTANT] Make sure the device is powered off before servicing it. - EOS + END pdf = to_pdf input, pdf_theme: { admonition_padding: 0, admonition_label_padding: 0 }, analyze: true ref_label_text = pdf.find_unique_text 'IMPORTANT' @@ -266,7 +266,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should not move cursor below block if block ends at top of page' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true top of page [NOTE] @@ -277,7 +277,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== top of page - EOS + END top_of_page_texts = pdf.find_text 'top of page' (expect top_of_page_texts).to have_size 2 @@ -285,9 +285,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should not allow prose_margin_bottom to impact padding' do - input = <<~'EOS' + input = <<~'END' NOTE: The prose_margin_bottom value does not impact the padding around the content box. - EOS + END pdf = to_pdf input, pdf_theme: { prose_margin_bottom: 12 }, analyze: :line reference_line = pdf.lines[0] @@ -303,7 +303,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should not increment counter in admonition content more times than expected' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true == Initial value Current number is {counter:my-count:0}. @@ -328,7 +328,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do == Five is expected Current number is {counter:my-count}. - EOS + END expected = (0.upto 5).map {|it| %(Current number is #{it}.) } number_texts = pdf.find_text %r/^Current number is/ @@ -337,9 +337,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do context 'Text' do it 'should show admonition label in bold by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true TIP: Look for the warp zone under the bridge. - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -359,7 +359,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_label_text_align: 'right', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true NOTE: Remember the milk. TIP: Look for the warp zone under the bridge. @@ -369,7 +369,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do WARNING: Beware of dog! IMPORTANT: Sign off before stepping away from the computer. - EOS + END label_texts = pdf.find_text font_name: 'NotoSerif-Bold' label_right_reference = nil @@ -383,7 +383,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should allow theme to control vertical alignment of label' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_vertical_align: 'top' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_label_vertical_align: 'top' }, analyze: true [NOTE] ==== There are lots of things you need to know. @@ -391,7 +391,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do And those things that you don't know that you do not know. This documentation seeks to close the gaps between them. ==== - EOS + END label_text = (pdf.find_text 'NOTE')[0] content_text = (pdf.find_text font_name: 'NotoSerif')[0] @@ -399,12 +399,12 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should resolve character references in label' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_font_color: '000000' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_label_font_color: '000000' }, analyze: true [NOTE,caption=®] ==== Christoph and sons. ==== - EOS + END label_text = (pdf.find_text font_color: '000000')[0] (expect label_text[:string]).to eql ?\u00ae @@ -415,11 +415,11 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do context 'Icon' do it 'should show font-based icon in place of label when icons=font' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font TIP: Look for the warp zone under the bridge. - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -436,7 +436,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should not reduce font size of icon if specified size fits within available space' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_important: { size: 50, scale: 1 } }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_icon_important: { size: 50, scale: 1 } }, analyze: true :icons: font [IMPORTANT] @@ -445,7 +445,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do And when you do that, always do this too! ==== - EOS + END label_text = pdf.find_unique_text ?\uf06a (expect label_text[:font_size]).to eql 50 @@ -457,7 +457,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_label_text_align: 'right', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true :icons: font NOTE: Remember the milk. @@ -469,7 +469,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do WARNING: Beware of dog! IMPORTANT: Sign off before stepping away from the computer. - EOS + END label_texts = pdf.text.select {|it| it[:font_name].start_with? 'FontAwesome' } (expect label_texts[0][:x]).to be > 100 @@ -484,7 +484,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should allow theme to control vertical alignment of icon' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_label_vertical_align: 'top' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_label_vertical_align: 'top' }, analyze: true :icons: font [NOTE] @@ -494,7 +494,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do And those things that you don't know that you do not know. This documentation seeks to close the gaps between them. ==== - EOS + END icon_text = (pdf.find_text ?\uf05a)[0] content_text = (pdf.find_text font_color: '333333')[1] @@ -502,11 +502,11 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should assume icon name with no icon set prefix is a legacy FontAwesome icon name' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_tip: { name: 'smile-wink' } }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_icon_tip: { name: 'smile-wink' } }, analyze: true :icons: font TIP: Time to upgrade your icon set. - EOS + END icon_text = pdf.text[0] (expect icon_text[:font_name]).to eql 'FontAwesome5Free-Solid' @@ -515,11 +515,11 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should be able to use fa- prefix to reference icon in legacy FontAwesome set' do (expect do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_tip: { name: 'fa-smile-wink' } }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_icon_tip: { name: 'fa-smile-wink' } }, analyze: true :icons: font TIP: Time to upgrade your icon set. - EOS + END icon_text = pdf.text[0] (expect icon_text[:font_name]).to eql 'FontAwesome5Free-Solid' @@ -528,11 +528,11 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should allow icon to come from Foundation icon set' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_warning: { name: 'fi-alert' } }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_icon_warning: { name: 'fi-alert' } }, analyze: true :icons: font WARNING: Just don't do it. - EOS + END icon_text = pdf.text[0] (expect icon_text[:font_name]).to eql 'fontcustom' @@ -540,11 +540,11 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should fall back to note icon if icon name cannot be resolved' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_warning: { name: nil } }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_icon_warning: { name: nil } }, analyze: true :icons: font WARNING: If the icon name is nil, the default note icon will be used. - EOS + END icon_text = pdf.text[0] (expect icon_text[:font_name]).to eql 'FontAwesome5Free-Solid' @@ -552,22 +552,22 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should set color of icon to value of stroke_color key specified in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_note: { stroke_color: '00ff00' } }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_icon_note: { stroke_color: '00ff00' } }, analyze: true :icons: font NOTE: This icon is green. - EOS + END icon_text = (pdf.find_text ?\uf05a)[0] (expect icon_text[:font_color]).to eql '00FF00' end it 'should use icon glyph specified in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { admonition_icon_tip: { name: 'far-money-bill-alt' } }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { admonition_icon_tip: { name: 'far-money-bill-alt' } }, analyze: true :icons: font TIP: Look for the warp zone under the bridge. - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -582,7 +582,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should use SVG icon specified by icon attribute when icons attribute is set', visual: true do - to_file = to_pdf_file <<~'EOS', 'admonition-custom-svg-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir } + to_file = to_pdf_file <<~'END', 'admonition-custom-svg-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir } :icons: font :iconsdir: :icontype: svg @@ -591,7 +591,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END (expect to_file).to visually_match 'admonition-custom-svg-icon.pdf' end @@ -604,7 +604,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_column_rule_width: 0, admonition_icon_tip: { width: 24, scale: 1 }, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true :icons: svg :iconsdir: {imagesdir} @@ -617,7 +617,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do [icon=square] TIP: Use the icon attribute to customize the image for an admonition block. - EOS + END expected_icon_x = (pdf.find_unique_text 'right column')[:x] expected_content_x = expected_icon_x + 24 @@ -628,12 +628,12 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should warn if SVG icon specified by icon attribute is missing' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir } + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => fixtures_dir } :icons: font [TIP,icon=missing] Use the icon attribute to customize the image for an admonition block. - EOS + END (expect get_images pdf, 1).to be_empty (expect (pdf.page 1).text).to include 'TIP' end).to log_message severity: :WARN, message: %(admonition icon image not found or not readable: #{fixture_file 'missing.png'}) @@ -641,7 +641,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should warn if SVG icon specified by icon attribute has errors' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: :rect + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: :rect :icons: font :icontype: svg @@ -649,7 +649,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END (expect pdf.rectangles).to have_size 1 # NOTE: width and height of rectangle match what's defined in SVG (expect pdf.rectangles[0][:width]).to eql 200.0 @@ -659,7 +659,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should not warn if SVG icon specified by icon attribute in scratch document has errors' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: :rect + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: :rect :icons: font :icontype: svg @@ -670,7 +670,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do Use the icon attribute to customize the image for an admonition block. ==== -- - EOS + END (expect pdf.rectangles).to have_size 1 # NOTE: width and height of rectangle match what's defined in SVG (expect pdf.rectangles[0][:width]).to eql 200.0 @@ -680,7 +680,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should warn and fall back to admonition label if SVG icon cannot be found' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true :icons: :icontype: svg @@ -688,7 +688,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== The admonition label will be used if the image cannot be resolved. ==== - EOS + END label_text = pdf.find_unique_text 'WARNING' (expect label_text).not_to be_nil (expect label_text[:font_name]).to include 'Bold' @@ -697,7 +697,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should warn and fall back to admonition label if SVG icon specified by icon attribute cannot be embedded' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true :icons: font :icontype: svg @@ -705,7 +705,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END label_text = pdf.find_unique_text 'TIP' (expect label_text).not_to be_nil (expect label_text[:font_name]).to include 'Bold' @@ -714,7 +714,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should resize fallback admonition label to fit in available space if icon fails to embed' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => fixtures_dir }, analyze: true :icons: font :icontype: svg @@ -722,7 +722,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END label_text = pdf.find_unique_text 'WARNING' (expect label_text).not_to be_nil (expect label_text[:font_size]).to be < 10.5 @@ -732,14 +732,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do # NOTE: this test also verifies the text transform is applied as requested by theme it 'should warn and fall back to admonition label if raster icon cannot be found' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, pdf_theme: { admonition_label_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => fixtures_dir }, pdf_theme: { admonition_label_text_transform: 'uppercase' }, analyze: true :icons: [WARNING] ==== The admonition label will be used if the image cannot be resolved. ==== - EOS + END label_text = pdf.find_unique_text 'WARNING' (expect label_text).not_to be_nil (expect label_text[:font_name]).to include 'Bold' @@ -749,14 +749,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do # NOTE: this test also verifies the text transform is not applied if disabled by the theme it 'should warn and fall back to admonition label if raster icon specified by icon attribute cannot be embedded' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => fixtures_dir }, pdf_theme: { admonition_label_text_transform: 'none' }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => fixtures_dir }, pdf_theme: { admonition_label_text_transform: 'none' }, analyze: true :icons: [TIP,icon=corrupt.png] ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END label_text = pdf.find_unique_text 'Tip' (expect label_text).not_to be_nil (expect label_text[:font_name]).to include 'Bold' @@ -765,7 +765,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should embed remote image in icon if allow-uri-read attribute is set', network: true, visual: true do with_svg_with_remote_image do |image_path| - to_file = to_pdf_file <<~EOS, 'admonition-custom-svg-icon-with-remote-image.pdf', attribute_overrides: { 'docdir' => tmp_dir, 'allow-uri-read' => '' } + to_file = to_pdf_file <<~END, 'admonition-custom-svg-icon-with-remote-image.pdf', attribute_overrides: { 'docdir' => tmp_dir, 'allow-uri-read' => '' } :icons: font :iconsdir: @@ -773,7 +773,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== AsciiDoc is awesome! ==== - EOS + END (expect to_file).to visually_match 'admonition-custom-svg-icon-with-remote-image.pdf' end @@ -781,7 +781,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should use original width of SVG icon if height is less than height of admonition block', visual: true do pdf_theme = { admonition_icon_note: { width: 36, scale: 1 } } - to_file = to_pdf_file <<~'EOS', 'admonition-custom-svg-fit.pdf', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir } + to_file = to_pdf_file <<~'END', 'admonition-custom-svg-fit.pdf', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir } :icons: font :iconsdir: @@ -789,13 +789,13 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== When you see this icon, it means there's additional advice about passing tests. ==== - EOS + END (expect to_file).to visually_match 'admonition-custom-svg-fit.pdf' end it 'should use raster icon specified by icon attribute when icons attribute is set', visual: true do - to_file = to_pdf_file <<~'EOS', 'admonition-custom-raster-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir } + to_file = to_pdf_file <<~'END', 'admonition-custom-raster-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir } :icons: font :iconsdir: @@ -803,14 +803,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END (expect to_file).to visually_match 'admonition-custom-raster-icon.pdf' end it 'should allow theme to control width of admonition icon image using width key' do pdf_theme = { admonition_icon_tip: { scale: 0.6, width: 40 } } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image :icons: font :iconsdir: @@ -820,7 +820,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do Use the admonition_label_min_width key to control the image width. ==== - EOS + END images = pdf.images (expect images).to have_size 1 @@ -830,7 +830,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should allow theme to control spacing around admonition icon image using admonition_label_min_width key' do pdf_theme = { admonition_label_min_width: 40, admonition_icon_tip: { scale: 1, width: 24 } } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image :icons: font :iconsdir: @@ -840,7 +840,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do Use the admonition_label_min_width key to control the image width. ==== - EOS + END images = pdf.images (expect images).to have_size 1 @@ -849,7 +849,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should resolve icon when icons attribute is set to image', visual: true do - to_file = to_pdf_file <<~'EOS', 'admonition-image-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir } + to_file = to_pdf_file <<~'END', 'admonition-image-icon.pdf', attribute_overrides: { 'docdir' => fixtures_dir } :icons: image :iconsdir: @@ -857,13 +857,13 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END (expect to_file).to visually_match 'admonition-custom-raster-icon.pdf' end it 'should not unset data-uri attribute when resolving icon image if already unset', visual: true do - doc = Asciidoctor.load <<~'EOS', backend: :pdf, safe: :safe, standalone: true, attributes: { 'docdir' => fixtures_dir, 'nofooter' => '' } + doc = Asciidoctor.load <<~'END', backend: :pdf, safe: :safe, standalone: true, attributes: { 'docdir' => fixtures_dir, 'nofooter' => '' } :icons: image :iconsdir: @@ -871,7 +871,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END (expect doc.converter).not_to be_nil doc.remove_attr 'data-uri' @@ -884,14 +884,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should not resolve remote icon when icons attribute is set to image and allow-uri-read is not set' do with_local_webserver do |base_url| (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'iconsdir' => base_url }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'iconsdir' => base_url }, analyze: true :icons: image [TIP] ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END label_text = pdf.find_unique_text 'TIP' (expect label_text).not_to be_nil @@ -907,14 +907,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do with_local_webserver do |base_url| base_url += '/nada' (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'allow-uri-read' => '', 'iconsdir' => base_url }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'allow-uri-read' => '', 'iconsdir' => base_url }, analyze: true :icons: image [TIP] ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END label_text = pdf.find_unique_text 'TIP' (expect label_text).not_to be_nil @@ -928,14 +928,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should resolve remote icon when icons attribute is set to image and allow-uri-read is set', visual: true do to_file = with_local_webserver do |base_url| - to_pdf_file <<~'EOS', 'admonition-remote-image-icon.pdf', attribute_overrides: { 'allow-uri-read' => '', 'iconsdir' => base_url } + to_pdf_file <<~'END', 'admonition-remote-image-icon.pdf', attribute_overrides: { 'allow-uri-read' => '', 'iconsdir' => base_url } :icons: image [TIP] ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END end (expect to_file).to visually_match 'admonition-custom-raster-icon.pdf' @@ -943,21 +943,21 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should resize icon only if it does not fit within the available space' do pdf_theme = { admonition_icon_tip: { scale: 1 } } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image :icons: image :iconsdir: [TIP] This is Tux. He's the Linux mascot. - EOS + END images = pdf.images (expect images).to have_size 1 (expect images[0][:width]).to be < 36.0 (expect images[0][:height]).to be < 42.3529 - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, attribute_overrides: { 'docdir' => fixtures_dir }, analyze: :image :icons: image :iconsdir: @@ -970,7 +970,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do Thanks to Linux, penguins have receive a lot more attention. Technology can sometimes be a force for good like that. ==== - EOS + END images = pdf.images (expect images).to have_size 1 @@ -980,7 +980,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should warn and fall back to admonition label if image icon cannot be resolved' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'docdir' => fixtures_dir }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'docdir' => fixtures_dir }, analyze: true :icons: image :iconsdir: @@ -988,7 +988,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do ==== Use the icon attribute to customize the image for an admonition block. ==== - EOS + END note_text = pdf.find_unique_text 'NOTE' (expect note_text).not_to be_nil @@ -997,28 +997,28 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end it 'should use icon image specified in theme if icon attribute is not set on block', visual: true do - to_file = to_pdf_file <<~'EOS', 'admonition-icon-image.pdf', attribute_overrides: { 'pdf-theme' => (fixture_file 'admonition-image-theme.yml') }, analyze: true + to_file = to_pdf_file <<~'END', 'admonition-icon-image.pdf', attribute_overrides: { 'pdf-theme' => (fixture_file 'admonition-image-theme.yml') }, analyze: true :icons: [NOTE] ==== You can use a custom PDF theme to customize the icon image for a specific admonition type. ==== - EOS + END (expect to_file).to visually_match 'admonition-icon-image.pdf' end it 'should substitute attribute references in icon image value in theme', visual: true do pdf_theme = { admonition_icon_note: { image: '{docdir}/tux-note.svg' } } - to_file = to_pdf_file <<~'EOS', 'admonition-icon-image-with-attribute-ref.pdf', attribute_overrides: { 'docdir' => fixtures_dir }, pdf_theme: pdf_theme, analyze: true + to_file = to_pdf_file <<~'END', 'admonition-icon-image-with-attribute-ref.pdf', attribute_overrides: { 'docdir' => fixtures_dir }, pdf_theme: pdf_theme, analyze: true :icons: [NOTE] ==== You can use a custom PDF theme to customize the icon image for a specific admonition type. ==== - EOS + END (expect to_file).to visually_match 'admonition-icon-image.pdf' end @@ -1029,14 +1029,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_icon_note: { image: 'does-not-exist.png' }, } (expect do - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme :icons: [NOTE] ==== If the icon image cannot be found, the converter will fall back to using the label text in the place of the icon. ==== - EOS + END (expect get_images pdf).to be_empty (expect pdf.pages[0].text).to include 'NOTE' @@ -1061,7 +1061,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_icon_question: { name: 'question-circle' }, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, extensions: extensions, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, extensions: extensions, analyze: true :icons: font [QUESTION] @@ -1070,7 +1070,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do Just checking ;) ==== - EOS + END icon_text = pdf.find_unique_text ?\uf059 (expect icon_text).not_to be_nil @@ -1094,14 +1094,14 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end end - pdf = to_pdf <<~'EOS', extensions: extensions, analyze: true + pdf = to_pdf <<~'END', extensions: extensions, analyze: true :icons: font [FACT] ==== Like all planetary bodies, the Earth is spherical. ==== - EOS + END (expect pdf.lines).to eql [%(\uf05a Like all planetary bodies, the Earth is spherical.)] icon_text = pdf.find_unique_text ?\uf05a @@ -1117,9 +1117,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_column_rule_width: 1, admonition_column_rule_style: style, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line TIP: You can use the theme to customize the color and width of the column rule. - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -1133,9 +1133,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should not draw column rule if value is transparent' do pdf_theme = { admonition_column_rule_color: 'transparent' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line TIP: You can use the theme to customize the color and width of the column rule. - EOS + END lines = pdf.lines (expect lines).to be_empty @@ -1143,9 +1143,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should not draw column rule if value is nil and base border color is transparent' do pdf_theme = { base_border_color: 'transparent', admonition_column_rule_color: nil } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line TIP: You can use the theme to customize the color and width of the column rule. - EOS + END lines = pdf.lines (expect lines).to be_empty @@ -1157,9 +1157,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_column_rule_width: nil, base_border_width: nil, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line TIP: You can use the theme to customize the color and width of the column rule. - EOS + END lines = pdf.lines (expect lines).to be_empty @@ -1172,9 +1172,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_column_rule_width: nil, admonition_column_rule_color: '222222', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line TIP: You can use the theme to customize the color and width of the column rule. - EOS + END (expect pdf.lines).to be_empty end @@ -1185,9 +1185,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_column_rule_width: 1, admonition_column_rule_style: 'double', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line TIP: You can use the theme to customize the color and width of the column rule. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -1210,9 +1210,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_column_rule_color: '222222', admonition_column_rule_width: nil, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line TIP: You can use the theme to customize the color and width of the column rule. - EOS + END lines = pdf.lines (expect lines).to be_empty @@ -1225,9 +1225,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_border_color: 'e0e0e0', admonition_column_rule_color: 'e0e0e0', } - to_file = to_pdf_file <<~'EOS', 'admonition-border.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'admonition-border.pdf', pdf_theme: pdf_theme TIP: You can use the theme to add a border. - EOS + END (expect to_file).to visually_match 'admonition-border.pdf' end @@ -1238,16 +1238,16 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do admonition_border_radius: 3, admonition_column_rule_width: 0, } - to_file = to_pdf_file <<~'EOS', 'admonition-background-color.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'admonition-background-color.pdf', pdf_theme: pdf_theme TIP: You can use the theme to add a background color. - EOS + END (expect to_file).to visually_match 'admonition-background-color.pdf' end it 'should apply correct padding around content' do pdf_theme = { admonition_background_color: 'EEEEEE' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true :icons: font [NOTE] @@ -1256,7 +1256,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do last ==== - EOS + END boundaries = (pdf.extract_graphic_states pdf.pages[0][:raw_content])[0] .select {|l| l.end_with? 'l' } @@ -1274,7 +1274,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should apply correct padding around content when using base theme' do pdf_theme = { extends: 'base', admonition_background_color: 'EEEEEE' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true :icons: font [NOTE] @@ -1283,7 +1283,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do last ==== - EOS + END boundaries = (pdf.extract_graphic_states pdf.pages[0][:raw_content])[0] .select {|l| l.end_with? 'l' } @@ -1301,9 +1301,9 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do it 'should allow theme to disable column rule by setting width to 0' do pdf_theme = { admonition_column_rule_width: 0 } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line TIP: You can use the theme to add a background color. - EOS + END (expect pdf.lines).to be_empty end diff --git a/spec/arrange_block_spec.rb b/spec/arrange_block_spec.rb index 97d57e05..1973de54 100644 --- a/spec/arrange_block_spec.rb +++ b/spec/arrange_block_spec.rb @@ -16,14 +16,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end it 'should draw background across extent of empty block' do - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true before block ==== ==== after block - EOS + END pages = pdf.pages (expect pages).to have_size 1 @@ -37,7 +37,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should not draw backgrounds and borders in scratch document' do pdf_theme[:sidebar_border_color] = '222222' pdf_theme[:sidebar_border_width] = 0.5 - input = <<~'EOS' + input = <<~'END' before [%unbreakable] @@ -52,7 +52,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do example ==== -- - EOS + END scratch_pdf = nil extensions = proc do postprocessor do @@ -71,7 +71,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end it 'should invoke on_page_create if set on scratch document' do - input = <<~'EOS' + input = <<~'END' scratch_background_color:CCCCCC[] image::tall.svg[pdfwidth=70mm] @@ -83,7 +83,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do block ==== - EOS + END scratch_pdf = nil extensions = proc do inline_macro :scratch_background_color do @@ -129,11 +129,11 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do block_lines << 'content' block_lines << style end - input = <<~EOS + input = <<~END ****** #{block_lines * ?\n} ****** - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true horizontal_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -146,7 +146,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should compute extent of block correctly when indent is applied to section body' do pdf_theme[:section_indent] = 36 pdf = with_content_spacer 10, 650 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true == Section Title image::#{spacer_path}[] @@ -158,7 +158,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do It contains this very long sentence, which causes the block to become split across two pages. **** - EOS + END end pages = pdf.pages @@ -176,7 +176,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do # NOTE: only add tests that verify at top ignores unbreakable option; otherwise, put test in breakable at top describe 'at top' do it 'should keep block on current page if it fits' do - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [%unbreakable] ==== This block fits in the remaining space on the page. @@ -185,7 +185,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END pages = pdf.pages (expect pages).to have_size 1 @@ -197,14 +197,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block taller than page across pages, starting from page top' do block_content = ['block content'] * 35 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true [%unbreakable] ==== #{block_content} ==== after block - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -222,7 +222,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:example_border_color] = '0000ff' pdf_theme[:example_background_color] = 'ffffff' block_content = ['nested block content'] * 35 * %(\n\n) - input = <<~EOS + input = <<~END [%unbreakable] ==== @@ -237,7 +237,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -266,14 +266,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block taller than several pages across pages, starting from page top' do block_content = ['block content'] * 50 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true [%unbreakable] ==== #{block_content} ==== after block - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -291,7 +291,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do describe 'below top' do it 'should keep block on current page if it fits' do - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true before block [%unbreakable] @@ -300,7 +300,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do Therefore, it will not be split or moved to the following page. ==== - EOS + END pages = pdf.pages (expect pages).to have_size 1 @@ -313,14 +313,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block shorter than page to next page to avoid breaking' do before_block_content = ['before block'] * 15 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} [%unbreakable] ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -334,7 +334,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block shorter than page and with caption to next page to avoid breaking' do before_block_content = ['before block'] * 15 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} .block title @@ -342,7 +342,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -359,7 +359,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do before_block_content = ['before block'] * 15 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) block_title = ['block title'] * 20 * ' ' - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, attributes: { 'example-caption' => nil }, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, attributes: { 'example-caption' => nil }, analyze: true #{before_block_content} .#{block_title} @@ -367,7 +367,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -386,7 +386,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance nested unbreakable block shorter than page to next page to avoid breaking' do before_block_content = ['before block'] * 20 * %(\n\n) nested_block_content = ['nested block content'] * 5 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} ==== @@ -397,7 +397,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do #{nested_block_content} **** ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -416,7 +416,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block with only nested unbreakable block shorter than page to next page to avoid breaking' do before_block_content = ['before block'] * 20 * %(\n\n) nested_block_content = ['nested block content'] * 5 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} ==== @@ -425,7 +425,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do #{nested_block_content} **** ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -440,7 +440,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block taller than page across pages, starting from current position' do block_content = ['block content'] * 35 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true before block [%unbreakable] @@ -449,7 +449,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -481,7 +481,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end pdf = with_content_spacer 10, 650 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, extensions: extensions, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, extensions: extensions, analyze: true image::#{spacer_path}[] **** @@ -491,7 +491,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do [spy] paragraph **** - EOS + END end (expect pdf.pages).to have_size 2 @@ -519,7 +519,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end end - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, extensions: extensions, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, extensions: extensions, analyze: true before block [%unbreakable] @@ -533,7 +533,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END (expect pdf.pages).to have_size 2 # 1st call: to compute extent of sidebar for example block in scratch document @@ -563,7 +563,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end end - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, extensions: extensions, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, extensions: extensions, analyze: true [%unbreakable] ==== #{block_content} @@ -575,7 +575,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END (expect pdf.pages).to have_size 2 # 1st call: to compute extent of sidebar for example block in scratch document @@ -605,7 +605,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end end - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, extensions: extensions, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, extensions: extensions, analyze: true before block [%unbreakable] @@ -624,7 +624,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END (expect pdf.pages).to have_size 2 (expect calls).to have_size 7 @@ -650,7 +650,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end end - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, extensions: extensions, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, extensions: extensions, analyze: true before block [%unbreakable] @@ -666,7 +666,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END (expect pdf.pages).to have_size 2 (expect calls).to have_size 7 @@ -677,7 +677,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block taller than page to next page if only caption fits on current page' do before_block_content = ['before block'] * 22 * %(\n\n) block_content = ['block content'] * 25 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true **** filler **** @@ -689,7 +689,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -707,7 +707,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block taller than page to next page if no content fits on current page' do before_block_content = ['before block'] * 22 * %(\n\n) block_content = ['block content'] * 25 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true ==== filler ==== @@ -719,7 +719,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do **** #{block_content} **** - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -756,7 +756,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:example_border_width] = 0.5 pdf_theme[:example_border_color] = '0000ff' pdf_theme[:example_background_color] = 'ffffff' - input = <<~EOS + input = <<~END before block [%unbreakable] @@ -774,7 +774,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ======== ====== ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, extensions: extensions, analyze: true p3_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines.select {|it| it[:page_number] == 3 } (expect pdf.pages).to have_size 3 @@ -794,7 +794,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do describe 'breakable block' do describe 'at top' do it 'should keep block on current page if it fits' do - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true ==== This block fits in the remaining space on the page. @@ -802,7 +802,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END pages = pdf.pages (expect pages).to have_size 1 @@ -814,13 +814,13 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block taller than page across pages, starting from page top' do block_content = ['block content'] * 35 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true ==== #{block_content} ==== after block - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -838,7 +838,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:example_border_color] = '0000ff' pdf_theme[:example_background_color] = 'ffffff' block_content = ['nested block content'] * 35 * %(\n\n) - input = <<~EOS + input = <<~END ==== block content @@ -851,7 +851,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== after block - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -880,13 +880,13 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block taller than several pages, starting from page top' do block_content = ['block content'] * 50 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true ==== #{block_content} ==== after block - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -903,13 +903,13 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block across pages that contains image that does not fit in remaining space on current page' do block_content = ['block content'] * 10 * %(\n\n) - input = <<~EOS + input = <<~END ==== #{block_content} image::tux.png[pdfwidth=100%] ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images @@ -929,11 +929,11 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do # NOTE: this scenario renders an example block that starts with an empty page it 'should split block across pages that contains image taller than page at start of block', negative: true do - input = <<~'EOS' + input = <<~'END' ==== image::tall-spacer.png[] ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images pages = pdf.pages @@ -952,13 +952,13 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end it 'should split block across pages that contains image taller than page that follows text' do - input = <<~'EOS' + input = <<~'END' ==== before image image::tall-spacer.png[] ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images @@ -982,7 +982,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do code_border_radius: 0, code_background_color: 'transparent' block_content = ['block content with very long lines that do not wrap because the page layout is rotated to landscape'] * 20 * %(\n\n) - input = <<~EOS + input = <<~END first page [page-layout=landscape] @@ -991,7 +991,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do .... #{block_content} .... - EOS + END block_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines.select {|it| it[:color] == '0000FF' } pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -1014,7 +1014,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do code_background_color: 'transparent', page_margin_rotated: 10 block_content = ['block content with very long lines that do not wrap because the page layout is rotated to landscape'] * 20 * %(\n\n) - input = <<~EOS + input = <<~END first page [page-layout=landscape] @@ -1023,7 +1023,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do .... #{block_content} .... - EOS + END block_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines.select {|it| it[:color] == '0000FF' } top_line = block_lines[0] @@ -1045,7 +1045,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do describe 'below top' do it 'should keep block on current page if it fits' do - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true before block ==== @@ -1053,7 +1053,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do Therefore, it will not be split or moved to the following page. ==== - EOS + END pages = pdf.pages (expect pages).to have_size 1 @@ -1066,14 +1066,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block shorter than page to next page if only caption fits on current page' do before_block_content = ['before block'] * 24 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} .block title ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -1091,7 +1091,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do block_content = ['block content'] * 15 * %(\n\n) block_title = ['block title'] * 15 * ' ' pdf = with_content_spacer 10, 635 do |spacer_path| - input = <<~EOS + input = <<~END image::#{spacer_path}[] before block @@ -1100,7 +1100,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== #{block_content} ==== - EOS + END to_pdf input, pdf_theme: pdf_theme, analyze: true end @@ -1118,7 +1118,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block shorter than page to next page if caption fits but advances page' do block_content = ['block content'] * 15 * %(\n\n) pdf = with_content_spacer 10, 635 do |spacer_path| - input = <<~EOS + input = <<~END image::#{spacer_path}[] before block @@ -1127,7 +1127,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== #{block_content} ==== - EOS + END to_pdf input, pdf_theme: pdf_theme, analyze: true end @@ -1145,14 +1145,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block shorter than page to next page if no content fits on current page' do before_block_content = ['before block'] * 24 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} .block title **** #{block_content} **** - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -1169,14 +1169,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block taller than page to next page if only caption fits on current page' do before_block_content = ['before block'] * 24 * %(\n\n) block_content = ['block content'] * 30 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} .block title ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -1194,14 +1194,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block taller than page to next page if no content fits on current page' do before_block_content = ['before block'] * 24 * %(\n\n) block_content = ['block content'] * 30 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} .block title **** #{block_content} **** - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -1219,13 +1219,13 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block shorter than page across pages, starting from current position if it does not fit on current page' do before_block_content = ['before block'] * 15 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -1241,13 +1241,13 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block taller than page across pages, starting from current position' do before_block_content = ['before block'] * 15 * %(\n\n) block_content = ['block content'] * 35 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true #{before_block_content} ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -1265,7 +1265,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should split block across pages that contains image that does not fit in remaining space on current page' do before_block_content = ['before block'] * 5 * %(\n\n) block_content = ['block content'] * 5 * %(\n\n) - input = <<~EOS + input = <<~END #{before_block_content} ==== @@ -1273,7 +1273,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do image::tux.png[pdfwidth=100%] ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images @@ -1294,7 +1294,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block that starts with image that does not fit in remaining space on current page to next page' do before_block_content = ['before block'] * 10 * %(\n\n) - input = <<~EOS + input = <<~END #{before_block_content} ==== @@ -1302,7 +1302,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do after image ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images @@ -1321,7 +1321,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should advance block with caption that starts with image that does not fit in remaining space on current page to next page' do before_block_content = ['before block'] * 10 * %(\n\n) - input = <<~EOS + input = <<~END #{before_block_content} .block title @@ -1330,7 +1330,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do after image ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images @@ -1350,13 +1350,13 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do # NOTE: this scenario renders an example block that starts with an empty page it 'should split block across pages that contains image taller than page at start of block', negative: true do - input = <<~'EOS' + input = <<~'END' before block ==== image::tall-spacer.png[] ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images pages = pdf.pages @@ -1381,7 +1381,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:sidebar_border_color] = '0000ff' pdf_theme[:sidebar_border_width] = 0.5 pdf_theme[:heading_margin_top] = 50 - input = <<~'EOS' + input = <<~'END' before **** @@ -1390,7 +1390,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do content **** - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -1412,7 +1412,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end end - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, extensions: extensions, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, extensions: extensions, analyze: true image::tall.svg[pdfwidth=78mm] .#{block_title} @@ -1423,7 +1423,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do example ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -1440,7 +1440,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do code_background_color: 'transparent' before_block_content = ['before block'] * 15 * %(\n\n) block_content = ['block content with very long lines that do not wrap because the page layout is rotated to landscape'] * 15 * %(\n\n) - input = <<~EOS + input = <<~END first page [page-layout=landscape] @@ -1451,7 +1451,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do .... #{block_content} .... - EOS + END block_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines.select {|it| it[:color] == '0000FF' } pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -1473,7 +1473,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do code_background_color: 'transparent' before_block_content = ['before block'] * 15 * %(\n\n) block_content = ['block content with very long lines that wrap because the page layout is not rotated to landscape'] * 15 * %(\n\n) - input = <<~EOS + input = <<~END first page [page-layout=landscape] @@ -1489,7 +1489,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do .... #{block_content} .... - EOS + END block_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines.select {|it| it[:color] == '0000FF' } pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -1510,7 +1510,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should arrange block after another block has been arranged' do before_block_content = ['before block'] * 35 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true [%unbreakable] ==== #{before_block_content} @@ -1522,7 +1522,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -1547,7 +1547,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:example_background_color] = 'ffffff' pdf_theme[:table_cell_padding] = 5 block_content = ['block content'] * 3 * %(\n\n) - input = <<~EOS + input = <<~END |=== a| before block @@ -1558,7 +1558,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do after block |=== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines (expect pdf.pages).to have_size 1 @@ -1577,7 +1577,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:example_background_color] = 'ffffff' pdf_theme[:table_cell_padding] = [30, 20] block_content = ['block content'] * 3 * %(\n\n) - input = <<~EOS + input = <<~END |=== a| before block @@ -1590,7 +1590,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do after block |=== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines (expect pdf.pages).to have_size 1 @@ -1612,7 +1612,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:page_margin] = 36 pdf_theme[:table_cell_padding] = 5 block_content = ['block content'] * 25 * %(\n\n) - input = <<~EOS + input = <<~END |=== a| table cell @@ -1623,7 +1623,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do table cell |=== - EOS + END (expect do pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -1659,7 +1659,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end end - input = <<~EOS + input = <<~END before table |=== @@ -1669,7 +1669,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do [spy] beyond of first page |=== - EOS + END (expect do pdf = to_pdf input, pdf_theme: pdf_theme, extensions: extensions, analyze: true (expect pdf.pages).to have_size 2 @@ -1701,7 +1701,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end end - input = <<~EOS + input = <<~END ==== before table |=== @@ -1712,7 +1712,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do beyond of first page |=== ==== - EOS + END (expect do pdf = to_pdf input, pdf_theme: pdf_theme, extensions: extensions, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, extensions: extensions, analyze: :line).lines @@ -1741,7 +1741,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:block_margin_bottom] = 10 pdf_theme[:table_font_size] = 5.25 block_content = ['block content'] * 10 * %(\n\n) - input = <<~EOS + input = <<~END |=== a| ==== @@ -1750,7 +1750,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do table cell |=== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines border_bottom_y = lines @@ -1775,7 +1775,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:table_cell_padding] = 5 before_table_content = ['before table'] * 15 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - input = <<~EOS + input = <<~END #{before_table_content} |=== @@ -1788,7 +1788,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do |=== after table - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines (expect pdf.pages).to have_size 2 @@ -1824,7 +1824,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:table_cell_padding] = 5 before_table_content = ['before table'] * 15 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - input = <<~EOS + input = <<~END #{before_table_content} |=== @@ -1840,7 +1840,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do |=== after table - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines (expect pdf.pages).to have_size 2 @@ -1877,7 +1877,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme[:table_cell_padding] = 5 before_table_content = ['before table'] * 15 * %(\n\n) block_content = ['block content'] * 25 * %(\n\n) - input = <<~EOS + input = <<~END #{before_table_content} |=== @@ -1890,7 +1890,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do |=== after table - EOS + END (expect do pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -1929,14 +1929,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should keep anchor with unbreakable block that is advanced to new page' do before_block_content = ['before block'] * 15 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme + pdf = to_pdf <<~END, pdf_theme: pdf_theme #{before_block_content} [#block-id%unbreakable] ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect (pages[0].text.split %r/\n+/).uniq.compact).to eql ['before block'] @@ -1950,7 +1950,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do it 'should keep anchor with breakable block that is advanced to next page' do before_block_content = ['before block'] * 24 * %(\n\n) block_content = ['block content'] * 15 * %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme + pdf = to_pdf <<~END, pdf_theme: pdf_theme #{before_block_content} .block title @@ -1958,7 +1958,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== #{block_content} ==== - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -1981,12 +1981,12 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end end end - input = <<~'EOS' + input = <<~'END' .... $ gem install asciidoctor-pdf asciidoctor-mathematical $ asciidoctor-pdf -r asciidoctor-mathematical -a mathematical-format=svg sample.adoc .... - EOS + END lines = (to_pdf input, backend: backend, pdf_theme: pdf_theme, analyze: :line).lines pdf = to_pdf input, backend: backend, pdf_theme: pdf_theme, analyze: true last_line_y = lines.select {|it| it[:from][:y] == it[:to][:y] }.map {|it| it[:from][:y] }.min @@ -2003,14 +2003,14 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do code_background_color: 'EFEFEF' pdf = with_content_spacer 10, 675 do |spacer_path| - input = <<~EOS + input = <<~END image::#{spacer_path}[] .... $ gem install asciidoctor-pdf asciidoctor-mathematical $ asciidoctor-pdf -r asciidoctor-mathematical -a mathematical-format=svg sample.adoc .... - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true pages = pdf.pages (expect pages).to have_size 1 @@ -2023,7 +2023,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do pdf_theme.update page_columns: 2, page_column_gap: 12, admonition_column_rule_color: '0000FF' pdf = with_content_spacer 10, 400 do |spacer_path| - input = <<~EOS + input = <<~END = Document Title :toc: @@ -2035,7 +2035,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do ==== #{lorem_ipsum '4-sentences-2-paragraphs'} ==== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true pages = pdf.pages diff --git a/spec/audio_spec.rb b/spec/audio_spec.rb index 1fd555ee..399fecad 100644 --- a/spec/audio_spec.rb +++ b/spec/audio_spec.rb @@ -10,13 +10,13 @@ describe 'Asciidoctor::PDF::Converter - Audio' do 'after', ] - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true before audio::podcast.mp3[] after - EOS + END (expect pdf.lines).to eql expected_lines before_text = (pdf.find_text 'before')[0] @@ -26,9 +26,9 @@ describe 'Asciidoctor::PDF::Converter - Audio' do end it 'should wrap text for audio if it exceeds width of content area' do - pdf = to_pdf <<~'EOS', analyze: true, attribute_overrides: { 'imagesdir' => '' } + pdf = to_pdf <<~'END', analyze: true, attribute_overrides: { 'imagesdir' => '' } audio::a-podcast-with-an-excessively-long-and-descriptive-name-as-they-sometimes-are-that-causes-the-text-to-wrap.mp3[] - EOS + END (expect pdf.pages).to have_size 1 lines = pdf.lines pdf.find_text page_number: 1 @@ -36,9 +36,9 @@ describe 'Asciidoctor::PDF::Converter - Audio' do end it 'should use font-based icon for play symbol if font icons are enabled' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'icons' => 'font' }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'icons' => 'font' }, analyze: true audio::podcast.mp3[] - EOS + END icon_text = (pdf.find_text ?\uf04b)[0] (expect icon_text).not_to be_nil @@ -46,12 +46,12 @@ describe 'Asciidoctor::PDF::Converter - Audio' do end it 'should show caption for audio if title is specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font .Episode 1 of my podcast audio::podcast-e1.mp3[] - EOS + END (expect pdf.lines).to eql [%(\uf04b\u00a0#{fixture_file 'podcast-e1.mp3'} (audio)), 'Episode 1 of my podcast'] end diff --git a/spec/break_spec.rb b/spec/break_spec.rb index fe7684b9..53cb34f2 100644 --- a/spec/break_spec.rb +++ b/spec/break_spec.rb @@ -5,35 +5,35 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Break' do context 'Line Breaks' do it 'should place text on separate line after explicit line break' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true foo + bar + baz - EOS + END (expect pdf.lines).to eql %w(foo bar baz) end it 'should preserve inner empty lines that end with hard line break' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true foo + filler + filler + filler + bar - EOS + END expected_gap = ((pdf.find_unique_text 'foo')[:y] - (pdf.find_unique_text 'bar')[:y]).round 4 - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true foo + {empty} + {empty} + {empty} + bar - EOS + END actual_gap = ((pdf.find_unique_text 'foo')[:y] - (pdf.find_unique_text 'bar')[:y]).round 4 @@ -42,12 +42,12 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should preserve newlines in paragraph with hardbreaks option' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%hardbreaks] foo bar baz - EOS + END (expect pdf.lines).to eql %w(foo bar baz) end @@ -55,13 +55,13 @@ describe 'Asciidoctor::PDF::Converter - Break' do context 'Thematic Breaks' do it 'should draw line for thematic break' do - input = <<~'EOS' + input = <<~'END' before ''' after - EOS + END pdf = to_pdf input, analyze: true @@ -81,9 +81,9 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should use solid style for thematic break if not specified' do - pdf = to_pdf <<~'EOS', pdf_theme: { thematic_break_border_style: nil }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { thematic_break_border_style: nil }, analyze: :line ''' - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -98,13 +98,13 @@ describe 'Asciidoctor::PDF::Converter - Break' do thematic_break_border_style: 'double', } - input = <<~'EOS' + input = <<~'END' before ''' after - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -127,13 +127,13 @@ describe 'Asciidoctor::PDF::Converter - Break' do context 'Page Breaks' do it 'should advance to next page after page break' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page foo <<< bar - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[0][:strings]).to include 'foo' @@ -141,7 +141,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should insert page break if page does not have columns' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :notitle: @@ -151,7 +151,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< second page - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.find_unique_text 'first page')[:page_number]).to eql 1 @@ -159,29 +159,29 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should not advance to next page if at start of document' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page <<< foo - EOS + END (expect pdf.pages).to have_size 1 end it 'should advance to next page if at start of document and always option is specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%always] <<< content - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.find_unique_text 'content')[:page_number]).to eql 2 end it 'should not advance to next page if preceding content forced a new page to be started' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Book Title :doctype: book @@ -190,7 +190,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< == Chapter - EOS + END part_text = (pdf.find_text 'Part')[0] (expect part_text[:page_number]).to be 2 @@ -199,27 +199,27 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should not advance to next page if preceding content advanced page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true .... #{(['filler'] * 50).join ?\n} .... start of page - EOS + END start_of_page_text = (pdf.find_text 'start of page')[0] (expect start_of_page_text[:page_number]).to be 2 end it 'should not advance to next column if at start of column in multi-column layout' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2 }, analyze: true = Article Title [.column] <<< column 1 - EOS + END (expect pdf.pages).to have_size 1 text = pdf.find_unique_text 'column 1' @@ -228,14 +228,14 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should advance to next column if at start of column in multi-column layout and always option is specified' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2 }, analyze: true = Article Title [.column%always] <<< column 1 - EOS + END (expect pdf.pages).to have_size 1 text = pdf.find_unique_text 'column 1' @@ -244,11 +244,11 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should not leave blank page at the end of document' do - input = <<~'EOS' + input = <<~'END' foo <<< - EOS + END [ {}, @@ -261,14 +261,14 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should change layout if page break specifies page-layout attribute' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true portrait [page-layout=landscape] <<< landscape - EOS + END text = pdf.text (expect text).to have_size 2 @@ -277,14 +277,14 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should change layout if page break specifies layout role' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true portrait [.landscape] <<< landscape - EOS + END text = pdf.text (expect text).to have_size 2 @@ -293,7 +293,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should switch layout each time page break specifies layout role' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true portrait [.landscape] @@ -310,7 +310,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< landscape - EOS + END portrait_text = pdf.find_text 'portrait' (expect portrait_text).to have_size 2 @@ -328,7 +328,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should switch layout specified by page break even when it falls at a natural page break' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true portrait [.landscape] @@ -340,13 +340,13 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< portrait - EOS + END (expect (pdf.page 3)[:size]).to eql PDF::Core::PageGeometry::SIZES['A4'] end it 'should not switch layout specified by page break if value is unrecognized' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true portrait [.landscape] @@ -358,13 +358,13 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< landscape - EOS + END (expect (pdf.page 3)[:size]).to eql (pdf.page 2)[:size] end it 'should insert page break in column layout' do - pdf = to_pdf <<~EOS, pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { page_columns: 2 }, analyze: true = Article Title column 1, page 1 @@ -372,7 +372,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< column 1, page 2 - EOS + END c1p1_text = pdf.find_unique_text 'column 1, page 1' (expect c1p1_text[:x]).to eql 48.24 @@ -383,7 +383,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should insert page break with custom layout in column layout' do - pdf = to_pdf <<~EOS, pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { page_columns: 2 }, analyze: true = Article Title column 1, page 1 @@ -392,7 +392,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< column 1, page 2 - EOS + END c1p1_text = pdf.find_unique_text 'column 1, page 1' (expect c1p1_text[:x]).to eql 48.24 @@ -407,7 +407,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should insert column break in column layout if column role is specified' do - pdf = to_pdf <<~EOS, pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { page_columns: 2 }, analyze: true = Article Title column 1, page 1 @@ -416,7 +416,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< column 2, page 1 - EOS + END c1p1_text = pdf.find_unique_text 'column 1, page 1' (expect c1p1_text[:x]).to eql 48.24 @@ -427,7 +427,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do end it 'should insert page break in column layout if page layout is specified even if column role is specified' do - pdf = to_pdf <<~EOS, pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { page_columns: 2 }, analyze: true = Article Title column 1, page 1 @@ -436,7 +436,7 @@ describe 'Asciidoctor::PDF::Converter - Break' do <<< column 1, page 2 - EOS + END c1p1_text = pdf.find_unique_text 'column 1, page 1' (expect c1p1_text[:x]).to eql 48.24 diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 800f13d3..3d192921 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -12,12 +12,12 @@ describe 'asciidoctor-pdf' do it 'should enable sourcemap if --sourcemap option is specified', cli: true do with_tmp_file '.adoc', tmpdir: output_dir do |tmp_file| - tmp_file.write <<~'EOS' + tmp_file.write <<~'END' before **** content - EOS + END tmp_file.close out, err, res = run_command asciidoctor_pdf_bin, '--sourcemap', tmp_file.path (expect res.exitstatus).to be 0 diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb index cfb4d3e9..2d0ec242 100644 --- a/spec/converter_spec.rb +++ b/spec/converter_spec.rb @@ -79,13 +79,13 @@ describe Asciidoctor::PDF::Converter do it 'should warn if convert method is not found for node' do (expect do - doc = Asciidoctor.load <<~'EOS', backend: 'pdf', safe: :safe, attributes: { 'nofooter' => '' } + doc = Asciidoctor.load <<~'END', backend: 'pdf', safe: :safe, attributes: { 'nofooter' => '' } before 1,2,3 after - EOS + END doc.blocks[1].context = :chart pdf_stream = StringIO.new doc.write doc.convert, pdf_stream @@ -99,7 +99,7 @@ describe Asciidoctor::PDF::Converter do it 'should not warn if convert method is not found for node in scratch document' do (expect do - doc = Asciidoctor.load <<~'EOS', backend: 'pdf', safe: :safe, attributes: { 'nofooter' => '' } + doc = Asciidoctor.load <<~'END', backend: 'pdf', safe: :safe, attributes: { 'nofooter' => '' } before [%unbreakable] @@ -108,7 +108,7 @@ describe Asciidoctor::PDF::Converter do -- after - EOS + END doc.blocks[1].blocks[0].context = :chart pdf_stream = StringIO.new doc.write doc.convert, pdf_stream @@ -121,20 +121,20 @@ describe Asciidoctor::PDF::Converter do end it 'should ensure data-uri attribute is set' do - doc = Asciidoctor.load <<~'EOS', backend: 'pdf', base_dir: fixtures_dir, safe: :safe + doc = Asciidoctor.load <<~'END', backend: 'pdf', base_dir: fixtures_dir, safe: :safe image::logo.png[] - EOS + END (expect doc.attr? 'data-uri').to be true doc.convert (expect doc.attr? 'data-uri').to be true end it 'should ignore data-uri attribute entry in document' do - doc = Asciidoctor.load <<~'EOS', backend: 'pdf', base_dir: fixtures_dir, safe: :safe + doc = Asciidoctor.load <<~'END', backend: 'pdf', base_dir: fixtures_dir, safe: :safe :!data-uri: image::logo.png[] - EOS + END (expect doc.attr? 'data-uri').to be true doc.convert (expect doc.attr? 'data-uri').to be true @@ -143,9 +143,9 @@ describe Asciidoctor::PDF::Converter do it 'should not fail to remove tmp files if already removed' do image_data = File.read (fixture_file 'square.jpg'), mode: 'r:UTF-8' encoded_image_data = Base64.strict_encode64 image_data - doc = Asciidoctor.load <<~EOS, backend: 'pdf' + doc = Asciidoctor.load <<~END, backend: 'pdf' :page-background-image: image:data:image/png;base64,#{encoded_image_data}[Square,fit=cover] - EOS + END pdf_doc = doc.convert tmp_files = (converter = doc.converter).instance_variable_get :@tmp_files (expect tmp_files).to have_size 1 @@ -159,9 +159,9 @@ describe Asciidoctor::PDF::Converter do (expect do image_data = File.read (fixture_file 'square.jpg'), mode: 'r:UTF-8' encoded_image_data = Base64.strict_encode64 image_data - doc = Asciidoctor.load <<~EOS, backend: 'pdf' + doc = Asciidoctor.load <<~END, backend: 'pdf' :page-background-image: image:data:image/png;base64,#{encoded_image_data}[Square,fit=cover] - EOS + END pdf_doc = doc.convert tmp_files = doc.converter.instance_variable_get :@tmp_files (expect tmp_files).to have_size 1 @@ -181,9 +181,9 @@ describe Asciidoctor::PDF::Converter do it 'should keep tmp files if KEEP_ARTIFACTS environment variable is set' do image_data = File.read (fixture_file 'square.jpg'), mode: 'r:UTF-8' encoded_image_data = Base64.strict_encode64 image_data - doc = Asciidoctor.load <<~EOS, backend: 'pdf' + doc = Asciidoctor.load <<~END, backend: 'pdf' :page-background-image: image:data:image/png;base64,#{encoded_image_data}[Square,fit=cover] - EOS + END pdf_doc = doc.convert tmp_files = doc.converter.instance_variable_get :@tmp_files (expect tmp_files).to have_size 1 @@ -201,16 +201,16 @@ describe Asciidoctor::PDF::Converter do context 'theme' do it 'should apply the theme at the path specified by pdf-theme' do - with_pdf_theme_file <<~'EOS' do |theme_path| + with_pdf_theme_file <<~'END' do |theme_path| base: font-color: ff0000 - EOS - pdf = to_pdf <<~EOS, analyze: true + END + pdf = to_pdf <<~END, analyze: true = Document Title :pdf-theme: #{theme_path} red text - EOS + END (expect pdf.find_text font_color: 'FF0000').to have_size pdf.text.size end @@ -220,12 +220,12 @@ describe Asciidoctor::PDF::Converter do [nil, 'default'].each do |theme| to_pdf_opts = { analyze: true } to_pdf_opts[:attribute_overrides] = { 'pdf-theme' => theme } if theme - pdf = to_pdf <<~EOS, to_pdf_opts + pdf = to_pdf <<~END, to_pdf_opts = Document Title :pdf-themesdir: #{fixtures_dir} body text - EOS + END expected_font_color = theme ? 'AA0000' : '333333' body_text = (pdf.find_text 'body text')[0] @@ -235,17 +235,17 @@ describe Asciidoctor::PDF::Converter do end it 'should apply the named theme specified by pdf-theme located in the specified pdf-themesdir' do - with_pdf_theme_file <<~'EOS' do |theme_path| + with_pdf_theme_file <<~'END' do |theme_path| base: font-color: ff0000 - EOS - pdf = to_pdf <<~EOS, analyze: true + END + pdf = to_pdf <<~END, analyze: true = Document Title :pdf-theme: #{File.basename theme_path, '-theme.yml'} :pdf-themesdir: #{File.dirname theme_path} red text - EOS + END (expect pdf.find_text font_color: 'FF0000').to have_size pdf.text.size end @@ -265,25 +265,25 @@ describe Asciidoctor::PDF::Converter do end it 'should set text color to black when default-for-print theme is specified' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :pdf-theme: default-for-print black `text` > loud quote - EOS + END (expect pdf.find_text font_color: '000000').to have_size pdf.text.size end it 'should set font family to Noto Sans when default-sans themme is specified' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :pdf-theme: default-sans We don't like those _pesky_ serifs in these here parts. - EOS + END text = pdf.text sans_text = text.select {|it| it[:font_name].start_with? 'NotoSans' } @@ -335,7 +335,7 @@ describe Asciidoctor::PDF::Converter do end it 'should not crash if theme does not specify any keys' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => (fixture_file 'bare-theme.yml') }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'pdf-theme' => (fixture_file 'bare-theme.yml') }, analyze: true = Document Title :doctype: book @@ -358,7 +358,7 @@ describe Asciidoctor::PDF::Converter do <1> A variable assignment NOTE: That's all, folks! - EOS + END (expect pdf.pages).to have_size 3 (expect pdf.find_text font_name: 'Helvetica', font_size: 12).not_to be_empty @@ -443,11 +443,11 @@ describe Asciidoctor::PDF::Converter do describe 'helpers' do it 'should not drop lines with unresolved attributes when apply_subs_discretely is called without options' do - input = <<~'EOS' + input = <<~'END' foo {undefined} bar - EOS + END doc = Asciidoctor.load 'yo', backend: :pdf converter = doc.converter converter.load_theme doc @@ -558,11 +558,11 @@ describe Asciidoctor::PDF::Converter do context 'of block followed by block' do let :input_source do - <<~'EOS' + <<~'END' first paragraph second paragraph - EOS + END end let(:start) { doc.blocks[0] } @@ -572,7 +572,7 @@ describe Asciidoctor::PDF::Converter do context 'of last block in open block followed by block' do let :input_source do - <<~'EOS' + <<~'END' first paragraph -- @@ -580,7 +580,7 @@ describe Asciidoctor::PDF::Converter do -- third paragraph - EOS + END end let(:start) { (doc.find_by context: :paragraph)[1] } @@ -590,13 +590,13 @@ describe Asciidoctor::PDF::Converter do context 'of last block before parent section' do let :input_source do - <<~'EOS' + <<~'END' == First Section paragraph == Second Section - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -606,13 +606,13 @@ describe Asciidoctor::PDF::Converter do context 'of last block before subsection' do let :input_source do - <<~'EOS' + <<~'END' == Section paragraph === Subsection - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -622,7 +622,7 @@ describe Asciidoctor::PDF::Converter do context 'of last block before grandparent section' do let :input_source do - <<~'EOS' + <<~'END' == First Section paragraph @@ -632,7 +632,7 @@ describe Asciidoctor::PDF::Converter do paragraph == Last Section - EOS + END end let(:start) { (doc.find_by context: :paragraph)[-1] } @@ -642,13 +642,13 @@ describe Asciidoctor::PDF::Converter do context 'of preamble' do let :input_source do - <<~'EOS' + <<~'END' = Document Title preamble == First Section - EOS + END end let(:start) { (doc.find_by context: :preamble)[0] } @@ -658,7 +658,7 @@ describe Asciidoctor::PDF::Converter do context 'of abstract' do let :input_source do - <<~'EOS' + <<~'END' = Document Title [abstract] @@ -667,7 +667,7 @@ describe Asciidoctor::PDF::Converter do -- == First Section - EOS + END end let(:start) { (doc.find_by context: :open, style: 'abstract')[0] } @@ -677,7 +677,7 @@ describe Asciidoctor::PDF::Converter do context 'of abstract followed by more preamble' do let :input_source do - <<~'EOS' + <<~'END' = Document Title [abstract] @@ -688,7 +688,7 @@ describe Asciidoctor::PDF::Converter do more preamble == First Section - EOS + END end let(:start) { (doc.find_by context: :open, style: 'abstract')[0] } @@ -698,7 +698,7 @@ describe Asciidoctor::PDF::Converter do context 'of last block in abstract' do let :input_source do - <<~'EOS' + <<~'END' = Document Title [abstract] @@ -707,7 +707,7 @@ describe Asciidoctor::PDF::Converter do -- == First Section - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -717,7 +717,7 @@ describe Asciidoctor::PDF::Converter do context 'of last block inside abstract followed by more preamble' do let :input_source do - <<~'EOS' + <<~'END' = Document Title [abstract] @@ -728,7 +728,7 @@ describe Asciidoctor::PDF::Converter do more preamble == First Section - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -738,13 +738,13 @@ describe Asciidoctor::PDF::Converter do context 'of last block inside delimited block' do let :input_source do - <<~'EOS' + <<~'END' **** inside paragraph **** outside paragraph - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -754,11 +754,11 @@ describe Asciidoctor::PDF::Converter do context 'of list followed by block' do let :input_source do - <<~'EOS' + <<~'END' * list item paragraph - EOS + END end let(:start) { doc.blocks[0] } @@ -768,10 +768,10 @@ describe Asciidoctor::PDF::Converter do context 'of first list item in list' do let :input_source do - <<~'EOS' + <<~'END' * yin * yang - EOS + END end let(:start) { doc.blocks[0].items[0] } @@ -781,12 +781,12 @@ describe Asciidoctor::PDF::Converter do context 'of last list item in list' do let :input_source do - <<~'EOS' + <<~'END' * yin * yang paragraph - EOS + END end let(:start) { doc.blocks[0].items[-1] } @@ -796,12 +796,12 @@ describe Asciidoctor::PDF::Converter do context 'of last attached block in first item in list' do let :input_source do - <<~'EOS' + <<~'END' * moon + stars * sun - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -811,14 +811,14 @@ describe Asciidoctor::PDF::Converter do context 'of last attached block in last item in list' do let :input_source do - <<~'EOS' + <<~'END' * sun * moon + stars paragraph - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -828,7 +828,7 @@ describe Asciidoctor::PDF::Converter do context 'of last block in open block attached to first item in list' do let :input_source do - <<~'EOS' + <<~'END' * moon + -- @@ -837,7 +837,7 @@ describe Asciidoctor::PDF::Converter do dark side -- * sun - EOS + END end let(:start) { (doc.find_by context: :paragraph)[1] } @@ -847,11 +847,11 @@ describe Asciidoctor::PDF::Converter do context 'of last item in nested list of first item in list' do let :input_source do - <<~'EOS' + <<~'END' * sun ** star * moon - EOS + END end let(:start) { (doc.find_by context: :list_item)[1] } @@ -861,13 +861,13 @@ describe Asciidoctor::PDF::Converter do context 'of last item in nested list of last item in list' do let :input_source do - <<~'EOS' + <<~'END' * moon * sun ** star paragraph - EOS + END end let(:start) { (doc.find_by context: :list_item)[2] } @@ -877,12 +877,12 @@ describe Asciidoctor::PDF::Converter do context 'of last item in deeply nested list of first item in list' do let :input_source do - <<~'EOS' + <<~'END' * foo ** bar *** baz * moon - EOS + END end let(:start) { (doc.find_by context: :list_item)[2] } @@ -892,9 +892,9 @@ describe Asciidoctor::PDF::Converter do context 'of term of first item in dlist' do let :input_source do - <<~'EOS' + <<~'END' foo:: bar - EOS + END end let(:start) { (doc.find_by context: :list_item)[0] } @@ -904,10 +904,10 @@ describe Asciidoctor::PDF::Converter do context 'of desc text of first item in dlist' do let :input_source do - <<~'EOS' + <<~'END' foo:: bar yin:: yang - EOS + END end let(:start) { (doc.find_by context: :list_item)[1] } @@ -917,12 +917,12 @@ describe Asciidoctor::PDF::Converter do context 'of desc text of last item in dlist' do let :input_source do - <<~'EOS' + <<~'END' foo:: bar yin:: yang paragraph - EOS + END end let(:start) { (doc.find_by context: :list_item)[3] } @@ -932,14 +932,14 @@ describe Asciidoctor::PDF::Converter do context 'of attached block in last item in dlist' do let :input_source do - <<~'EOS' + <<~'END' foo:: bar sun:: moon + stars paragraph - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -949,10 +949,10 @@ describe Asciidoctor::PDF::Converter do context 'of missing block' do let :input_source do - <<~'EOS' + <<~'END' foo:: bar yin:: yang - EOS + END end let :start do @@ -966,7 +966,7 @@ describe Asciidoctor::PDF::Converter do context 'of preamble followed by section' do let :input_source do - <<~'EOS' + <<~'END' = Document Title [abstract] @@ -975,7 +975,7 @@ describe Asciidoctor::PDF::Converter do -- == Intro - EOS + END end let(:start) { (doc.find_by context: :open)[0].parent } @@ -985,7 +985,7 @@ describe Asciidoctor::PDF::Converter do context 'of paragraph in abstract followed by section' do let :input_source do - <<~'EOS' + <<~'END' = Document Title [abstract] @@ -994,7 +994,7 @@ describe Asciidoctor::PDF::Converter do -- == Intro - EOS + END end let(:start) { (doc.find_by context: :paragraph)[0] } @@ -1004,7 +1004,7 @@ describe Asciidoctor::PDF::Converter do context 'of quote block in abstract followed by section' do let :input_source do - <<~'EOS' + <<~'END' = Document Title [abstract] @@ -1015,7 +1015,7 @@ describe Asciidoctor::PDF::Converter do -- == Intro - EOS + END end let(:start) { (doc.find_by context: :quote)[0] } @@ -1025,7 +1025,7 @@ describe Asciidoctor::PDF::Converter do context 'of last block in AsciiDoc table cell' do let :input_source do - <<~'EOS' + <<~'END' [cols=2*] |=== a| @@ -1041,7 +1041,7 @@ describe Asciidoctor::PDF::Converter do |=== after - EOS + END end let(:start) { (doc.find_by context: :quote, traverse_documents: true)[0] } @@ -1053,7 +1053,7 @@ describe Asciidoctor::PDF::Converter do example_group = self let :input_source do - <<~'EOS' + <<~'END' .Title [horizontal] term:: desc @@ -1062,7 +1062,7 @@ describe Asciidoctor::PDF::Converter do capture:quote[] another term:: - EOS + END end let :doc do @@ -1088,7 +1088,7 @@ describe Asciidoctor::PDF::Converter do example_group = self let :input_source do - <<~'EOS' + <<~'END' .Title [horizontal] term:: desc @@ -1097,7 +1097,7 @@ describe Asciidoctor::PDF::Converter do capture:quote[] after - EOS + END end let :doc do @@ -1135,7 +1135,7 @@ describe Asciidoctor::PDF::Converter do end pdf_theme = { caption_background_color: 'EEEEEE' } - input = <<~'EOS' + input = <<~'END' = Article Title * list item @@ -1149,7 +1149,7 @@ describe Asciidoctor::PDF::Converter do code block <1> ---- <1> Callout description - EOS + END (expect to_pdf_file input, 'bounding-box-left.pdf', backend: backend, pdf_theme: pdf_theme).to visually_match 'bounding-box-left.pdf' end @@ -1166,7 +1166,7 @@ describe Asciidoctor::PDF::Converter do end end - input = <<~'EOS' + input = <<~'END' = Article Title column 1, page 1 @@ -1180,7 +1180,7 @@ describe Asciidoctor::PDF::Converter do <<< column 1, page 2 - EOS + END pdf = to_pdf input, backend: backend, analyze: true (expect (pdf.find_unique_text 'column 1, page 2')[:page_number]).to eql 2 @@ -1198,12 +1198,12 @@ describe Asciidoctor::PDF::Converter do end end - input = <<~'EOS' + input = <<~'END' see next section [#next-section] == Next Section - EOS + END pdf = to_pdf input, backend: backend, analyze: true para_text = pdf.find_unique_text 'see next section' @@ -1228,13 +1228,13 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, pdf_theme: { heading_margin_bottom: 0, heading_margin_top: 100 }, analyze: true + pdf = to_pdf <<~'END', backend: backend, pdf_theme: { heading_margin_bottom: 0, heading_margin_top: 100 }, analyze: true [.first] paragraph [.second] paragraph - EOS + END first_heading_text = pdf.find_unique_text 'First Heading' (expect first_heading_text).not_to be_nil @@ -1262,14 +1262,14 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true before [.heading] heading paragraph - EOS + END heading_text = pdf.find_unique_text 'HEADING' (expect heading_text).not_to be_nil @@ -1289,13 +1289,13 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, pdf_theme: { heading_margin_bottom: 0, heading_margin_top: 100 }, analyze: true + pdf = to_pdf <<~'END', backend: backend, pdf_theme: { heading_margin_bottom: 0, heading_margin_top: 100 }, analyze: true [.first] paragraph [.second] paragraph - EOS + END first_heading_text = pdf.find_unique_text 'First Heading' (expect first_heading_text).not_to be_nil @@ -1323,14 +1323,14 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true before [.heading] heading paragraph - EOS + END heading_text = pdf.find_unique_text 'HEADING' (expect heading_text).not_to be_nil @@ -1354,10 +1354,10 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true [transform=upcase] == Section Title - EOS + END heading_text = pdf.find_unique_text 'SECTION TITLE' (expect heading_text).not_to be_nil @@ -1377,10 +1377,10 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: :image + pdf = to_pdf <<~'END', backend: backend, analyze: :image [image=tux.png] == Section Title - EOS + END (expect pdf.images).to have_size 1 end @@ -1399,14 +1399,14 @@ describe Asciidoctor::PDF::Converter do end pdf_theme = { heading_doctitle_font_color: '0000EE', heading_doctitle_margin_bottom: 24 } - pdf = to_pdf <<~'EOS', backend: backend, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', backend: backend, pdf_theme: pdf_theme, analyze: true = Article Title First paragraph of body. First paragraph of body. First paragraph of body. First paragraph of body. - EOS + END (expect pdf.pages).to have_size 1 title_text = pdf.find_unique_text 'Article Title' @@ -1444,14 +1444,14 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', backend: backend, enable_footer: true, analyze: true = Document Title :doctype: book = Part Title == Chapter - EOS + END page_2_text = pdf.find_text page_number: 2 (expect page_2_text).to have_size 1 @@ -1470,12 +1470,12 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true [,ruby] ---- puts "Hello, Ruby!" ---- - EOS + END (expect pdf.text[0][:string]).to eql 'puts "Hello, World!"' end @@ -1491,12 +1491,12 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true [,ruby] ---- puts "Hello, Ruby!" ---- - EOS + END (expect pdf.text[0][:string]).to eql 'puts "Hello, World!"' end @@ -1518,7 +1518,7 @@ describe Asciidoctor::PDF::Converter do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: :line + pdf = to_pdf <<~'END', backend: backend, analyze: :line [.custom,cols=2*] |=== |a |b @@ -1532,7 +1532,7 @@ describe Asciidoctor::PDF::Converter do |a |b |c |d |=== - EOS + END lines = pdf.lines custom_lines = lines.select {|it| it[:color] == '0000EE' } diff --git a/spec/cover_page_spec.rb b/spec/cover_page_spec.rb index 388ed07e..2f233ade 100644 --- a/spec/cover_page_spec.rb +++ b/spec/cover_page_spec.rb @@ -4,12 +4,12 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should add front cover page if front-cover-image attribute is set to bare path' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :front-cover-image: #{fixture_file 'cover.jpg', relative: true} content page - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[0].text).to be_empty @@ -19,12 +19,12 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should add front cover page if front-cover-image attribute is set to image macro' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :front-cover-image: image:cover.jpg[] content page - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[0].text).to be_empty @@ -36,12 +36,12 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should add front cover page if front-cover-image attribute is set to data URI' do image_data = File.binread fixture_file 'cover.jpg' encoded_image_data = Base64.strict_encode64 image_data - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :front-cover-image: image:data:image/jpg;base64,#{encoded_image_data}[] content page - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[0].text).to be_empty @@ -52,13 +52,13 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should not add cover page if file cannot be resolved' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :front-cover-image: image:no-such-file.jpg[] content page - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.lines pdf.find_text page_number: 1).to eql ['Document Title'] @@ -67,11 +67,11 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should not add cover page if image cannot be embedded' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :front-cover-image: image:broken.svg[] content page - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.lines pdf.find_text page_number: 1).to eql ['content page'] @@ -79,20 +79,20 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should not add cover page if value is ~' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :front-cover-image: ~ content page - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.lines pdf.find_text page_number: 1).to eql ['Document Title'] end it 'should apply recto margin to title page of prepress book when value of front-cover-image attribute is ~' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_text_align: 'left' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { title_page_text_align: 'left' }, analyze: true = Document Title :doctype: book :media: prepress @@ -103,7 +103,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do <<< second page - EOS + END (expect pdf.pages).to have_size 4 doctitle_text = pdf.find_unique_text 'Document Title' @@ -122,13 +122,13 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do title_page_text_align: 'left', cover_front_image: '~', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :media: prepress content - EOS + END (expect pdf.pages).to have_size 3 doctitle_text = pdf.find_unique_text 'Document Title' @@ -138,11 +138,11 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should add front cover page if cover_front_image theme key is set' do pdf_theme = { cover_front_image: (fixture_file 'cover.jpg') } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title content page - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[0].text).to be_empty @@ -152,13 +152,13 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should add back cover page if back-cover-image attribute is set to raw path' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :front-cover-image: #{fixture_file 'cover.jpg', relative: true} :back-cover-image: #{fixture_file 'cover.jpg', relative: true} content page - EOS + END (expect pdf.pages).to have_size 3 (expect pdf.pages[0].text).to be_empty @@ -169,13 +169,13 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should add back cover page if back-cover-image attribute is set to image macro' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :front-cover-image: image:cover.jpg[] :back-cover-image: image:cover.jpg[] content page - EOS + END (expect pdf.pages).to have_size 3 (expect pdf.pages[0].text).to be_empty @@ -188,13 +188,13 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should add back cover page if back-cover-image attribute is set to data URI' do image_data = File.binread fixture_file 'cover.jpg' encoded_image_data = Base64.strict_encode64 image_data - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :front-cover-image: image:data:image/jpg;base64,#{encoded_image_data}[] :back-cover-image: image:data:image/jpg;base64,#{encoded_image_data}[] content page - EOS + END (expect pdf.pages).to have_size 3 (expect pdf.pages[0].text).to be_empty @@ -209,11 +209,11 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do cover_front_image: (fixture_file 'cover.jpg'), cover_back_image: (fixture_file 'cover.jpg'), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title content page - EOS + END (expect pdf.pages).to have_size 3 (expect pdf.pages[0].text).to be_empty @@ -225,12 +225,12 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should prefer attribute over theme key' do pdf_theme = { cover_back_image: (fixture_file 'not-this-one.jpg') } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title :back-cover-image: image:cover.jpg[] content page - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[1].text).to be_empty @@ -240,7 +240,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should create blank page if front or back cover image is empty' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Book Title :doctype: book :front-cover-image: @@ -249,7 +249,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do == Chapter text - EOS + END (expect pdf.pages).to have_size 4 (expect (pdf.page 1).text).to be_empty @@ -272,12 +272,12 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should not crash if front cover image is a URI and the allow-uri-read attribute is not set' do pdf = nil (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :front-cover-image: https://example.org/cover.svg content - EOS + END end).to not_raise_exception & (log_message severity: :WARN, message: '~allow-uri-read attribute not enabled') (expect pdf.pages).to have_size 1 (expect pdf.find_text 'Document Title').to have_size 1 @@ -285,13 +285,13 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should recognize attribute value that uses image macro syntax and resolve relative to imagesdir', visual: true do %w(block inline).each do |type| - to_file = to_pdf_file <<~EOS, %(cover-page-front-cover-#{type}-image-macro.pdf) + to_file = to_pdf_file <<~END, %(cover-page-front-cover-#{type}-image-macro.pdf) = Document Title :doctype: book :front-cover-image: image:#{type == 'block' ? ':' : ''}cover.jpg[] content page - EOS + END (expect to_file).to visually_match 'cover-page-front-cover-image-contain.pdf' end @@ -305,63 +305,63 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should scale front cover image to boundaries of page by default', visual: true do ['', 'fit=contain'].each do |image_opts| - to_file = to_pdf_file <<~EOS, %(cover-page-front-cover-image-#{image_opts.empty? ? 'default' : 'contain'}.pdf) + to_file = to_pdf_file <<~END, %(cover-page-front-cover-image-#{image_opts.empty? ? 'default' : 'contain'}.pdf) = Document Title :doctype: book :front-cover-image: image:cover.jpg[#{image_opts}] content page - EOS + END (expect to_file).to visually_match 'cover-page-front-cover-image-contain.pdf' end end it 'should stretch front cover image to boundaries of page if fit=fill', visual: true do - to_file = to_pdf_file <<~'EOS', 'cover-page-front-cover-image-fill.pdf' + to_file = to_pdf_file <<~'END', 'cover-page-front-cover-image-fill.pdf' = Document Title :doctype: book :front-cover-image: image:cover.jpg[fit=fill] :pdf-page-size: Letter content page - EOS + END (expect to_file).to visually_match 'cover-page-front-cover-image-fill.pdf' end it 'should not scale front cover image to fit page if fit is none', visual: true do - to_file = to_pdf_file <<~'EOS', 'cover-page-front-cover-image-unscaled.pdf' + to_file = to_pdf_file <<~'END', 'cover-page-front-cover-image-unscaled.pdf' = Document Title :doctype: book :front-cover-image: image:cover.jpg[fit=none] content page - EOS + END (expect to_file).to visually_match 'cover-page-front-cover-image-unscaled.pdf' end it 'should scale front cover down until it is contained within the boundaries of the page', visual: true do ['', 'fit=scale-down'].each do |image_opts| - to_file = to_pdf_file <<~EOS, %(cover-page-front-cover-image-#{image_opts.empty? ? 'max' : 'scale-down'}.pdf) + to_file = to_pdf_file <<~END, %(cover-page-front-cover-image-#{image_opts.empty? ? 'max' : 'scale-down'}.pdf) :front-cover-image: image:cover.jpg[#{image_opts}] :pdf-page-size: A7 content page - EOS + END (expect to_file).to visually_match 'cover-page-front-cover-image-max.pdf' end end it 'should scale front cover image until it covers page if fit=cover', visual: true do - to_file = to_pdf_file <<~'EOS', 'cover-page-front-cover-image-cover.pdf' + to_file = to_pdf_file <<~'END', 'cover-page-front-cover-image-cover.pdf' = Document Title :front-cover-image: image:cover.jpg[fit=cover] content page - EOS + END (expect to_file).to visually_match 'cover-page-front-cover-image-cover.pdf' end @@ -369,13 +369,13 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should scale front cover image with aspect ratio taller than page until it covers page if fit=cover' do pdf_page_size = get_page_size (to_pdf 'content', attribute_overrides: { 'pdf-page-size' => 'Letter' }), 1 - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :pdf-page-size: Letter :front-cover-image: image:cover.jpg[fit=cover] content page - EOS + END images = pdf.images (expect images).to have_size 1 @@ -387,12 +387,12 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should position front cover image as specified by position attribute', visual: true do - to_file = to_pdf_file <<~'EOS', 'cover-page-front-cover-image-positioned.pdf' + to_file = to_pdf_file <<~'END', 'cover-page-front-cover-image-positioned.pdf' = Document Title :front-cover-image: image:square.svg[fit=none,pdfwidth=50%,position=top right] content page - EOS + END (expect to_file).to visually_match 'cover-page-front-cover-image-positioned.pdf' end @@ -400,12 +400,12 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do it 'should use specified image format', visual: true do source_file = (dest_file = fixture_file 'square') + '.svg' FileUtils.cp source_file, dest_file - to_file = to_pdf_file <<~'EOS', 'cover-page-front-cover-image-format.pdf' + to_file = to_pdf_file <<~'END', 'cover-page-front-cover-image-format.pdf' = Document Title :front-cover-image: image:square[format=svg] content page - EOS + END (expect to_file).to visually_match 'cover-page-front-cover-image-format.pdf' ensure @@ -413,36 +413,36 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should set the base font for a book when front cover image is a PDF and title page is off' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :front-cover-image: #{fixture_file 'blue-letter.pdf', relative: true} :doctype: book :notitle: content - EOS + END (expect (pdf.find_unique_text 'content')[:font_name]).to eql 'NotoSerif' end it 'should set the base font for an article when front cover image is a PDF and title page is off' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :front-cover-image: #{fixture_file 'blue-letter.pdf', relative: true} content - EOS + END (expect (pdf.find_unique_text 'content')[:font_name]).to eql 'NotoSerif' end it 'should not allow page size of PDF cover page to affect page size of document' do - input = <<~EOS + input = <<~END = Document Title :front-cover-image: #{fixture_file 'blue-letter.pdf', relative: true} content - EOS + END pdf = to_pdf input, analyze: :rect rects = pdf.rectangles @@ -458,11 +458,11 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should import specified page from PDF file defined using front-cover-image attribute' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :front-cover-image: image:red-green-blue.pdf[page=3] content - EOS + END (expect pdf.pages).to have_size 2 page_contents = pdf.objects[(pdf.page 1).page_object[:Contents][0]].data (expect (page_contents.split ?\n).slice 0, 3).to eql ['q', '/DeviceRGB cs', '0.0 0.0 1.0 scn'] @@ -477,7 +477,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should not add front cover if reference page in PDF file does not exist' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :front-cover-image: image:red-green-blue.pdf[page=10] one @@ -485,7 +485,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do <<< two - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.page 1).text).to eql 'one' @@ -495,11 +495,11 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should add back cover using referenced page in PDF file' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :back-cover-image: image:red-green-blue.pdf[page=3] content - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.page 1).text).to eql 'content' @@ -508,18 +508,18 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should not add back cover if referenced page in PDF file does not exist' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :back-cover-image: image:red-green-blue.pdf[page=10] content - EOS + END (expect pdf.pages).to have_size 1 (expect (pdf.page 1).text).to eql 'content' end it 'should not add front cover if PDF file has no pages' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :front-cover-image: image:no-pages.pdf[] one @@ -527,7 +527,7 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do <<< two - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.page 1).text).to eql 'one' @@ -537,11 +537,11 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do end it 'should not add back cover if PDF file has no pages' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :back-cover-image: image:no-pages.pdf[] content - EOS + END (expect pdf.pages).to have_size 1 (expect (pdf.page 1).text).to eql 'content' diff --git a/spec/dest_spec.rb b/spec/dest_spec.rb index a35bb534..5735974c 100644 --- a/spec/dest_spec.rb +++ b/spec/dest_spec.rb @@ -4,15 +4,15 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Dest' do it 'should not define a dest named __anchor-top if document has no body pages' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book - EOS + END (expect get_names pdf).to be_empty end it 'should define a dest named __anchor-top at top of the first body page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toc: @@ -22,7 +22,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do == Chapter content - EOS + END (expect (top_dest = get_dest pdf, '__anchor-top')).not_to be_nil (expect (top_dest[:page_number])).to be 3 @@ -31,13 +31,13 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should define a dest named toc at the top of the first toc page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toc: == Chapter - EOS + END (expect (toc_dest = get_dest pdf, 'toc')).not_to be_nil (expect toc_dest[:page_number]).to be 2 @@ -46,7 +46,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should define a dest named toc at the location where the macro toc starts' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :toc: macro @@ -57,7 +57,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do == Chapter == Another Chapter - EOS + END (expect (toc_dest = get_dest pdf, 'toc')).not_to be_nil (expect (toc_dest[:page_number])).to be 1 @@ -66,7 +66,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should use the toc macro ID as the name of the dest for the macro toc' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :toc: macro @@ -78,18 +78,18 @@ describe 'Asciidoctor::PDF::Converter - Dest' do == Chapter == Another Chapter - EOS + END (expect get_names pdf).to have_key 'macro-toc' end it 'should define a dest at the top of a chapter page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book == Chapter - EOS + END (expect (chapter_dest = get_dest pdf, '_chapter')).not_to be_nil (expect (chapter_dest[:page_number])).to be 2 @@ -98,7 +98,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should define a dest at the top of a part page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book @@ -107,7 +107,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do == Chapter content - EOS + END (expect (part_dest = get_dest pdf, '_part_1')).not_to be_nil (expect (part_dest[:page_number])).to be 2 @@ -116,7 +116,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should define a dest at the top of page for section if section is at top of page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title content @@ -126,7 +126,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do == Section content - EOS + END (expect (sect_dest = get_dest pdf, '_section')).not_to be_nil (expect (sect_dest[:page_number])).to be 2 @@ -137,10 +137,10 @@ describe 'Asciidoctor::PDF::Converter - Dest' do it 'should define a dest at the top of content area if page does not start with a section' do pdf_theme = { page_margin: 15 } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme [#p1] content - EOS + END (expect (para_dest = get_dest pdf, 'p1')).not_to be_nil (expect (para_dest[:page_number])).to be 1 @@ -150,24 +150,24 @@ describe 'Asciidoctor::PDF::Converter - Dest' do it 'should register dest for every block that has an ID' do ['', 'abstract', 'example', 'open', 'sidebar', 'quote', 'verse', 'listing', 'literal', 'NOTE'].each do |style| - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END [#{style}#disclaimer] All views expressed are my own. - EOS + END (expect get_names pdf).to have_key 'disclaimer' end end it 'should register dest for table that has an ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' [#props] |=== | Name | Value | Foo | Bar |=== - EOS + END (expect get_names pdf).to have_key 'props' end @@ -179,47 +179,47 @@ describe 'Asciidoctor::PDF::Converter - Dest' do video: 'webcast.mp4', audio: 'podcast.mp3', }.each do |macro_name, target| - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END [#media] #{macro_name == :svg ? 'image' : macro_name.to_s}::#{target}[] - EOS + END (expect get_names pdf).to have_key 'media' end end it 'should register dest for unordered list that has an ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' [#takeaways] * one * two - EOS + END (expect get_names pdf).to have_key 'takeaways' end it 'should register dest for ordered list that has an ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' [#takeaways] . one . two - EOS + END (expect get_names pdf).to have_key 'takeaways' end it 'should register dest for description list that has an ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' [#takeaways] reuse:: try to avoid binning it in the first place recycle:: if you do bin it, make sure the material gets reused - EOS + END (expect get_names pdf).to have_key 'takeaways' end it 'should register dest for callout list that has an ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' ---- require 'asciidoctor-pdf' // <1> @@ -228,13 +228,13 @@ describe 'Asciidoctor::PDF::Converter - Dest' do [#details] <1> requires the library <2> converts the document to PDF - EOS + END (expect get_names pdf).to have_key 'details' end it 'should register dest for each section with implicit ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' == Fee === Fi @@ -242,7 +242,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do ==== Fo ===== Fum - EOS + END names = get_names pdf (expect names).to have_key '_fee' @@ -252,7 +252,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should register dest for each section with explicit ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' [#s-fee] == Fee @@ -264,7 +264,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do [#s-fum] ===== Fum - EOS + END names = get_names pdf (expect names).to have_key 's-fee' @@ -274,7 +274,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should not register dest with auto-generated name for each section if sectids are disabled' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :!sectids: == Fee @@ -284,7 +284,7 @@ describe 'Asciidoctor::PDF::Converter - Dest' do ==== Fo ===== Fum - EOS + END names = get_names pdf names.delete '__anchor-top' @@ -295,25 +295,25 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should register dest for a discrete heading with an implicit ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' [discrete] == Bundler Use this procedure if you're using Bundler. - EOS + END (expect get_names pdf).to have_key '_bundler' end it 'should not register dest for a discrete heading when sectids are disabled' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :!sectids: [discrete] == Bundler Use this procedure if you're using Bundler. - EOS + END names = get_names pdf names.delete '__anchor-top' @@ -321,24 +321,24 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should register dest for a discrete heading with an explicit ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' [discrete#bundler] == Bundler Use this procedure if you're using Bundler. - EOS + END (expect get_names pdf).to have_key 'bundler' end it 'should register dest for a link with an ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' see <<link,link>> <<< https://asciidoctor.org[Asciidoctor,id=link] - EOS + END (expect (link_dest = get_dest pdf, 'link')).not_to be_nil (expect link_dest[:page_number]).to be 2 @@ -355,13 +355,13 @@ describe 'Asciidoctor::PDF::Converter - Dest' do it 'should define a dest at the location of an inline anchor' do ['[[details]]details', '[#details]#details#'].each do |details| - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END Here's the intro. <<< Here are all the #{details}. - EOS + END (expect (phrase_dest = get_dest pdf, 'details')).not_to be_nil (expect phrase_dest[:page_number]).to be 2 @@ -369,13 +369,13 @@ describe 'Asciidoctor::PDF::Converter - Dest' do end it 'should keep anchor with text if text is advanced to next page' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END jump to <<anchor>> #{(['paragraph'] * 25).join %(\n\n)} #{(['paragraph'] * 16).join ' '} [#anchor]#supercalifragilisticexpialidocious# - EOS + END (expect (phrase_dest = get_dest pdf, 'anchor')).not_to be_nil (expect phrase_dest[:page_number]).to be 2 @@ -393,11 +393,11 @@ describe 'Asciidoctor::PDF::Converter - Dest' do base_font_family: 'Missing Null', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true foo [#bar]#bar# #baz# foo bar #baz# - EOS + END baz_texts = pdf.find_text 'baz' (expect baz_texts).to have_size 2 diff --git a/spec/diagram_spec.rb b/spec/diagram_spec.rb index 90953433..32733fef 100644 --- a/spec/diagram_spec.rb +++ b/spec/diagram_spec.rb @@ -27,7 +27,7 @@ describe 'Asciidoctor Diagram Integration', if: (RSpec::ExampleGroupHelpers.gem_ it 'should be able to control display size of image using pdfwidth attribute on diagram block' do require 'asciidoctor-diagram' - pdf = to_pdf <<~EOS, safe: :unsafe, attributes: { 'docdir' => fixtures_dir, 'outdir' => output_dir, 'imagesdir' => 'images' }, analyze: :image + pdf = to_pdf <<~END, safe: :unsafe, attributes: { 'docdir' => fixtures_dir, 'outdir' => output_dir, 'imagesdir' => 'images' }, analyze: :image [plantuml,pdfwidth-test,png,pdfwidth=1in] .... @@ -36,7 +36,7 @@ describe 'Asciidoctor Diagram Integration', if: (RSpec::ExampleGroupHelpers.gem_ :Work; end .... - EOS + END (expect Pathname.new output_file 'images/pdfwidth-test.png').to exist images = pdf.images @@ -49,7 +49,7 @@ describe 'Asciidoctor Diagram Integration', if: (RSpec::ExampleGroupHelpers.gem_ require 'asciidoctor-diagram' with_tmp_file '.cfg', contents: %(skinparam defaultFontName M+ 1p Fallback\n) do |tmp_file| Dir.chdir File.dirname tmp_file do - pdf = to_pdf <<~EOS, attributes: { 'imagesdir' => '' }, analyze: true + pdf = to_pdf <<~END, attributes: { 'imagesdir' => '' }, analyze: true :pdf-theme: default-with-font-fallbacks :plantumlconfig: #{File.basename tmp_file} @@ -57,7 +57,7 @@ describe 'Asciidoctor Diagram Integration', if: (RSpec::ExampleGroupHelpers.gem_ .... card カード .... - EOS + END text = pdf.text[0] (expect text[:string]).to eql 'カード' diff --git a/spec/document_title_spec.rb b/spec/document_title_spec.rb index f77a7134..9c87a809 100644 --- a/spec/document_title_spec.rb +++ b/spec/document_title_spec.rb @@ -5,12 +5,12 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Document Title' do context 'book' do it 'should partition the main title and subtitle' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Main Title: Subtitle :doctype: book body - EOS + END title_page_texts = pdf.find_text page_number: 1 (expect title_page_texts).to have_size 2 @@ -26,13 +26,13 @@ describe 'Asciidoctor::PDF::Converter - Document Title' do end it 'should use custom separator to partition document title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [separator=" -"] = Main Title - Subtitle :doctype: book body - EOS + END title_page_texts = pdf.find_text page_number: 1 (expect title_page_texts).to have_size 2 @@ -50,11 +50,11 @@ describe 'Asciidoctor::PDF::Converter - Document Title' do context 'article' do it 'should place document title at top of first page of content' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title body - EOS + END doctitle_text = (pdf.find_text 'Document Title')[0] (expect doctitle_text).not_to be_nil @@ -66,11 +66,11 @@ describe 'Asciidoctor::PDF::Converter - Document Title' do end it 'should align document title according to value of heading_h1_text_align theme key' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_h1_text_align: 'left' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_h1_text_align: 'left' }, analyze: true = Document Title body - EOS + END doctitle_text = (pdf.find_text 'Document Title')[0] (expect doctitle_text).not_to be_nil @@ -80,12 +80,12 @@ describe 'Asciidoctor::PDF::Converter - Document Title' do end it 'should not include document title if notitle attribute is set' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page = Document Title :notitle: body - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:strings]).not_to include 'Document Title' end diff --git a/spec/example_spec.rb b/spec/example_spec.rb index 6379ae3f..c3c8284f 100644 --- a/spec/example_spec.rb +++ b/spec/example_spec.rb @@ -4,45 +4,45 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Example' do it 'should keep block together if it can fit on one page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['filler'] * 15).join %(\n\n)} [%unbreakable] ==== #{(['content'] * 15).join %(\n\n)} ==== - EOS + END example_text = (pdf.find_text 'content')[0] (expect example_text[:page_number]).to be 2 end it 'should include title if specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true .Title ==== Content ==== - EOS + END title_texts = pdf.find_text 'Example 1. Title' (expect title_texts).to have_size 1 end it 'should include title if specified and background and border are not set' do - pdf = to_pdf <<~'EOS', pdf_theme: { example_background_color: 'transparent', example_border_width: 0 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { example_background_color: 'transparent', example_border_width: 0 }, analyze: true .Title ==== Content ==== - EOS + END title_texts = pdf.find_text 'Example 1. Title' (expect title_texts).to have_size 1 end it 'should keep title with content when block is advanced to next page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['filler'] * 15).join %(\n\n)} .Title @@ -50,7 +50,7 @@ describe 'Asciidoctor::PDF::Converter - Example' do ==== #{(['content'] * 15).join %(\n\n)} ==== - EOS + END example_title_text = (pdf.find_text 'Example 1. Title')[0] example_content_text = (pdf.find_text 'content')[0] @@ -59,13 +59,13 @@ describe 'Asciidoctor::PDF::Converter - Example' do end it 'should split block if it cannot fit on one page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true .Title [%unbreakable] ==== #{(['content'] * 30).join %(\n\n)} ==== - EOS + END example_title_text = (pdf.find_text 'Example 1. Title')[0] example_content_text = (pdf.find_text 'content') @@ -75,13 +75,13 @@ describe 'Asciidoctor::PDF::Converter - Example' do end it 'should split border when block is split across pages', visual: true do - to_file = to_pdf_file <<~EOS, 'example-page-split.pdf' + to_file = to_pdf_file <<~END, 'example-page-split.pdf' .Title [%unbreakable] ==== #{(['content'] * 30).join %(\n\n)} ==== - EOS + END (expect to_file).to visually_match 'example-page-split.pdf' end @@ -94,14 +94,14 @@ describe 'Asciidoctor::PDF::Converter - Example' do example_border_radius: 0, } pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] ==== content + that wraps ==== - EOS + END end pages = pdf.pages @@ -112,14 +112,14 @@ describe 'Asciidoctor::PDF::Converter - Example' do (expect last_text_y - pdf_theme[:example_padding]).to be > 48.24 pdf = with_content_spacer 10, 692 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] ==== content + that wraps ==== - EOS + END end pages = pdf.pages @@ -132,7 +132,7 @@ describe 'Asciidoctor::PDF::Converter - Example' do end it 'should draw border around whole block when block contains nested unbreakable block', visual: true do - to_file = to_pdf_file <<~EOS, 'example-with-nested-block-page-split.pdf' + to_file = to_pdf_file <<~END, 'example-with-nested-block-page-split.pdf' .Title ==== #{(['content'] * 25).join %(\n\n)} @@ -146,20 +146,20 @@ describe 'Asciidoctor::PDF::Converter - Example' do #{(['content'] * 5).join %(\n\n)} ==== - EOS + END (expect to_file).to visually_match 'example-with-nested-block-page-split.pdf' end it 'should not add signifier and numeral to caption if example-caption attribute is unset' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :!example-caption: .Title ==== content ==== - EOS + END (expect pdf.lines[0]).to eql 'Title' end @@ -170,12 +170,12 @@ describe 'Asciidoctor::PDF::Converter - Example' do example_caption_font_style: 'bold', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Title ==== content ==== - EOS + END title_text = (pdf.find_text 'Example 1. Title')[0] (expect title_text[:font_color]).to eql '0000FF' @@ -185,12 +185,12 @@ describe 'Asciidoctor::PDF::Converter - Example' do it 'should allow theme to place caption below block' do pdf_theme = { example_caption_end: 'bottom' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Look out below! ==== content ==== - EOS + END content_text = pdf.find_unique_text 'content' title_text = pdf.find_unique_text 'Example 1. Look out below!' @@ -203,12 +203,12 @@ describe 'Asciidoctor::PDF::Converter - Example' do caption_text_decoration_color: 'DDDDDD', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line .Title ==== content ==== - EOS + END underline = pdf.lines.find {|it| it[:color] = 'DDDDDD' } (expect underline).not_to be_nil @@ -224,7 +224,7 @@ describe 'Asciidoctor::PDF::Converter - Example' do example_border_color: '333333', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line ==== example @@ -232,7 +232,7 @@ describe 'Asciidoctor::PDF::Converter - Example' do here ==== - EOS + END lines = pdf.lines (expect lines).to have_size 8 @@ -254,13 +254,13 @@ describe 'Asciidoctor::PDF::Converter - Example' do example_padding: 3, } - input = <<~'EOS' + input = <<~'END' ==== first last ==== - EOS + END to_file = to_pdf_file input, 'example-uneven-border-end-caps.pdf', pdf_theme: pdf_theme (expect to_file).to visually_match 'example-uneven-border-end-caps.pdf' @@ -274,13 +274,13 @@ describe 'Asciidoctor::PDF::Converter - Example' do example_padding: 3, } - input = <<~'EOS' + input = <<~'END' ==== first last ==== - EOS + END # NOTE: visually, these two reference files are identical, but the image comparator doesn't think so to_file = to_pdf_file input, 'example-singular-border-end-caps.pdf', pdf_theme: pdf_theme @@ -291,13 +291,13 @@ describe 'Asciidoctor::PDF::Converter - Example' do end it 'should add correct padding around content when using default theme' do - input = <<~'EOS' + input = <<~'END' ==== first last ==== - EOS + END pdf = to_pdf input, analyze: true lines = (to_pdf input, analyze: :line).lines @@ -316,13 +316,13 @@ describe 'Asciidoctor::PDF::Converter - Example' do end it 'should add equal padding around content when using base theme' do - input = <<~'EOS' + input = <<~'END' ==== first last ==== - EOS + END pdf = to_pdf input, attribute_overrides: { 'pdf-theme' => 'base' }, analyze: true lines = (to_pdf input, attribute_overrides: { 'pdf-theme' => 'base' }, analyze: :line).lines @@ -341,7 +341,7 @@ describe 'Asciidoctor::PDF::Converter - Example' do end it 'should use informal title, indented content, no border or shading, and bottom margin if collapsible option is set' do - input = <<~'EOS' + input = <<~'END' .Reveal Answer [%collapsible] ==== @@ -349,7 +349,7 @@ describe 'Asciidoctor::PDF::Converter - Example' do ==== Paragraph following collapsible block. - EOS + END pdf = to_pdf input, analyze: true lines = pdf.lines @@ -369,26 +369,26 @@ describe 'Asciidoctor::PDF::Converter - Example' do # see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary#default_label_text it 'should use fallback title for collapsible block if no title is specified' do - input = <<~'EOS' + input = <<~'END' [%collapsible] ==== These are the details. ==== - EOS + END pdf = to_pdf input, analyze: true (expect pdf.text[0][:string]).to eql %(\u25bc Details) end it 'should align left margin of content of collapsible block with start of title text' do - input = <<~'EOS' + input = <<~'END' .*Spoiler* [%collapsible] ==== Now you can't unsee it. Muahahahaha. ==== - EOS + END pdf = to_pdf input, analyze: true (expect pdf.text[0][:x]).to eql 48.24 @@ -403,7 +403,7 @@ describe 'Asciidoctor::PDF::Converter - Example' do code_border_radius: 0, code_border_width: [1, 0], } - input = <<~'EOS' + input = <<~'END' [%collapsible] ==== ---- @@ -414,7 +414,7 @@ describe 'Asciidoctor::PDF::Converter - Example' do ---- below ---- - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines.sort_by {|it| -it[:from][:y] } (expect lines).to have_size 4 diff --git a/spec/floating_title_spec.rb b/spec/floating_title_spec.rb index 32630f9b..e406d450 100644 --- a/spec/floating_title_spec.rb +++ b/spec/floating_title_spec.rb @@ -7,12 +7,12 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do pdf_theme = { heading_text_align: 'center', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [discrete] == Discrete Heading main content - EOS + END discrete_heading_text = pdf.find_unique_text 'Discrete Heading' main_text = pdf.find_unique_text 'main content' @@ -24,12 +24,12 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do heading_text_align: 'left', heading_h2_text_align: 'center', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [discrete] == Discrete Heading main content - EOS + END discrete_heading_text = pdf.find_unique_text 'Discrete Heading' main_text = pdf.find_unique_text 'main content' @@ -42,13 +42,13 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do heading_h2_text_align: nil, heading_text_align: nil, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [discrete] == Discrete Heading [.text-left] main content - EOS + END discrete_heading_text = pdf.find_unique_text 'Discrete Heading' main_text = pdf.find_unique_text 'main content' @@ -57,14 +57,14 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do it 'should force discrete heading to next page if space below is less than heading-min-height-after value' do pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS + to_pdf <<~END image::#{spacer_path}[] [discrete#buddy] == Discrete Heading Don't abandon me! - EOS + END end (expect pdf.pages).to have_size 2 @@ -76,7 +76,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do it 'should force discrete heading with breakable option to next page if no content is inked below it' do pdf = with_content_spacer 10, 675 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { heading_min_height_after: nil } + to_pdf <<~END, pdf_theme: { heading_min_height_after: nil } image::#{spacer_path}[] [discrete#buddy%breakable] @@ -85,7 +85,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do ---- Do it like this. ---- - EOS + END end (expect pdf.pages).to have_size 2 @@ -97,7 +97,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do it 'should force discrete heading to next page when heading-min-height-after is auto if no content is inked below it' do pdf = with_content_spacer 10, 675 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { heading_min_height_after: 'auto' } + to_pdf <<~END, pdf_theme: { heading_min_height_after: 'auto' } image::#{spacer_path}[] [discrete#buddy] @@ -106,7 +106,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do ---- Do it like this. ---- - EOS + END end (expect pdf.pages).to have_size 2 @@ -118,12 +118,12 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do it 'should ignore heading-min-height-after if heading is last child' do pdf = with_content_spacer 10, 650 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { heading_min_height_after: 100, heading_font_color: 'AA0000' }, analyze: true + to_pdf <<~END, pdf_theme: { heading_min_height_after: 100, heading_font_color: 'AA0000' }, analyze: true image::#{spacer_path}[] [discrete] == Heading Fits - EOS + END end (expect pdf.pages).to have_size 1 @@ -138,7 +138,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do backend = %(pdf#{ext_class.object_id}) source_lines[0] = %( register_for '#{backend}'\n) ext_class.class_eval source_lines.join, source_file - pdf = to_pdf <<~EOS, backend: backend, analyze: true + pdf = to_pdf <<~END, backend: backend, analyze: true [discrete] == Heading A @@ -158,7 +158,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do together -- - EOS + END heading_c_text = pdf.find_unique_text 'Heading C' (expect heading_c_text[:page_number]).to be 2 @@ -168,14 +168,14 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do it 'should not force discrete heading to next page if heading-min-height-after value is not set' do pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { heading_min_height_after: nil } + to_pdf <<~END, pdf_theme: { heading_min_height_after: nil } image::#{spacer_path}[] [discrete#buddy] == Discrete Heading Don't abandon me! - EOS + END end (expect pdf.pages).to have_size 2 @@ -189,7 +189,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do it 'should not force discrete heading without breakable option to next page if no content is inked below it' do pdf = with_content_spacer 10, 675 do |spacer_path| - to_pdf <<~EOS + to_pdf <<~END image::#{spacer_path}[] [discrete#buddy] @@ -198,7 +198,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do ---- Do it like this. ---- - EOS + END end (expect pdf.pages).to have_size 2 @@ -212,12 +212,12 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do it 'should not force discrete heading to next page if it has no next sibling' do pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS + to_pdf <<~END image::#{spacer_path}[] [discrete#buddy] == Discrete Heading - EOS + END end (expect pdf.pages).to have_size 1 @@ -228,7 +228,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do end it 'should outdent discrete heading' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true = Document Title == Section @@ -248,7 +248,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do ==== Another Discrete Heading paragraph - EOS + END discrete_heading_texts = pdf.find_text %r/Discrete/ (expect discrete_heading_texts).to have_size 2 @@ -259,7 +259,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do end it 'should not outdent discrete heading inside block' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true == Section **** @@ -268,7 +268,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do [discrete] == Discrete Heading **** - EOS + END sidebar_content_text = (pdf.find_text 'sidebar content')[0] discrete_heading_text = (pdf.find_text 'Discrete Heading')[0] @@ -276,16 +276,16 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do end it 'should honor text alignment role on discrete heading' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [discrete] == Discrete Heading - EOS + END left_x = (pdf.find_text 'Discrete Heading')[0][:x] - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [discrete.text-right] == Discrete Heading - EOS + END right_x = (pdf.find_text 'Discrete Heading')[0][:x] (expect right_x).to be > left_x @@ -304,7 +304,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do heading_h3_padding: [0, 0, 5], } - input = <<~'EOS' + input = <<~'END' [discrete] == Heading Level 1 @@ -314,7 +314,7 @@ describe 'Asciidoctor::PDF::Converter - Floating Title' do === Heading Level 2 content - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true diff --git a/spec/font_spec.rb b/spec/font_spec.rb index 15da223c..9c3deef5 100644 --- a/spec/font_spec.rb +++ b/spec/font_spec.rb @@ -81,23 +81,23 @@ describe 'Asciidoctor::PDF::Converter - Font' do end it 'should render emoji when using default theme with fallback font', visual: true do - to_file = to_pdf_file <<~'EOS', 'font-emoji.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' } + to_file = to_pdf_file <<~'END', 'font-emoji.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' } Don't 😢 over spilled 🍺. Asciidoctor is 👍. - EOS + END (expect to_file).to visually_match 'font-emoji.pdf' end it 'should use sans base font when using sans theme with fallback font', visual: true do - to_file = to_pdf_file <<~'EOS', 'font-sans-emoji.pdf', attribute_overrides: { 'pdf-theme' => 'default-sans-with-font-fallbacks' } + to_file = to_pdf_file <<~'END', 'font-sans-emoji.pdf', attribute_overrides: { 'pdf-theme' => 'default-sans-with-font-fallbacks' } == Lessons Don't 😢 over spilled 🍺. Asciidoctor is 👍. - EOS + END (expect to_file).to visually_match 'font-sans-emoji.pdf' end @@ -129,7 +129,7 @@ describe 'Asciidoctor::PDF::Converter - Font' do it 'should replace essential characters with suitable replacements to avoid warnings' do (expect do - pdf = to_pdf <<~'EOS', pdf_theme: { base_font_family: 'Helvetica' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_font_family: 'Helvetica' }, analyze: true :experimental: * disc @@ -139,7 +139,7 @@ describe 'Asciidoctor::PDF::Converter - Font' do no{zwsp}space button:[Save] - EOS + END (expect pdf.find_text font_name: 'Helvetica').to have_size pdf.text.size (expect pdf.lines).to eql [%(\u2022 disc), '- circle', %(\u00b7 square), 'nospace', 'button:[Save]'] end).to not_log_message @@ -148,11 +148,11 @@ describe 'Asciidoctor::PDF::Converter - Font' do context 'OTF' do it 'should allow theme to specify an OTF font', visual: true do - to_file = to_pdf_file <<~'EOS', 'font-otf.pdf', enable_footer: true, attribute_overrides: { 'pdf-theme' => (fixture_file 'otf-theme.yml'), 'pdf-fontsdir' => fixtures_dir } + to_file = to_pdf_file <<~'END', 'font-otf.pdf', enable_footer: true, attribute_overrides: { 'pdf-theme' => (fixture_file 'otf-theme.yml'), 'pdf-fontsdir' => fixtures_dir } == OTF You're looking at an OTF font! - EOS + END (expect to_file).to visually_match 'font-otf.pdf' end end @@ -256,11 +256,11 @@ describe 'Asciidoctor::PDF::Converter - Font' do it 'should throw error that reports font name and style when font is not registered' do (expect do - to_pdf <<~'EOS', pdf_theme: { base_font_family: 'Lato' } + to_pdf <<~'END', pdf_theme: { base_font_family: 'Lato' } == Section Title paragraph - EOS + END end).to raise_exception Prawn::Errors::UnknownFont, 'Lato (normal) is not a known font.' end @@ -274,51 +274,51 @@ describe 'Asciidoctor::PDF::Converter - Font' do base_font_family: 'Quicksand', } (expect do - to_pdf <<~'EOS', pdf_theme: pdf_theme + to_pdf <<~'END', pdf_theme: pdf_theme == Section Title paragraph - EOS + END end).to raise_exception Prawn::Errors::UnknownFont, 'Quicksand (bold) is not a known font.' end end context 'Kerning' do it 'should enable kerning when using default theme', visual: true do - to_file = to_pdf_file <<~'EOS', 'font-kerning-default.pdf' + to_file = to_pdf_file <<~'END', 'font-kerning-default.pdf' [%hardbreaks] AVA Aya WAWA WeWork DYI - EOS + END (expect to_file).to visually_match 'font-kerning-default.pdf' end it 'should enable kerning when using base theme', visual: true do - to_file = to_pdf_file <<~'EOS', 'font-kerning-base.pdf', attribute_overrides: { 'pdf-theme' => 'base' } + to_file = to_pdf_file <<~'END', 'font-kerning-base.pdf', attribute_overrides: { 'pdf-theme' => 'base' } [%hardbreaks] AVA Aya WAWA WeWork DYI - EOS + END (expect to_file).to visually_match 'font-kerning-base.pdf' end it 'should allow theme to disable kerning globally', visual: true do - to_file = to_pdf_file <<~'EOS', 'font-kerning-disabled.pdf', pdf_theme: { base_font_kerning: 'none' } + to_file = to_pdf_file <<~'END', 'font-kerning-disabled.pdf', pdf_theme: { base_font_kerning: 'none' } [%hardbreaks] AVA Aya WAWA WeWork DYI - EOS + END (expect to_file).to visually_match 'font-kerning-disabled.pdf' end @@ -345,14 +345,14 @@ describe 'Asciidoctor::PDF::Converter - Font' do context 'Line breaks' do it 'should break line on any CJK character if value of scripts attribute is cjk' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :scripts: cjk :pdf-theme: default-with-font-fallbacks AsciiDoc 是一个人类可读的文件格式,语义上等同于 DocBook 的 XML,但使用纯文本标记了约定。可以使用任何文本编辑器创建文件把 AsciiDoc 和阅读“原样”,或呈现为HTML 或由 DocBook 的工具链支持的任何其他格式,如 PDF,TeX 的,Unix 的手册页,电子书,幻灯片演示等。 AsciiDoc は、意味的には DocBook XML のに相当するが、プレーン·テキスト·マークアップの規則を使用して、人間が読めるドキュメントフォーマット、である。 AsciiDoc は文書は、任意のテキストエディタを使用して作成され、「そのまま"または、HTML や DocBook のツールチェーンでサポートされている他のフォーマット、すなわち PDF、TeX の、Unix の man ページ、電子書籍、スライドプレゼンテーションなどにレンダリングすることができます。 - EOS + END lines = pdf.lines (expect lines).to have_size 8 @@ -364,12 +364,12 @@ describe 'Asciidoctor::PDF::Converter - Font' do # intentionally use the deprecated alias for this test it 'should not break line immediately before an ideographic full stop' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :scripts: cjk :pdf-theme: default-with-fallback-font Asciidoctor PDF 是一个 Asciidoctor 转换器,可将 AsciiDoc 文档转换为PDF文档。填料填料。转换器不会创建临时格式。 - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -377,9 +377,9 @@ describe 'Asciidoctor::PDF::Converter - Font' do end it 'should not break line where no-break hyphen is adjacent to formatted text' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar **foo**‑bar‑**foo** - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -388,9 +388,9 @@ describe 'Asciidoctor::PDF::Converter - Font' do # NOTE: this test demonstrates a bug in Prawn it 'should break line if no-break hyphen is isolated into its own fragment' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar **foo**‑**bar**‑**foo** - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -437,11 +437,11 @@ describe 'Asciidoctor::PDF::Converter - Font' do sidebar_font_size: 10, link_font_size: '0.75em', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true **** Check out https://asciidoctor.org[Asciidoctor]' **** - EOS + END normal_text = pdf.find_unique_text 'Check out ' (expect normal_text[:font_size].to_f).to eql 10.0 linked_text = pdf.find_unique_text 'Asciidoctor' @@ -454,11 +454,11 @@ describe 'Asciidoctor::PDF::Converter - Font' do sidebar_font_size: 10, link_font_size: 0.75, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true **** Check out https://asciidoctor.org[Asciidoctor]' **** - EOS + END normal_text = pdf.find_unique_text 'Check out ' (expect normal_text[:font_size].to_f).to eql 10.0 linked_text = pdf.find_unique_text 'Asciidoctor' @@ -471,11 +471,11 @@ describe 'Asciidoctor::PDF::Converter - Font' do sidebar_font_size: 10, link_font_size: '0.75rem', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true **** https://asciidoctor.org[Asciidoctor] **** - EOS + END linked_text = pdf.find_unique_text 'Asciidoctor' (expect linked_text[:font_size].to_f).to eql 9.0 end diff --git a/spec/footnote_spec.rb b/spec/footnote_spec.rb index 4e959055..64f910e3 100644 --- a/spec/footnote_spec.rb +++ b/spec/footnote_spec.rb @@ -4,7 +4,7 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should place footnotes at the end of each chapter when doctype is book' do - pdf = to_pdf <<~'EOS', doctype: :book, attribute_overrides: { 'notitle' => '' }, analyze: true + pdf = to_pdf <<~'END', doctype: :book, attribute_overrides: { 'notitle' => '' }, analyze: true == Chapter A About this thing.footnote:[More about that thing.] And so on. @@ -12,7 +12,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do == Chapter B Yada yada yada. - EOS + END strings, text = pdf.strings, pdf.text (expect strings[2]).to eql '[1]' # superscript @@ -33,7 +33,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should reset footnote number per chapter' do - pdf = to_pdf <<~'EOS', doctype: :book, attribute_overrides: { 'notitle' => '' }, analyze: true + pdf = to_pdf <<~'END', doctype: :book, attribute_overrides: { 'notitle' => '' }, analyze: true == Chapter A About this thing.footnote:[More about that thing.] And so on. @@ -41,7 +41,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do == Chapter B Yada yada yada.footnote:[What does it all mean?] - EOS + END chapter_a_lines = pdf.lines pdf.find_text page_number: 1 (expect chapter_a_lines).to include 'About this thing.[1] And so on.' @@ -53,7 +53,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should add xreftext of chapter to footnote reference to footnote in previous chapter' do - pdf = to_pdf <<~'EOS', doctype: :book, pdf_theme: { footnotes_font_color: 'AA0000' }, analyze: true + pdf = to_pdf <<~'END', doctype: :book, pdf_theme: { footnotes_font_color: 'AA0000' }, analyze: true = Document Title :notitle: :xrefstyle: short @@ -66,7 +66,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do == B Yada yada yada.footnote:fn1[] - EOS + END footnote_texts = pdf.find_text font_color: 'AA0000' (expect footnote_texts.map {|it| it[:page_number] }.uniq).to eql [1] @@ -87,7 +87,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do warnings << str end - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book :notitle: @@ -100,7 +100,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do == Chapter B Yada yada yada.footnote:fn1[] - EOS + END doc = Asciidoctor.convert input, backend: 'pdf', safe: :safe, to_file: (pdf_io = StringIO.new), standalone: true pdf_io.truncate 0 @@ -115,7 +115,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should place footnotes at the end of document when doctype is not book' do - pdf = to_pdf <<~'EOS', attributes_overrides: { 'notitle' => '' }, analyze: true + pdf = to_pdf <<~'END', attributes_overrides: { 'notitle' => '' }, analyze: true == Section A About this thing.footnote:[More about that thing.] And so on. @@ -125,7 +125,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do == Section B Yada yada yada. - EOS + END strings, text = pdf.strings, pdf.text (expect strings[2]).to eql '[1]' @@ -144,13 +144,13 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should place footnotes at bottom of page if start on following page' do pdf = with_content_spacer 10, 700 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { page_margin: 50 }, analyze: true + to_pdf <<~END, pdf_theme: { page_margin: 50 }, analyze: true image::#{spacer_path}[] About this thing.footnote:[More about this thing.] About that thing.footnote:[More about that thing.] And so on. - EOS + END end (expect pdf.pages).to have_size 2 @@ -165,13 +165,13 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should put footnotes directly below last block if footnotes_margin_top is 0' do pdf_theme = { footnotes_margin_top: 0 } - input = <<~'EOS' + input = <<~'END' About this thing.footnote:[More about this thing.] **** sidebar **** - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true horizontal_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -186,11 +186,11 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should push footnotes to bottom of page if footnotes_margin_top is auto' do pdf_theme = { page_margin: 36, footnotes_margin_top: 'auto', footnotes_item_spacing: 0 } - input = <<~'EOS' + input = <<~'END' About this thing.footnote:[More about this thing.] more content - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true footnote_text = pdf.find_unique_text %r/More about / @@ -199,7 +199,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should put footnotes beyond margin below last block of content' do pdf_theme = { sidebar_background_color: 'transparent' } - input = <<~'EOS' + input = <<~'END' About this thing.footnote:[More about this thing.] image::tall.svg[pdfwidth=76.98mm] @@ -207,7 +207,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do **** sidebar **** - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true horizontal_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -221,13 +221,13 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should not allow footnotes to collapse margin below last block of content' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true About this thing.footnote:[More about this thing.] image::tall.svg[pdfwidth=80mm] Some other content. - EOS + END (expect pdf.pages).to have_size 2 main_text = pdf.find_unique_text %r/^About / @@ -238,9 +238,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should not move footnotes down if height exceeds height of page' do footnotes = ['footnote:[Lots more about this thing.]'] * 50 - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true About this thing.#{footnotes} - EOS + END (expect pdf.pages).to have_size 2 main_text = (pdf.find_text %r/About this thing\./)[0] @@ -250,28 +250,28 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should allow footnote to be externalized so it can be used multiple times' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :fn-disclaimer: footnote:disclaimer[Opinions are my own.] A bold statement.{fn-disclaimer} Another audacious statement.{fn-disclaimer} - EOS + END if (Gem::Version.new Asciidoctor::VERSION) < (Gem::Version.new '2.0.11') - expected_lines = <<~'EOS'.lines.map(&:chomp) + expected_lines = <<~'END'.lines.map(&:chomp) A bold statement.[1] Another audacious statement.[2] 1. Opinions are my own. 2. Opinions are my own. - EOS + END footnote_text = (pdf.find_text %r/Opinions/)[-1] else - expected_lines = <<~'EOS'.lines.map(&:chomp) + expected_lines = <<~'END'.lines.map(&:chomp) A bold statement.[1] Another audacious statement.[1] 1. Opinions are my own. - EOS + END footnote_text = pdf.find_unique_text %r/Opinions/ end @@ -280,9 +280,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should keep footnote label with previous adjacent text' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. Go.footnote:a[This is note A.] - EOS + END lines = pdf.lines (expect lines).to have_size 3 @@ -291,9 +291,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should not keep footnote label with previous text if separated by a space' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. Go. footnote:a[This is note A.] - EOS + END text = pdf.text (expect text[1][:string]).to start_with '[' @@ -306,11 +306,11 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should keep footnote label with previous text when line wraps to next page' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true image::tall.svg[pdfwidth=85mm] The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. Go.footnote:a[This is note A.] - EOS + END lines = pdf.lines (expect lines).to have_size 3 @@ -321,14 +321,14 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should keep formatted footnote label with previous text' do - expected_y = ((to_pdf <<~'EOS', analyze: true).find_unique_text '[1]')[:y] + expected_y = ((to_pdf <<~'END', analyze: true).find_unique_text '[1]')[:y] The + Go.^[1]^ - EOS + END - pdf = to_pdf <<~'EOS', pdf_theme: { mark_border_offset: 0 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { mark_border_offset: 0 }, analyze: true The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. Go.#footnote:a[This is note A.]# - EOS + END lines = pdf.lines (expect lines).to have_size 3 @@ -338,9 +338,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should support text formatting in a footnote' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true You can download patches from the product page.footnote:[Only available if you have an _active_ subscription.] - EOS + END (expect pdf.lines[-1]).to eql '1. Only available if you have an active subscription.' active_text = pdf.find_unique_text 'active' @@ -348,28 +348,28 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should support text formatting in an externalized footnote' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :fn-disclaimer: pass:q[footnote:disclaimer[Only available if you have an _active_ subscription.]] You will receive notifications of all product updates.{fn-disclaimer} You can download patches from the product page.{fn-disclaimer} - EOS + END if (Gem::Version.new Asciidoctor::VERSION) < (Gem::Version.new '2.0.11') - expected_lines = <<~'EOS'.lines.map(&:chomp) + expected_lines = <<~'END'.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 + END active_text = (pdf.find_text 'active')[-1] else - expected_lines = <<~'EOS'.lines.map(&:chomp) + expected_lines = <<~'END'.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 + END active_text = pdf.find_unique_text 'active' end @@ -379,9 +379,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should show unresolved footnote reference in red text' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true text.footnote:foo[] - EOS + END foo_text = pdf.find_unique_text '[foo]' (expect foo_text).not_to be_nil @@ -393,9 +393,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should allow theme to configure color of unresolved footnote reference using unresolved role' do (expect do - pdf = to_pdf <<~'EOS', pdf_theme: { role_unresolved_font_color: 'AA0000' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { role_unresolved_font_color: 'AA0000' }, analyze: true text.footnote:foo[] - EOS + END foo_text = pdf.find_unique_text '[foo]' (expect foo_text).not_to be_nil @@ -414,17 +414,17 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end opts = { extension_registry: Asciidoctor::Extensions.create { inline_macro(&fn_inline_macro_impl) } } (expect do - pdf = to_pdf <<~'EOS', (opts.merge analyze: true) + pdf = to_pdf <<~'END', (opts.merge analyze: true) before fn:foo[] after - EOS + END (expect pdf.lines).to eql ['before after'] end).to log_message severity: :WARN, message: 'unknown footnote type: :unknown' end it 'should not crash if footnote is defined in section title with autogenerated ID' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true == Section Titlefootnote:[Footnote about this section title.] - EOS + END (expect pdf.lines[-1]).to eql '1. Footnote about this section title.' end @@ -436,10 +436,10 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do footnotes_font_size: 10, footnotes_item_spacing: 3, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true line a{empty}footnote:[Footnote on line a] + line b{empty}footnote:[Footnote on line b] - EOS + END line_a_text = (pdf.find_text 'line a')[0] line_b_text = (pdf.find_text 'line b')[0] @@ -456,10 +456,10 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do footnotes_font_size: 10, footnotes_item_spacing: nil, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true line a{empty}footnote:[Footnote on line a] + line b{empty}footnote:[Footnote on line b] - EOS + END line_a_text = (pdf.find_text 'line a')[0] line_b_text = (pdf.find_text 'line b')[0] @@ -470,11 +470,11 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should add title to footnotes block if footnotes-title is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :footnotes-title: Footnotes main content.footnote:[This is a footnote, just so you know.] - EOS + END footnotes_title_text = (pdf.find_text 'Footnotes')[0] (expect footnotes_title_text).not_to be_nil @@ -488,11 +488,11 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do footnotes_caption_font_size: '24', footnotes_caption_font_color: '222222', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true :footnotes-title: Footnotes main content.footnote:[This is a footnote, just so you know.] - EOS + END footnotes_title_text = (pdf.find_text 'Footnotes')[0] (expect footnotes_title_text).not_to be_nil @@ -502,13 +502,13 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should create bidirectional links between footnote ref and def' do - pdf = to_pdf <<~'EOS', doctype: :book, attribute_overrides: { 'notitle' => '' } + pdf = to_pdf <<~'END', doctype: :book, attribute_overrides: { 'notitle' => '' } = Document Title == Chapter A About this thing.footnote:[More about that thing.] And so on. - EOS + END annotations = (get_annotations pdf, 1).sort_by {|it| it[:Rect][1] }.reverse (expect annotations).to have_size 2 footnote_label_y = annotations[0][:Rect][3] @@ -520,22 +520,22 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should render footnotes in table cell that are directly adjacent to text' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== |``German``footnote:[Other non-English languages may be supported in the future depending on demand.] | 80footnote:[Width and Length is overridden by the actual terminal or window size, if available.] |=== - EOS + END (expect pdf.lines.slice 0, 2).to eql ['German[1]', '80[2]'] end it 'should use number of target footnote in footnote reference' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true You can download patches from the product page.footnote:sub[Only available if you have an active subscription.] If you have problems running the software, you can submit a support request.footnote:sub[] - EOS + END text = pdf.text p1 = pdf.find_unique_text %r/download/ @@ -549,7 +549,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should not duplicate footnotes that are included in unbreakable blocks' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true Here we go. [%unbreakable] @@ -561,7 +561,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do **** Make it snow.footnote:[dollar bills] - EOS + END combined_text = pdf.strings.join (expect combined_text).to include 'Make it rain.[1]' @@ -574,28 +574,28 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should not duplicate footnotes included in the desc of a horizontal dlist' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [horizontal] ctrl-r:: Make it rain.footnote:[money] ctrl-d:: Make it snow.footnote:[dollar bills] - EOS + END lines = pdf.lines pdf.text (expect lines).to eql ['ctrl-r Make it rain.[1]', 'ctrl-d Make it snow.[2]', '1. money', '2. dollar bills'] end it 'should allow a bibliography ref to be used inside the text of a footnote' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true There are lots of things to know.footnote:[Be sure to read <<wells>> to learn about it.] [bibliography] == Bibliography * [[[wells]]] Ashley Wells. 'Stuff About Stuff'. Publishistas. 2010. - EOS + END lines = pdf.lines (expect lines[0]).to eql 'There are lots of things to know.[1]' @@ -603,9 +603,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do end it 'should allow a link to be used in footnote when media is print' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'media' => 'print' }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'media' => 'print' }, analyze: true When in doubt, search.footnote:[Use a search engine like https://google.com[Google]] - EOS + END lines = pdf.lines (expect lines[0]).to eql 'When in doubt, search.[1]' @@ -624,9 +624,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do base_font_family: 'Missing Null', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true foo{empty}footnote:[Note about foo.] - EOS + END foo_text = pdf.find_unique_text 'foo' foo_text_end = foo_text[:x] + foo_text[:width] @@ -636,9 +636,9 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do it 'should show missing footnote reference as ID in red text' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true bla bla bla.footnote:no-such-id[] - EOS + END (expect pdf.lines).to eql ['bla bla bla.[no-such-id]'] annotation_text = pdf.find_unique_text font_color: 'FF0000' (expect annotation_text).not_to be_nil diff --git a/spec/formatted_text_formatter_spec.rb b/spec/formatted_text_formatter_spec.rb index 79533686..33d8213e 100644 --- a/spec/formatted_text_formatter_spec.rb +++ b/spec/formatted_text_formatter_spec.rb @@ -281,12 +281,12 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should not allow use of fallback font after hard line break to alter line height' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' }, analyze: true [%hardbreaks] けふこえて あさきゆめみし ゑひもせす - EOS + END text = pdf.text (expect text).to have_size 3 @@ -446,11 +446,11 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should add background and border to kbd as defined in theme', visual: true do - to_file = to_pdf_file <<~'EOS', 'text-formatter-kbd.pdf', attribute_overrides: { 'experimental' => '' } + to_file = to_pdf_file <<~'END', 'text-formatter-kbd.pdf', attribute_overrides: { 'experimental' => '' } Press kbd:[q] to exit. Press kbd:[Ctrl,c] to kill the process. - EOS + END (expect to_file).to visually_match 'text-formatter-kbd.pdf' end @@ -460,11 +460,11 @@ describe Asciidoctor::PDF::FormattedText::Formatter do kbd_border_color: nil, } - to_file = to_pdf_file <<~'EOS', 'text-formatter-kbd.pdf', pdf_theme: pdf_theme, attribute_overrides: { 'experimental' => '' } + to_file = to_pdf_file <<~'END', 'text-formatter-kbd.pdf', pdf_theme: pdf_theme, attribute_overrides: { 'experimental' => '' } Press kbd:[q] to exit. Press kbd:[Ctrl,c] to kill the process. - EOS + END (expect to_file).to visually_match 'text-formatter-kbd.pdf' end @@ -474,9 +474,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do kbd_border_width: 0, kbd_border_offset: 0, } - pdf = to_pdf <<~'EOS', analyze: true, pdf_theme: pdf_theme, attribute_overrides: { 'experimental' => '' } + pdf = to_pdf <<~'END', analyze: true, pdf_theme: pdf_theme, attribute_overrides: { 'experimental' => '' } Press kbd:[Ctrl,c] to kill the process. - EOS + END (expect pdf.lines).to eql ['Press Ctrl+c to kill the process.'] end @@ -486,16 +486,16 @@ describe Asciidoctor::PDF::FormattedText::Formatter do kbd_border_width: 0, kbd_border_offset: 0, } - pdf = to_pdf <<~'EOS', analyze: true, pdf_theme: pdf_theme, attribute_overrides: { 'experimental' => '' } + pdf = to_pdf <<~'END', analyze: true, pdf_theme: pdf_theme, attribute_overrides: { 'experimental' => '' } Press kbd:[Ctrl,c] to kill the process. - EOS + END (expect pdf.lines).to eql ['Press Ctrl-c to kill the process.'] end it 'should convert menu macro' do - pdf = to_pdf <<~'EOS', analyze: true, attribute_overrides: { 'experimental' => '' } + pdf = to_pdf <<~'END', analyze: true, attribute_overrides: { 'experimental' => '' } Select menu:File[Quit] to exit. - EOS + END menu_texts = pdf.find_text font_name: 'NotoSerif-Bold' (expect menu_texts).to have_size 3 (expect menu_texts[0][:string]).to eql %(File\u00a0) @@ -508,9 +508,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should support menu macro with only the root level' do - pdf = to_pdf <<~'EOS', analyze: true, attribute_overrides: { 'experimental' => '' } + pdf = to_pdf <<~'END', analyze: true, attribute_overrides: { 'experimental' => '' } The menu:File[] menu is where all the useful stuff is. - EOS + END menu_texts = pdf.find_text font_name: 'NotoSerif-Bold' (expect menu_texts).to have_size 1 (expect menu_texts[0][:string]).to eql 'File' @@ -519,9 +519,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should support menu macro with multiple levels' do - pdf = to_pdf <<~'EOS', analyze: true, attribute_overrides: { 'experimental' => '' } + pdf = to_pdf <<~'END', analyze: true, attribute_overrides: { 'experimental' => '' } Select menu:File[New,Class] to create a new Java class. - EOS + END menu_texts = pdf.find_text font_name: 'NotoSerif-Bold' (expect menu_texts).to have_size 5 (expect menu_texts[0][:string]).to eql %(File\u00a0) @@ -538,9 +538,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should use default caret content for menu if not specified by theme' do - pdf = to_pdf <<~'EOS', analyze: true, pdf_theme: { menu_caret_content: nil }, attribute_overrides: { 'experimental' => '' } + pdf = to_pdf <<~'END', analyze: true, pdf_theme: { menu_caret_content: nil }, attribute_overrides: { 'experimental' => '' } Select menu:File[Quit] to exit. - EOS + END menu_texts = pdf.find_text font_name: 'NotoSerif-Bold' (expect menu_texts).to have_size 1 (expect menu_texts[0][:string]).to eql %(File\u00a0\u203a Quit) @@ -549,9 +549,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should allow theme to control font properties for menu' do - pdf = to_pdf <<~'EOS', analyze: true, pdf_theme: { menu_font_color: 'AA0000', menu_font_size: 10, menu_font_style: 'bold_italic', menu_caret_content: ' > ' }, attribute_overrides: { 'experimental' => '' } + pdf = to_pdf <<~'END', analyze: true, pdf_theme: { menu_font_color: 'AA0000', menu_font_size: 10, menu_font_style: 'bold_italic', menu_caret_content: ' > ' }, attribute_overrides: { 'experimental' => '' } Select menu:File[Quit] to exit. - EOS + END menu_texts = pdf.find_text font_name: 'NotoSerif-BoldItalic' (expect menu_texts).to have_size 1 (expect menu_texts[0][:string]).to eql %(File > Quit) @@ -561,11 +561,11 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should keep caret with previous item if menu wraps' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :experimental: This is a long-winded explanation that finally gets to the point by instructing you to use menu:File[Make,Class] to create a new class. - EOS + END lines = pdf.lines (expect lines).to have_size 2 (expect lines[1]).not_to start_with ?\u203a @@ -578,14 +578,14 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should be able to reference section title containing icon' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font [#reference] == icon:cogs[] Heading See <<reference>>. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -634,42 +634,42 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should not lowercase tags when applying lowercase text transform' do - pdf = to_pdf <<~'EOS', pdf_theme: { sidebar_text_transform: 'lowercase' } + pdf = to_pdf <<~'END', pdf_theme: { sidebar_text_transform: 'lowercase' } **** image:TuxTheLinuxPenguin.png[width=20] <= How this fella came to be the Linux mascot. **** - EOS + END (expect get_images pdf).to have_size 1 end it 'should apply width and alignment specified by span tag', visual: true do %w(left center right).each do |align| - to_file = to_pdf_file <<~EOS, %(text-formatter-align-#{align}-within-width.pdf) + to_file = to_pdf_file <<~END, %(text-formatter-align-#{align}-within-width.pdf) |+++<span style="width: 1in; align: #{align}; background-color: #ffff00">hi</span>+++| - EOS + END (expect to_file).to visually_match %(text-formatter-align-#{align}-within-width.pdf) end end it 'should preserve word spacing in multi-word phrase that has a border offset', visual: true do pdf_theme = { role_wild_background_color: 'CCCCCC', role_wild_border_offset: 1.5 } - to_file = to_pdf_file <<~EOS, 'text-formatter-marked-phrase-word-spacing.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'text-formatter-marked-phrase-word-spacing.pdf', pdf_theme: pdf_theme To tame the [.wild]#extremely wild and dangerous wolpertingers#, we needed to build a *charm*. But ultimate victory could only be won if we divined the true name of the warlock. - EOS + END (expect to_file).to visually_match 'text-formatter-marked-phrase-word-spacing.pdf' end it 'should not warn if text contains invalid markup in scratch document' do # NOTE: this assertion will fail if the message is logged multiple times (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%unbreakable] -- before +++<foo>bar</foo>+++ after -- - EOS + END (expect pdf.lines).to eql ['before <foo>bar</foo> after'] end).to log_message severity: :ERROR, message: /^failed to parse formatted text:/ @@ -735,11 +735,11 @@ describe Asciidoctor::PDF::FormattedText::Formatter do role_underline_text_decoration_color: '0000AA', role_underline_text_decoration_width: 0.5, } - input = <<~'EOS' + input = <<~'END' [.underline]#underline# [.line-through]#line-through# - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :line lines = pdf.lines (expect lines).to have_size 2 @@ -829,9 +829,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should support built-in pre-wrap role on phrase' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [.pre-wrap]`0 1 2 3 5` - EOS + END shout_text = pdf.text[0] (expect shout_text[:string]).to eql '0 1 2 3 5' @@ -901,11 +901,11 @@ describe Asciidoctor::PDF::FormattedText::Formatter do role_important_text_decoration_color: '0000AA', role_important_text_decoration_width: 0.5, } - input = <<~'EOS' + input = <<~'END' [.important]#important# [.delete]#delete# - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :line lines = pdf.lines (expect lines).to have_size 2 @@ -937,9 +937,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do role_capital_text_transform: 'capitalize', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [.lower]#WHISPER# [.upper]#shout# [.capital]#here me roar# - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -952,9 +952,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do role_upper_text_transform: 'uppercase', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [.upper.red]#shout# - EOS + END shout_text = pdf.text[0] (expect shout_text[:font_color]).to eql 'FF0000' @@ -962,11 +962,11 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should apply text transform to value of attribute reference' do - pdf = to_pdf <<~'EOS', pdf_theme: { role_upper_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { role_upper_text_transform: 'uppercase' }, analyze: true :brandname: acme [.upper]#{brandname}# - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -974,10 +974,10 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should apply text transform to enclosed formatted text' do - pdf = to_pdf <<~'EOS', pdf_theme: { role_upper_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { role_upper_text_transform: 'uppercase' }, analyze: true [.upper]#_please_ transform *bob & carl* + to `uppercase`# - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -992,9 +992,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do end it 'should apply smallcaps text transform to phrase' do - pdf = to_pdf <<~'EOS', pdf_theme: { role_sc_text_transform: 'smallcaps' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { role_sc_text_transform: 'smallcaps' }, analyze: true HTML stands for [.sc]#HyperText Markup Language# - EOS + END (expect pdf.lines).to eql ['HTML stands for HʏᴘᴇʀTᴇxᴛ Mᴀʀᴋᴜᴘ Lᴀɴɢᴜᴀɢᴇ'] end @@ -1004,9 +1004,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do codespan_font_size: '0.75em', role_mono_font_size: '0.875em', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true == `MIN` and [.mono]`MAX` - EOS + END min_text = (pdf.find_text 'MIN')[0] normal_text = (pdf.find_text ' and ')[0] @@ -1031,9 +1031,9 @@ describe Asciidoctor::PDF::FormattedText::Formatter do link_font_color: '0000AA', role_hlink_font_color: '00AA00', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true == https://asciidoctor.org[Asciidoctor,role=hlink] - EOS + END link_text = (pdf.find_text 'Asciidoctor')[0] (expect link_text[:font_color]).to eql '00AA00' @@ -1184,7 +1184,7 @@ describe Asciidoctor::PDF::FormattedText::Formatter do role_red_font_color: 'FF0000', role_blue_font_color: '0000FF', } - pdf = to_pdf <<~'EOS', analyze: true, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', analyze: true, pdf_theme: pdf_theme = Document Title :doctype: book :notitle: @@ -1195,7 +1195,7 @@ describe Asciidoctor::PDF::FormattedText::Formatter do == [.blue]#Blue Chapter# == Default Chapter - EOS + END red_section_text = pdf.find_text 'Red Chapter' blue_section_text = pdf.find_text 'Blue Chapter' @@ -1249,15 +1249,15 @@ describe Asciidoctor::PDF::FormattedText::Formatter do it 'should not use the closing single quotation mark as apostrophe' do pdf_theme = { quotes: %w(« » ‹ ›) } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true Apostrophes`' substitution shouldn`'t match '`single quoted`' - EOS + END (expect pdf.text[0][:string]).to eql %(Apostrophes\u2019 substitution shouldn\u2019t match \u2039single quoted\u203a) end it 'should use user-defined quotation marks in the TOC' do pdf_theme = { quotes: %w(« » ‹ ›) } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document '`Title`' :doctype: book :toc: @@ -1266,25 +1266,25 @@ describe Asciidoctor::PDF::FormattedText::Formatter do == '`Single Quoted`' - EOS + END (expect (pdf.find_text %(Document \u2039Title\u203a))).to have_size 1 (expect (pdf.find_text %(\u00abDouble Quoted\u00bb))).to have_size 2 (expect (pdf.find_text %(\u2039Single Quoted\u203a))).to have_size 2 end it 'should keep closing double quote attached to trailing ellipsis' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['filler'] * 15).join ' '} ||||| "`and then...`" - EOS + END lines = pdf.lines (expect lines).to have_size 2 (expect lines[1]).to start_with 'then' end it 'should keep closing single quote attached to trailing ellipsis' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['filler'] * 15).join ' '} .|||||. '`and then...`' - EOS + END lines = pdf.lines (expect lines).to have_size 2 (expect lines[1]).to start_with 'then' diff --git a/spec/hyphens_spec.rb b/spec/hyphens_spec.rb index 9f79553b..a062b192 100644 --- a/spec/hyphens_spec.rb +++ b/spec/hyphens_spec.rb @@ -5,11 +5,11 @@ require_relative 'spec_helper' # NOTE: text-hyphen may not be available when building RPM, so check for it describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelpers.gem_available? 'text-hyphen'), &(proc do it 'should hyphenate text in paragraph if hyphens attribute is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :hyphens: This story chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -21,9 +21,9 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper it 'should hyphenate text in paragraph if base-hyphens key in theme is set to truthy value' do [true, ''].each do |base_hyphens| - pdf = to_pdf <<~'EOS', pdf_theme: { base_hyphens: base_hyphens }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_hyphens: base_hyphens }, analyze: true This story chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -33,11 +33,11 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should not hyphenate text in paragraph if base-hyphens key in theme is set but hyphens attribute is unset' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_hyphens: '' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_hyphens: '' }, analyze: true :!hyphens: This story chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -45,14 +45,14 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should hyphenate text split across multiple lines' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :hyphens: This story chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -67,7 +67,7 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should honor hyphenation exceptions when word is adjacent to a non-word character' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :hyphens: :lang: nl @@ -75,7 +75,7 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper |=== | souveniertjes! |=== - EOS + END (expect pdf.lines).to eql [%(souve\u00ad), 'niertjes!'] @@ -85,7 +85,7 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should hyphenate text in table cell in table head if hyphens attribute is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :hyphens: :pdf-page-size: A7 @@ -93,7 +93,7 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper |=== |This story chronicles the inexplicable hazards and tremendously vicious beasts the team must conquer and vanquish. |=== - EOS + END lines = pdf.lines (expect lines.size).to be > 2 @@ -103,13 +103,13 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should hyphenate text in table cell in table body if hyphens attribute is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :hyphens: |=== |This story chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish. |=== - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -118,11 +118,11 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should hyphenate text in a list item if hyphens attribute is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :hyphens: * This story chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -131,11 +131,11 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should hyphenate formatted word' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :hyphens: This story chronicles the inexplicable hazards and vicious beasts a team must conquer and *vanquish* on the journey to discover the true power of Open Source. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -150,12 +150,12 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper it 'should not mangle formatting when hyphenating text' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font :hyphens: This story chronicles the inexplicable icon:biohazard@fas[] and vicious icon:paw@fas[] teams must conquer on the journey to discover the true power of Open Source. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -167,13 +167,13 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should set hyphenation language based on value of hyphens attribute' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :hyphens: DE Mitwirkende sind immer willkommen. Neue Mitwirkende sind immer willkommen! Wenn Sie Fehler oder Auslassungen im Quellcode, in der Dokumentation oder im Inhalt der Website entdecken, zögern Sie bitte nicht, ein Problem zu melden oder eine Pull Request mit einem Fix zu öffnen. - EOS + END lines = pdf.lines (expect lines).to have_size 3 @@ -182,14 +182,14 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should set hyphenation language based on value of lang attribute if value of hyphens attribute is empty' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :lang: DE :hyphens: Mitwirkende sind immer willkommen. Neue Mitwirkende sind immer willkommen! Wenn Sie Fehler oder Auslassungen im Quellcode, in der Dokumentation oder im Inhalt der Website entdecken, zögern Sie bitte nicht, ein Problem zu melden oder eine Pull Request mit einem Fix zu öffnen. - EOS + END lines = pdf.lines (expect lines).to have_size 3 @@ -199,14 +199,14 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper it 'should apply hyphenation when line is advanced to next page' do pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, analyze: true + to_pdf <<~END, analyze: true = Document Title :hyphens: image::#{spacer_path}[] foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar paragraph - EOS + END end lines = pdf.lines pdf.find_text page_number: 2 @@ -216,11 +216,11 @@ describe 'Asciidoctor::PDF::Converter - Hyphens', if: (RSpec::ExampleGroupHelper end it 'should show visible hyphen at locate where word is split across lines', visual: true do - to_file = to_pdf_file <<~'EOS', 'hyphens-word-break.pdf' + to_file = to_pdf_file <<~'END', 'hyphens-word-break.pdf' :hyphens: This story chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish. - EOS + END (expect to_file).to visually_match 'hyphens-word-break.pdf' end diff --git a/spec/icon_spec.rb b/spec/icon_spec.rb index 546372a8..c1c76971 100644 --- a/spec/icon_spec.rb +++ b/spec/icon_spec.rb @@ -10,12 +10,12 @@ describe 'Asciidoctor::PDF::Converter - Icon' do it 'should read icon from image file when icons mode is image' do (expect do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image :icons: :iconsdir: {imagesdir} Look for files with the icon:logo[] icon. - EOS + END images = pdf.images (expect images).to have_size 1 @@ -25,12 +25,12 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should log warning if image file for icon not readable' do - input = <<~'EOS' + input = <<~'END' :icons: :icontype: svg I looked for icon:not-found[], but it was no where to be seen. - EOS + END (expect do pdf = to_pdf input, analyze: :image images = pdf.images @@ -46,12 +46,12 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should use icon name from specified icon set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font :icon-set: fas A icon:wrench[] ought to fix it. - EOS + END wink_text = pdf.find_text ?\uf0ad (expect wink_text).to have_size 1 (expect wink_text[0][:font_name]).to eql 'FontAwesome5Free-Solid' @@ -67,12 +67,12 @@ describe 'Asciidoctor::PDF::Converter - Icon' do %W(mdi alien \uf089 MaterialDesignIcons), ].each do |icon_set, icon_name, char_code, font_name| next if icon_set == 'mdi' && !supports_mdi - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :icons: font :icon-set: #{icon_set} Look for the icon:#{icon_name}[] icon. - EOS + END icon_text = pdf.text[1] (expect icon_text).not_to be_nil (expect icon_text[:string]).to eql char_code @@ -81,34 +81,34 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should support icon set as suffix on icon name' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font A icon:wrench@fas[] ought to fix it. - EOS + END wink_text = pdf.find_text ?\uf0ad (expect wink_text).to have_size 1 (expect wink_text[0][:font_name]).to eql 'FontAwesome5Free-Solid' end it 'should support icon set as prefix on icon name' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font A icon:fas-wrench[] ought to fix it. - EOS + END wink_text = pdf.find_text ?\uf0ad (expect wink_text).to have_size 1 (expect wink_text[0][:font_name]).to eql 'FontAwesome5Free-Solid' end it 'should support icon set as prefix on icon name even if icon set is configured globally' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font :icon-set: fab A icon:fas-wrench[] ought to fix it. - EOS + END wink_text = pdf.find_text ?\uf0ad (expect wink_text).to have_size 1 (expect wink_text[0][:font_name]).to eql 'FontAwesome5Free-Solid' @@ -116,22 +116,22 @@ describe 'Asciidoctor::PDF::Converter - Icon' do it 'should not support icon set as prefix on icon name if explicit icon set is specified' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font A icon:fas-wrench[set=fab] ought to fix it. - EOS + END wink_text = pdf.find_text ?\uf0ad (expect wink_text).to be_empty end).to log_message severity: :WARN, message: 'fas-wrench is not a valid icon name in the fab icon set' end it 'should apply larger font size to icon if size is lg' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font If the icon:wrench[] doesn't do it, try a icon:wrench[lg] one. - EOS + END wrench_texts = pdf.find_text ?\uf0ad (expect wrench_texts).to have_size 2 @@ -142,34 +142,34 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should apply specified custom font size to icon' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font I icon:fas-heart[1.2x] AsciiDoc - EOS + END heart_text = pdf.find_unique_text ?\uf004 (expect heart_text[:font_size]).to eql 12.6 end it 'should use inherited size if font size is 1x' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font I icon:fas-heart[1x] AsciiDoc - EOS + END heart_text = pdf.find_unique_text ?\uf004 (expect heart_text[:font_size]).to eql pdf.text[0][:font_size] end it 'should reserve 1em of space for fw icon' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font :icon-set: fas *|* icon:arrows-alt-h[fw] *|* icon:arrows-alt-v[fw] *|* - EOS + END guide_text = pdf.find_text '|', font_name: 'NotoSerif-Bold' first_icon_gap = (guide_text[1][:x] - guide_text[0][:x]).round 2 second_icon_gap = (guide_text[2][:x] - guide_text[1][:x]).round 2 @@ -177,12 +177,12 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should align fw icon in center of 1em space', visual: true do - to_file = to_pdf_file <<~'EOS', 'icon-fw.pdf' + to_file = to_pdf_file <<~'END', 'icon-fw.pdf' :icons: font :icon-set: fas *|* icon:arrows-alt-h[fw] *|* icon:arrows-alt-v[fw] *|* - EOS + END (expect to_file).to visually_match 'icon-fw.pdf' end @@ -193,11 +193,11 @@ describe 'Asciidoctor::PDF::Converter - Icon' do ['icon:fas-no-such-icon[]', 'fas no such icon'], ].each do |macro, alt| (expect do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :icons: font #{macro} will surely fail. - EOS + END text = pdf.text (expect text).to have_size 1 (expect text[0][:string]).to eql %([#{alt}] will surely fail.) @@ -207,11 +207,11 @@ describe 'Asciidoctor::PDF::Converter - Icon' do it 'should remap legacy icon name if icon set is not specified and report remapping' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font Click the icon:hdd-o[] icon to see your files. - EOS + END hdd_text = pdf.find_text ?\uf0a0 (expect hdd_text).to have_size 1 (expect hdd_text[0][:font_name]).to eql 'FontAwesome5Free-Regular' @@ -220,11 +220,11 @@ describe 'Asciidoctor::PDF::Converter - Icon' do it 'should resolve non-legacy icon name if icon set is not specified and report icon set in which it was found' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font Time to upgrade your icon set icon:smile-wink[] - EOS + END wink_text = pdf.find_text ?\uf4da (expect wink_text).to have_size 1 (expect wink_text[0][:font_name]).to eql 'FontAwesome5Free-Regular' @@ -232,11 +232,11 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should apply link to icon if link attribute is set and font-based icons are enabled' do - input = <<~'EOS' + input = <<~'END' :icons: font gem icon:download[link=https://rubygems.org/downloads/asciidoctor-pdf-1.5.4.gem, window=_blank] - EOS + END pdf = to_pdf input annotations = get_annotations pdf, 1 @@ -255,9 +255,9 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should apply link to alt text if link attribute is set and font-based icons are not enabled' do - input = <<~'EOS' + input = <<~'END' gem icon:download[link=https://rubygems.org/downloads/asciidoctor-pdf-1.5.4.gem, window=_blank] - EOS + END pdf = to_pdf input annotations = get_annotations pdf, 1 @@ -274,11 +274,11 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should apply styles from role to icon' do - pdf = to_pdf <<~'EOS', pdf_theme: { role_red_font_color: 'FF0000' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { role_red_font_color: 'FF0000' }, analyze: true :icons: font icon:heart[role=red] - EOS + END heart_text = pdf.text[0] (expect heart_text[:string]).to eql ?\uf004 @@ -287,13 +287,13 @@ describe 'Asciidoctor::PDF::Converter - Icon' do end it 'should parse icon inside kbd macro' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :experimental: :icons: font :icon-set: fas Press kbd:[Alt,icon:arrow-up[\]] to move the line up. - EOS + END keyseq_text = pdf.text.find_all {|candidate| ['Alt', %(\u202f+\u202f), ?\uf062].include? candidate[:string] } (expect keyseq_text.size).to be 3 diff --git a/spec/image_float_spec.rb b/spec/image_float_spec.rb index 1ed291a8..140e590f 100644 --- a/spec/image_float_spec.rb +++ b/spec/image_float_spec.rb @@ -17,11 +17,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should ignore float attribute is value is unknown' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=center] #{lorem_ipsum '1-sentence'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -31,11 +31,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should wrap paragraph around left of image with float right' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=right] #{lorem_ipsum '1-sentence'} - EOS + END images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images (expect images).to have_size 1 @@ -50,11 +50,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should ignore align attribute if float attribute is set' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,align=left,float=right] #{lorem_ipsum '1-sentence'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] (expect image[:x].to_f).to eql page_width - page_margin - image[:width].to_f @@ -66,11 +66,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should wrap paragraph around right of image with float left' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=left] #{lorem_ipsum '1-sentence'} - EOS + END images = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images (expect images).to have_size 1 @@ -83,13 +83,13 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should apply hyphenation to paragraph in float box if hyphens is set', if: (gem_available? 'text-hyphen'), &(proc do - input = <<~EOS + input = <<~END :hyphens: image::rect.png[pdfwidth=3in,float=right] This story chronicles the inexplicable hazards and tremendously vicious beasts the team must conquer and vanquish. - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = pdf.lines @@ -100,23 +100,23 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should apply base font color to text within float box' do pdf_theme[:base_font_color] = '0000AA' - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=right] #{lorem_ipsum '1-sentence'} - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true (expect pdf.text[0][:font_color]).to eql pdf_theme[:base_font_color] end it 'should fit single paragraph within float box' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=right] #{lorem_ipsum '1-sentence'} *fin* - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -129,11 +129,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should fit multiple paragraphs within float box' do ref_input = lorem_ipsum '2-sentences-2-paragraphs' - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=left] #{ref_input} - EOS + END pdf = to_pdf ref_input, pdf_theme: (pdf_theme.merge section_indent: [228, 0]), analyze: true fragments = pdf.text @@ -153,11 +153,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should wrap current paragraph around bottom of image if it extends beyond image' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=left] #{lorem_ipsum '4-sentences-1-paragraph'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -174,11 +174,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should wrap second paragraph around bottom of image if it extends beyond image' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=left] #{lorem_ipsum '4-sentences-2-paragraphs'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -192,12 +192,12 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should wrap around single-line caption on bottom of image' do pdf_theme[:image_caption_font_color] = 'AA0000' - input = <<~EOS + input = <<~END .Image description image::rect.png[pdfwidth=2in,float=left] #{lorem_ipsum '4-sentences-2-paragraphs'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -216,12 +216,12 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should wrap around multi-line caption on bottom of image' do pdf_theme[:image_caption_font_color] = 'AA0000' - input = <<~EOS + input = <<~END .Long image description image::rect.png[pdfwidth=2in,float=left] #{lorem_ipsum '4-sentences-2-paragraphs'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -241,12 +241,12 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should wrap around bottom of image when image has single-line caption on top' do pdf_theme[:image_caption_end] = 'top' pdf_theme[:image_caption_font_color] = 'AA0000' - input = <<~EOS + input = <<~END .Image description image::rect.png[pdfwidth=2in,float=left] #{lorem_ipsum '4-sentences-2-paragraphs'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -264,12 +264,12 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should wrap around bottom of image when image has multi-line caption on top' do pdf_theme[:image_caption_end] = 'top' pdf_theme[:image_caption_font_color] = 'AA0000' - input = <<~EOS + input = <<~END .Long image description image::rect.png[pdfwidth=2in,float=left] #{lorem_ipsum '4-sentences-2-paragraphs'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -285,12 +285,12 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should place caption directly under image when image floats to the right' do - input = <<~EOS + input = <<~END .Image description image::rect.png[pdfwidth=3in,float=right] #{lorem_ipsum '1-sentence'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -300,11 +300,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should allow theme to specify float gap using single value' do pdf_theme[:image_float_gap] = 24 - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=left] #{lorem_ipsum '4-sentences-2-paragraphs'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -321,11 +321,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should allow theme to specify float gap using array value (side, bottom)' do pdf_theme[:image_float_gap] = [0, 0] - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=left] #{lorem_ipsum '4-sentences-2-paragraphs'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -342,18 +342,18 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should apply base font color to text that extends beyond image' do pdf_theme[:base_font_color] = '0000AA' - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=right] #{lorem_ipsum '4-sentences-1-paragraph'} - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true (expect pdf.text[-1][:font_color]).to eql pdf_theme[:base_font_color] end it 'should add anchors to paragraphs in float box' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=right] [#first] @@ -361,7 +361,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do [#second] #{lorem_ipsum '1-sentence'} - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme names = get_names pdf @@ -370,12 +370,12 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should apply text-align to text within float box' do - input = <<~'EOS' + input = <<~'END' image::rect.png[pdfwidth=3in,float=right] [.text-center] center me - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] text = (to_pdf input, pdf_theme: pdf_theme, analyze: true).text[0] @@ -389,12 +389,12 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do pdf_theme[:role_important_text_align] = 'center' pdf_theme[:role_important_font_color] = 'AA0000' pdf_theme[:role_important_text_transform] = 'uppercase' - input = <<~'EOS' + input = <<~'END' image::rect.png[pdfwidth=3in,float=right] [.important] center me - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] text = (to_pdf input, pdf_theme: pdf_theme, analyze: true).text[0] @@ -407,11 +407,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should apply text formatting to wrapped text' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=left] #{((lorem_ipsum '4-sentences-1-paragraph').sub 'Lorem', '*Lorem*').sub 'tempor', '_tempor_'} - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true bold_text = pdf.find_text font_name: 'NotoSerif-Bold' @@ -426,7 +426,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do pdf_theme[:role_lead_line_height] = 1.5 pdf_theme[:role_lead_font_family] = 'M+ 1p Fallback' pdf_theme[:role_muted_font_color] = '999999' - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=2.25in,float=left] [.muted] @@ -437,7 +437,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do [.muted] #{lorem_ipsum '1-sentence'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -458,13 +458,13 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do pdf_theme.update \ prose_text_indent_inner: 18, prose_margin_inner: 0 - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=50%,float=right] #{lorem_ipsum '4-sentences-2-paragraphs'} fin. - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true first_line_first_para_text = pdf.find_unique_text %r/^Lorem/ @@ -482,7 +482,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should not end float box if next unstyled paragraph will fit' do with_content_spacer 180, 220 do |spacer_path| - input = <<~EOS + input = <<~END image::#{spacer_path}[float=left] #{lorem_ipsum '1-sentence'} @@ -491,7 +491,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do #{lorem_ipsum '2-sentences-1-paragraph'} #{lorem_ipsum '1-sentence'} - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true expected_x = 228.0 @@ -502,20 +502,20 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should position next block below wrapped content when wrapped content extends past image' do pdf_theme.update code_border_radius: 0, code_border_color: '0000EE', code_border_width: [0.5, 0, 0, 0] - ref_input = <<~'EOS' + ref_input = <<~'END' para ---- code block ---- - EOS + END expected_margin = ( ((to_pdf ref_input, pdf_theme: pdf_theme, analyze: true).find_unique_text 'para')[:y] - (to_pdf ref_input, pdf_theme: pdf_theme, analyze: :line).lines[0][:from][:y] ).round 5 - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=1.75in,float=left] #{lorem_ipsum '2-paragraphs'} @@ -523,7 +523,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do ---- code block ---- - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] code_block_top = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines[0][:from][:y] @@ -539,13 +539,13 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should end float box after first paragraph if next block is not a paragraph' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=3in,float=left] #{lorem_ipsum '1-sentence'} term:: desc - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -559,11 +559,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should not create float box if next block is not a paragraph' do - input = <<~'EOS' + input = <<~'END' image::rect.png[pdfwidth=50%,float=right] term:: desc - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -579,11 +579,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should continue below image if next paragraph does not fit in remaining height' do pdf_theme[:role_outline_border_width] = 0.5 pdf_theme[:role_outline_border_color] = '0000EE' - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=1.5in,float=left] #{(lorem_ipsum '4-sentences-2-paragraphs').gsub %r/non|nam/, '[.outline]#\\0#'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -597,11 +597,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should indent and align next paragraph if next paragraph does not fit in remaining height and prose-text-indent is set' do pdf_theme[:prose_text_indent] = 18 - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=1.5in,float=left] #{(lorem_ipsum '4-sentences-2-paragraphs').sub 'Blandit', %([.text-left]\nBlandit)} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -614,13 +614,13 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should advance cursor to block bottom if next paragraph does not fit and cursor is above block bottom' do pdf_theme[:role_outline_border_width] = 0.5 pdf_theme[:role_outline_border_color] = '0000EE' - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=110.6pt,float=left] #{lorem_ipsum '2-sentences-1-paragraph'} [.outline]#fin#. - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] expected_y = image[:y] - image[:height] - float_gap_b @@ -630,7 +630,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should end float box if inked text depletes float box' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=1.2in,float=left] #{lorem_ipsum '2-sentences-1-paragraph'} @@ -638,7 +638,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do after after that - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -651,11 +651,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do pdf_theme[:role_outline_border_width] = 0.5 pdf_theme[:role_outline_border_color] = '0000EE' [[116.5, 6], [117, 22]].each do |pdfwidth, expected_gap| - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=#{pdfwidth}pt,float=left] #{(lorem_ipsum '4-sentences-1-paragraph').sub 'lobortis', '[.outline]#lobortis#'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] rects = (to_pdf input, pdf_theme: pdf_theme, analyze: :rect).rectangles @@ -668,7 +668,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should allow paragraph that starts in float box to extend to next page' do with_content_spacer 10, 596 do |spacer_path| - input = <<~EOS + input = <<~END image::#{spacer_path}[] image::rect.png[pdfwidth=2in,float=left] @@ -678,7 +678,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do <<< at top - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -698,7 +698,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should run float box to bottom of page if taller than remaining space on page' do with_content_spacer 10, 605 do |spacer_path| - input = <<~EOS + input = <<~END image::#{spacer_path}[] image::rect.png[pdfwidth=2in,float=left] @@ -708,7 +708,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do <<< at top - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -728,7 +728,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do it 'should not continue float box if bottom margin of last paragraph starts new page' do with_content_spacer 10, 630 do |spacer_path| - input = <<~EOS + input = <<~END image::#{spacer_path}[] image::rect.png[pdfwidth=1.5in,float=left] @@ -736,7 +736,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do #{lorem_ipsum '2-sentences-2-paragraphs'} at top - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -752,13 +752,13 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should float image inside a delimited block' do - input = <<~EOS + input = <<~END **** image::rect.png[pdfwidth=3in,float=left] #{lorem_ipsum '4-sentences-2-paragraphs'} **** - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -772,7 +772,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should support multiple image floats in same document', visual: true do - input = <<~EOS + input = <<~END Start. image::rect.png[pdfwidth=2.5in,float=left] @@ -798,7 +798,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do |=== fin. - EOS + END to_file = to_pdf_file input, 'image-float.pdf', pdf_theme: pdf_theme (expect to_file).to visually_match 'image-float.pdf' @@ -810,13 +810,13 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do sidebar_border_width: [0.5, 0], sidebar_border_color: '0000EE', sidebar_background_color: 'transparent' - input = <<~EOS + input = <<~END **** image::rect.png[pdfwidth=3in,float=right] #{lorem_ipsum '2-sentences-1-paragraph'} **** - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -832,13 +832,13 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do sidebar_border_width: [0.5, 0], sidebar_border_color: '0000EE', sidebar_background_color: 'transparent' - input = <<~EOS + input = <<~END **** image::rect.png[pdfwidth=3in,float=right] #{lorem_ipsum '4-sentences-2-paragraphs'} **** - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -852,13 +852,13 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do sidebar_border_width: [0.5, 0], sidebar_border_color: '0000EE', sidebar_background_color: 'transparent' - input = <<~EOS + input = <<~END **** image::rect.png[pdfwidth=2.25in,float=right] #{lorem_ipsum '2-paragraphs'} **** - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -867,22 +867,22 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should not process paragraph preceded by paragraph without an active float box' do - input = <<~'EOS' + input = <<~'END' paragraph another paragraph - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true pdf.text.each {|fragment| (expect fragment[:x]).to eql page_margin } end it 'should not process paragraph preceded by image without float attribute' do - input = <<~'EOS' + input = <<~'END' image::rect.png[pdfwidth=3in] paragraph - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -894,11 +894,11 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do end it 'should not process paragraph preceded by image with float attribute that spans width of content area' do - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=100%,float=left] #{lorem_ipsum '1-sentence'} - EOS + END image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -916,7 +916,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do backend = %(pdf#{ext_class.object_id}) source_lines[0] = %( register_for '#{backend}'\n) ext_class.class_eval source_lines.join, source_file - input = <<~EOS + input = <<~END image::rect.png[pdfwidth=50%,float=left] #{lorem_ipsum '1-sentence'} @@ -927,7 +927,7 @@ describe 'Asciidoctor::PDF::Converter - Image Float' do ---- #{lorem_ipsum '1-sentence'} - EOS + END image = (to_pdf input, backend: backend, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, backend: backend, pdf_theme: pdf_theme, analyze: true diff --git a/spec/image_spec.rb b/spec/image_spec.rb index 2bafa64a..73acd5bf 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -5,9 +5,9 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Image' do it 'should not crash when converting block image if theme is blank' do image_data = File.binread example_file 'wolpertinger.jpg' - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => (fixture_file 'bare-theme.yml'), 'imagesdir' => examples_dir } + pdf = to_pdf <<~'END', attribute_overrides: { 'pdf-theme' => (fixture_file 'bare-theme.yml'), 'imagesdir' => examples_dir } image::wolpertinger.jpg[] - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 (expect images[0].data).to eql image_data @@ -15,11 +15,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not crash if doctitle contains inline raster image with no explicit width' do expected_image_data = File.binread fixture_file 'tux.jpg' - pdf = to_pdf <<~'EOS', pdf_theme: { heading_h1_font_size: 42 }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: { heading_h1_font_size: 42 }, analyze: :image = Document Title image:tux.jpg[] content - EOS + END images = pdf.images (expect images).to have_size 1 (expect images[0][:data]).to eql expected_image_data @@ -29,11 +29,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not crash if doctitle contains inline raster image with only scale' do expected_image_data = File.binread fixture_file 'tux.jpg' - pdf = to_pdf <<~'EOS', pdf_theme: { heading_h1_font_size: 42 }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: { heading_h1_font_size: 42 }, analyze: :image = Document Title image:tux.jpg[scale=.5] content - EOS + END images = pdf.images (expect images).to have_size 1 (expect images[0][:data]).to eql expected_image_data @@ -44,11 +44,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not crash if doctitle contains inline image with data URI target' do image_data = File.binread fixture_file 'square.jpg' encoded_image_data = Base64.strict_encode64 image_data - pdf = to_pdf <<~EOS, analyze: :image + pdf = to_pdf <<~END, analyze: :image = Document Title image:data:image/jpg;base64,#{encoded_image_data}[] content - EOS + END images = pdf.images (expect images).to have_size 1 (expect images[0][:data]).to eql image_data @@ -57,11 +57,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should not crash if doctitle contains inline SVG image with no explicit width' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_h1_font_size: 42 }, analyze: :rect + pdf = to_pdf <<~'END', pdf_theme: { heading_h1_font_size: 42 }, analyze: :rect = Document Title image:square.svg[] content - EOS + END (expect pdf.rectangles).to have_size 1 rect = pdf.rectangles[0] (expect rect[:width]).to eql 200.0 @@ -70,11 +70,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not crash if section title contains inline image with no explicit width' do expected_image_data = File.binread fixture_file 'tux.jpg' - pdf = to_pdf <<~'EOS', pdf_theme: { heading_h2_font_size: 36 }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: { heading_h2_font_size: 36 }, analyze: :image == Section Title image:tux.jpg[] content - EOS + END images = pdf.images (expect images).to have_size 1 (expect images[0][:data]).to eql expected_image_data @@ -83,12 +83,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should place anchor directly at top of block image' do - input = <<~'EOS' + input = <<~'END' paragraph [#tux] image::tux.png[Tux] - EOS + END images = (to_pdf input, analyze: :image).images pdf = to_pdf input @@ -97,12 +97,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should offset anchor from top of block image by amount of block_anchor_top' do - input = <<~'EOS' + input = <<~'END' paragraph [#tux] image::tux.png[Tux] - EOS + END pdf_theme = { block_anchor_top: -12 } @@ -113,12 +113,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should place anchor at top of block image if advanced to next page' do - input = <<~'EOS' + input = <<~'END' paragraph [#tall-diagram] image::tall-diagram.png[Tall Diagram] - EOS + END images = (to_pdf input, analyze: :image).images pdf = to_pdf input @@ -129,9 +129,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do context 'imagesdir' do it 'should resolve target of block image relative to imagesdir', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-wolpertinger.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-wolpertinger.pdf', attribute_overrides: { 'imagesdir' => examples_dir } image::wolpertinger.jpg[,144] - EOS + END (expect to_file).to visually_match 'image-wolpertinger.pdf' end @@ -154,7 +154,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should wrap alt text of block image if it exceeds width of table cell' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols="1,3"] |=== a| @@ -164,7 +164,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do s|second s|row |=== - EOS + END (expect pdf.pages).to have_size 1 alt_text_lines = pdf.lines pdf.text.select {|it| it[:x] == 51.24 && it[:font_name] != 'NotoSerif-Bold' } (expect alt_text_lines).to eql ['[This image is missing', 'and therefore will be', 'replaced with alt text] |', 'missing-image-with-', 'very-long-filename.png'] @@ -210,7 +210,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should skip block if image is missing an alt text is empty' do pdf_theme = { image_alt_content: '' } (expect do - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true paragraph one paragraph two @@ -218,7 +218,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do image::no-such-image.png[Missing Image] paragraph three - EOS + END (expect pdf.lines).to eql ['paragraph one', 'paragraph two', 'paragraph three'] para_one_y = (pdf.find_text 'paragraph one')[0][:y].round 2 para_two_y = (pdf.find_text 'paragraph two')[0][:y].round 2 @@ -240,7 +240,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should respect value of imagesdir if changed mid-document' do - pdf = to_pdf <<~EOS, enable_footer: true, attributes: {} + pdf = to_pdf <<~END, enable_footer: true, attributes: {} :imagesdir: #{fixtures_dir} image::tux.png[tux] @@ -248,7 +248,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do :imagesdir: #{examples_dir} image::wolpertinger.jpg[wolpertinger] - EOS + END (expect get_images pdf).to have_size 2 end @@ -256,9 +256,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do context 'Alignment' do it 'should align block image to value of align attribute on macro', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-align-right-attribute.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-align-right-attribute.pdf', attribute_overrides: { 'imagesdir' => examples_dir } image::wolpertinger.jpg[align=right] - EOS + END (expect to_file).to visually_match 'image-align-right.pdf' end @@ -271,18 +271,18 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should align block image as indicated by block alignment role on macro', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-align-right-attribute.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-align-right-attribute.pdf', attribute_overrides: { 'imagesdir' => examples_dir } [.right] image::wolpertinger.jpg[] - EOS + END (expect to_file).to visually_match 'image-align-right.pdf' end it 'should align block image to value of image_align key in theme if alignment not specified on image', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-align-right-theme.pdf', pdf_theme: { image_align: 'right' }, attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-align-right-theme.pdf', pdf_theme: { image_align: 'right' }, attribute_overrides: { 'imagesdir' => examples_dir } image::wolpertinger.jpg[] - EOS + END (expect to_file).to visually_match 'image-align-right.pdf' end @@ -369,34 +369,34 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should size image using percentage width specified by pdfwidth', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-pdfwidth-percentage.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-pdfwidth-percentage.pdf', attribute_overrides: { 'imagesdir' => examples_dir } image::wolpertinger.jpg[,144,pdfwidth=25%,scaledwidth=50%] - EOS + END (expect to_file).to visually_match 'image-pdfwidth-percentage.pdf' end it 'should size image using percentage width specified by scaledwidth', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-scaledwidth-percentage.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-scaledwidth-percentage.pdf', attribute_overrides: { 'imagesdir' => examples_dir } image::wolpertinger.jpg[,144,scaledwidth=25%] - EOS + END (expect to_file).to visually_match 'image-pdfwidth-percentage.pdf' end it 'should size image using percentage width specified by width', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-width-percentage.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-width-percentage.pdf', attribute_overrides: { 'imagesdir' => examples_dir } image::wolpertinger.jpg[,144,width=25%] - EOS + END (expect to_file).to visually_match 'image-pdfwidth-percentage.pdf' end it 'should scale raster image as percentage of intrinsic size', visual: true do ['scale=75', 'pdfwidth=75iw'].each do |width_attr| - pdf = to_pdf <<~EOS, attribute_overrides: { 'imagesdir' => examples_dir }, analyze: :image + pdf = to_pdf <<~END, attribute_overrides: { 'imagesdir' => examples_dir }, analyze: :image image::wolpertinger.jpg[,144,#{width_attr}] - EOS + END image = pdf.images[0] (expect image[:intrinsic_width].to_f).to eql 220.0 @@ -406,26 +406,26 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should scale SVG image as percentage of intrinsic size', visual: true do ['scale=50', 'pdfwidth=50iw'].each do |width_attr| - to_file = to_pdf_file <<~EOS, %(image-svg-#{width_attr.sub '=', '-'}.pdf) + to_file = to_pdf_file <<~END, %(image-svg-#{width_attr.sub '=', '-'}.pdf) image::square.svg[#{width_attr}] - EOS + END (expect to_file).to visually_match 'image-svg-scale.pdf' end end it 'should scale image to width of page when pdfwidth=100vw and align-to-page option is set', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-full-width.pdf' + to_file = to_pdf_file <<~'END', 'image-full-width.pdf' image::square.png[pdfwidth=100vw,opts=align-to-page] - EOS + END (expect to_file).to visually_match 'image-full-width.pdf' end it 'should interpret unrecognized units as pt' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image Follow the image:square.jpg[pdfwidth=12ft]. - EOS + END (expect pdf.images).to have_size 1 (expect pdf.images[0][:width]).to eql 12.0 @@ -433,9 +433,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should scale inline image as percentage of intrinsic size' do ['scale=400', 'pdfwidth=400iw'].each do |width_attr| - pdf = to_pdf <<~EOS, analyze: :image + pdf = to_pdf <<~END, analyze: :image image:square.jpg[#{width_attr}] - EOS + END image = pdf.images[0] (expect image[:intrinsic_width].to_f).to eql 5.0 @@ -446,34 +446,34 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should interpret vw units as pt if align-to-page opts is not set' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image Follow the image:square.jpg[pdfwidth=50vw]. - EOS + END (expect pdf.images).to have_size 1 (expect pdf.images[0][:width]).to eql 50.0 end it 'should scale down image if height exceeds available space', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-png-scale-to-fit.pdf' + to_file = to_pdf_file <<~'END', 'image-png-scale-to-fit.pdf' :pdf-page-layout: landscape image::tux.png[pdfwidth=100%] - EOS + END (expect to_file).to visually_match 'image-png-scale-to-fit.pdf' end # NOTE: if not implemented properly, this case is subject to a floating point calculation error it 'should set height of scaled down image to exactly height of available space' do - input = <<~'EOS' + input = <<~'END' :pdf-page-size: Letter :pdf-page-margin: 0.67in before image::tall-irregular.jpg[pdfwidth=100%] - EOS + END pdf = to_pdf input (expect pdf.pages).to have_size 2 @@ -486,38 +486,38 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should use the numeric width defined in the theme if an explicit width is not specified', visual: true do [72, '72', '1in', '6pc'].each do |image_width| - to_file = to_pdf_file <<~'EOS', 'image-numeric-fallback-width.pdf', pdf_theme: { image_width: image_width } + to_file = to_pdf_file <<~'END', 'image-numeric-fallback-width.pdf', pdf_theme: { image_width: image_width } image::tux.png[pdfwidth=204px] image::tux.png[,204] image::tux.png[] - EOS + END (expect to_file).to visually_match 'image-numeric-fallback-width.pdf' end end it 'should use the percentage width defined in the theme if an explicit width is not specified', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-percentage-fallback-width.pdf', pdf_theme: { image_width: '50%' } + to_file = to_pdf_file <<~'END', 'image-percentage-fallback-width.pdf', pdf_theme: { image_width: '50%' } image::tux.png[] - EOS + END (expect to_file).to visually_match 'image-percentage-fallback-width.pdf' end it 'should use intrinsic width if value of width is not numeric', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-block-intrinsic-width.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-block-intrinsic-width.pdf', attribute_overrides: { 'imagesdir' => examples_dir } image::wolpertinger.jpg[,invalid] - EOS + END (expect to_file).to visually_match 'image-block-intrinsic-width.pdf' end it 'should use the vw width defined in theme if explicit width is not specified', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-full-width-theme.pdf', pdf_theme: { image_width: '100vw' } + to_file = to_pdf_file <<~'END', 'image-full-width-theme.pdf', pdf_theme: { image_width: '100vw' } image::square.png[opts=align-to-page] - EOS + END (expect to_file).to visually_match 'image-full-width.pdf' end @@ -525,14 +525,14 @@ describe 'Asciidoctor::PDF::Converter - Image' do context 'SVG' do it 'should not leave gap around SVG that specifies viewBox but no width' do - input = <<~'EOS' + input = <<~'END' :pdf-page-size: 200x400 :pdf-page-margin: 0 image::square-viewbox-only.svg[] after - EOS + END pdf = to_pdf input, analyze: :rect (expect pdf.rectangles).to have_size 1 @@ -548,14 +548,14 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should not leave gap around constrained SVG that specifies viewBox but no width' do - input = <<~'EOS' + input = <<~'END' :pdf-page-size: 200x400 :pdf-page-margin: 0 image::square-viewbox-only.svg[pdfwidth=50%] after - EOS + END pdf = to_pdf input, analyze: :rect (expect pdf.rectangles).to have_size 1 @@ -571,26 +571,26 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should vertically center SVG within content area if width and height attributes are 100%', visual: true do - input = <<~'EOS' + input = <<~'END' before image::square-100.svg[] after - EOS + END to_file = to_pdf_file input, 'image-square-100-auto.pdf' (expect to_file).to visually_match 'image-square-100-auto.pdf' end it 'should vertically center SVG within content area if width and height attributes are 100% and pdfwidth is set', visual: true do - input = <<~'EOS' + input = <<~'END' before image::square-100.svg[pdfwidth=1in] after - EOS + END to_file = to_pdf_file input, 'image-square-100-constrained.pdf' (expect to_file).to visually_match 'image-square-100-constrained.pdf' @@ -601,12 +601,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do to_file = with_content_spacer 200, 200, 'px' do |spacer_path| pdf_theme = {} pdf_theme[:image_width] = '200px' if from_theme - to_pdf_file <<~EOS, %(image-svg-px-width-from-#{from_theme ? 'theme' : 'file'}.svg), pdf_theme: pdf_theme + to_pdf_file <<~END, %(image-svg-px-width-from-#{from_theme ? 'theme' : 'file'}.svg), pdf_theme: pdf_theme image::#{spacer_path}[] image::#{spacer_path}[pdfwidth=200px] - EOS + END end (expect to_file).to visually_match 'image-svg-px-width.pdf' @@ -614,26 +614,26 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should treat value with px units at pt in SVG data', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-svg-px-data.pdf' + to_file = to_pdf_file <<~'END', 'image-svg-px-data.pdf' image::red-blue-squares.svg[pdfwidth=25%] - EOS + END (expect to_file).to visually_match 'image-svg-px-data.pdf' end it 'should not allow inline image to affect the cursor position of the following paragraph' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true before next - EOS + END expected_gap = ((pdf.find_unique_text 'before')[:y] - (pdf.find_unique_text 'next')[:y]).round 2 - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true before image:tall.svg[pdfwidth=0.5in] after next - EOS + END actual_gap = ((pdf.find_unique_text %r/before/)[:y] - (pdf.find_unique_text 'next')[:y]).round 2 (expect actual_gap).to eql expected_gap @@ -641,18 +641,18 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should set color space on page that only has image and stamp' do - pdf = to_pdf <<~'EOS', pdf_theme: { footer_recto_right_content: 'pg {page-number}' }, enable_footer: true + pdf = to_pdf <<~'END', pdf_theme: { footer_recto_right_content: 'pg {page-number}' }, enable_footer: true image::square.svg[] - EOS + END (expect (pdf.page 1).text.squeeze).to eql 'pg 1' raw_content = (pdf.page 1).raw_content - color_space_idx = raw_content.index <<~'EOS' + color_space_idx = raw_content.index <<~'END' /DeviceRGB cs 0.0 0.0 0.0 scn /DeviceRGB CS 0.0 0.0 0.0 SCN - EOS + END stamp_idx = raw_content.index %(\n/Stamp) (expect color_space_idx).to be > 0 (expect stamp_idx).to be > 0 @@ -660,17 +660,17 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should scale down SVG at top of page if dimensions exceed page size', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-svg-scale-to-fit-page.pdf' + to_file = to_pdf_file <<~'END', 'image-svg-scale-to-fit-page.pdf' :pdf-page-size: Letter image::watermark.svg[pdfwidth=100%] - EOS + END (expect to_file).to visually_match 'image-svg-scale-to-fit-page.pdf' end it 'should scale down SVG not at top of page and advance to next page if dimensions exceed page size', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-svg-scale-to-fit-next-page-with-text.pdf' + to_file = to_pdf_file <<~'END', 'image-svg-scale-to-fit-next-page-with-text.pdf' :pdf-page-size: Letter push @@ -680,7 +680,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do down image::watermark.svg[pdfwidth=100%] - EOS + END to_file = to_pdf_file %(image::#{to_file}[page=2]), 'image-svg-scale-to-fit-next-page.pdf' @@ -694,7 +694,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do thematic_break_border_color: '0000FF', thematic_break_border_width: 1, } - input = <<~'EOS' + input = <<~'END' left column [.column] @@ -703,7 +703,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do --- image::tall.svg[pdfwidth=50%] - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines thematic_break_line = lines.find {|it| it[:color] == '0000FF' && it[:width] == 1 } @@ -724,7 +724,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do thematic_break_border_color: '0000FF', thematic_break_border_width: 1, } - input = <<~'EOS' + input = <<~'END' left column [.column] @@ -733,7 +733,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do --- image::tall.svg[pdfwidth=50%,align=center] - EOS + END to_file = to_pdf_file input, 'image-svg-in-column-align-center.pdf', pdf_theme: pdf_theme @@ -752,13 +752,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do end end - input = <<~'EOS' + input = <<~'END' = Document Title image::tall.svg[pdfwidth=90mm] paragraph in second column - EOS + END pdf = to_pdf input, backend: backend, analyze: true (expect pdf.pages).to have_size 1 @@ -785,7 +785,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end end - input = <<~'EOS' + input = <<~'END' = Document Title before @@ -793,7 +793,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do image::tall.svg[pdfwidth=90mm] paragraph on next page - EOS + END pdf = to_pdf input, backend: backend, analyze: true (expect pdf.pages).to have_size 2 @@ -817,7 +817,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should not scale SVG if it can fit on next page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(%w(filler) * 6).join %(\n\n)} image::tall.svg[] @@ -829,7 +829,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do image::tall.svg[] below second - EOS + END below_first_text = pdf.find_unique_text 'below first' below_second_text = pdf.find_unique_text 'below second' @@ -839,12 +839,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should scale down inline SVG to fit height of page' do - input = <<~'EOS' + input = <<~'END' :pdf-page-size: 200x350 :pdf-page-margin: 0 image:tall.svg[] - EOS + END pdf = to_pdf input, analyze: :line image_h = pdf.lines[1][:to][:y] - pdf.lines[1][:from][:y] @@ -852,14 +852,14 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should scale down inline SVG to fit height of next page' do - input = <<~'EOS' + input = <<~'END' :pdf-page-size: 200x350 :pdf-page-margin: 0 before image:tall.svg[] - EOS + END pdf = to_pdf input, analyze: :line (expect pdf.lines.map {|it| it[:page_number] }.uniq).to eql [2] @@ -868,9 +868,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should display text inside link' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true image::svg-with-link.svg[] - EOS + END text = pdf.find_text 'Text with link' (expect text).to have_size 1 @@ -880,9 +880,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should map font names in SVG to font names in document font catalog' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true image::svg-with-text.svg[] - EOS + END text = pdf.find_text 'This text uses a document font.' (expect text).to have_size 1 @@ -892,9 +892,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should replace unrecognized font family with base font family' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true image::svg-with-unknown-font.svg[] - EOS + END text = pdf.find_text 'This text uses the default SVG font.' (expect text).to have_size 1 @@ -904,9 +904,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should map generic font family to AFM font by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true image::svg-with-generic-font.svg[] - EOS + END text = pdf.find_text 'This text uses the serif font.' (expect text).to have_size 1 @@ -918,9 +918,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should allow generic font family to be mapped in font catalog' do pdf_theme = build_pdf_theme pdf_theme.font_catalog['serif'] = { 'normal' => pdf_theme.font_catalog['Noto Serif']['normal'] } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true image::svg-with-generic-font.svg[] - EOS + END text = pdf.find_text 'This text uses the serif font.' (expect text).to have_size 1 @@ -931,11 +931,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should replace unrecognized font family in SVG with SVG fallback font family if specified in theme' do [true, false].each do |block| - pdf = to_pdf <<~EOS, pdf_theme: { svg_fallback_font_family: 'Times-Roman' }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { svg_fallback_font_family: 'Times-Roman' }, analyze: true #{block ? '' : 'before'} image:#{block ? ':' : ''}svg-with-unknown-font.svg[pdfwidth=100%] #{block ? '' : 'after'} - EOS + END text = pdf.find_text 'This text uses the default SVG font.' (expect text).to have_size 1 @@ -946,34 +946,34 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should embed local image in inline image', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-svg-with-local-image.pdf' + to_file = to_pdf_file <<~'END', 'image-svg-with-local-image.pdf' A sign of a good writer: image:svg-with-local-image.svg[pdfwidth=1.27cm] - EOS + END (expect to_file).to visually_match 'image-svg-with-image.pdf' end it 'should embed local image in block image', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-block-svg-with-local-image.pdf' + to_file = to_pdf_file <<~'END', 'image-block-svg-with-local-image.pdf' image::svg-with-local-image.svg[pdfwidth=1.27cm] - EOS + END (expect to_file).to visually_match 'image-block-svg-with-image.pdf' end it 'should allow image path to reference file in ancestor directory inside base dir' do expected_image_data = File.binread example_file 'sample-logo.jpg' - svg_data = <<~'EOS' + svg_data = <<~'END' <svg version="1.1" viewBox="0 0 331 369" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <image x="0" y="0" width="331" height="369" xlink:href="../../examples/sample-logo.jpg"/> </svg> - EOS + END with_tmp_file '.svg', contents: svg_data do |tmp_file| image_path = tmp_file.path ['::', ':'].each do |macro_delim| - pdf = to_pdf <<~EOS, base_dir: (File.dirname __dir__) + pdf = to_pdf <<~END, base_dir: (File.dirname __dir__) image#{macro_delim}#{image_path}[SVG with ancestor relative image,pdfwidth=25%] - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -997,17 +997,17 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should embed image from data-uri in inline image', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-svg-with-data-uri-image.pdf' + to_file = to_pdf_file <<~'END', 'image-svg-with-data-uri-image.pdf' A sign of a good writer: image:svg-with-data-uri-image.svg[pdfwidth=1.27cm] - EOS + END (expect to_file).to visually_match 'image-svg-with-image.pdf' end it 'should embed image from data-uri in block image', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-block-svg-with-data-uri-image.pdf' + to_file = to_pdf_file <<~'END', 'image-block-svg-with-data-uri-image.pdf' image::svg-with-data-uri-image.svg[pdfwidth=1.27cm] - EOS + END (expect to_file).to visually_match 'image-block-svg-with-image.pdf' end @@ -1021,17 +1021,17 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should use width defined in image if width not specified on inline macro', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-svg-with-own-width.pdf' + to_file = to_pdf_file <<~'END', 'image-svg-with-own-width.pdf' A sign of a good writer: image:svg-with-local-image.svg[] - EOS + END (expect to_file).to visually_match 'image-svg-with-image.pdf' end it 'should use width defined in image if width not specified on block macro', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-block-svg-with-own-width.pdf' + to_file = to_pdf_file <<~'END', 'image-block-svg-with-own-width.pdf' image::svg-with-local-image.svg[] - EOS + END (expect to_file).to visually_match 'image-block-svg-with-image.pdf' end @@ -1039,9 +1039,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not embed remote image if allow allow-uri-read attribute is not set', visual: true do with_svg_with_remote_image do |image_path, image_url| (expect do - to_file = to_pdf_file <<~EOS, 'image-svg-with-remote-image-disabled.pdf' + to_file = to_pdf_file <<~END, 'image-svg-with-remote-image-disabled.pdf' A sign of a good writer: image:#{image_path}[] - EOS + END (expect to_file).to visually_match 'image-svg-with-missing-image.pdf' end).to log_message severity: :WARN, message: %(~problem encountered in image: #{image_path}; Error retrieving URL #{image_url}) end @@ -1049,9 +1049,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should embed remote image if allow allow-uri-read attribute is set', network: true, visual: true do with_svg_with_remote_image do |image_path| - to_file = to_pdf_file <<~EOS, 'image-svg-with-remote-image.pdf', attribute_overrides: { 'allow-uri-read' => '' } + to_file = to_pdf_file <<~END, 'image-svg-with-remote-image.pdf', attribute_overrides: { 'allow-uri-read' => '' } A sign of a good writer: image:#{image_path}[pdfwidth=1.27cm] - EOS + END (expect to_file).to visually_match 'image-svg-with-image.pdf' end @@ -1059,9 +1059,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should warn if remote image is missing and allow-uri-read attribute is set', network: true do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'allow-uri-read' => '' } + pdf = to_pdf <<~'END', attribute_overrides: { 'allow-uri-read' => '' } See the logo in image:svg-with-missing-remote-image.svg[pdfwidth=16] - EOS + END (expect get_images pdf, 1).to be_empty (expect (pdf.page 1).text).to include 'See the logo in' end).to log_message severity: :WARN, message: %(problem encountered in image: #{fixture_file 'svg-with-missing-remote-image.svg'}; Error retrieving URL https://github.com/no-such-image.png: 404 Not Found) @@ -1069,9 +1069,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should warn if remote image is not a valid URL and allow-uri-read attribute is set', network: true do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'allow-uri-read' => '' } + pdf = to_pdf <<~'END', attribute_overrides: { 'allow-uri-read' => '' } See the logo in image:svg-with-non-url-image.svg[pdfwidth=16] - EOS + END (expect get_images pdf, 1).to be_empty (expect (pdf.page 1).text).to include 'See the logo in' end).to log_message severity: :WARN, message: %(problem encountered in image: #{fixture_file 'svg-with-non-url-image.svg'}; Error retrieving URL s3://foobar/tux.png: No handler available for this URL scheme) @@ -1085,9 +1085,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should ignore inline option for SVG on image macro' do - pdf = to_pdf <<~'EOS', analyze: :rect + pdf = to_pdf <<~'END', analyze: :rect image::square.svg[pdfwidth=200pt,opts=inline] - EOS + END (expect pdf.rectangles).to have_size 1 rect = pdf.rectangles[0] (expect rect[:point]).to eql [48.24, 605.89] @@ -1131,13 +1131,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do footer_recto_right_content: %(image:#{fixture_file 'svg-with-text.svg'}[]), footer_verso_left_content: %(image:#{fixture_file 'svg-with-text.svg'}[]), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true before image::tall.svg[pdfwidth=50%] after - EOS + END (expect pdf.pages).to have_size 3 page_contents = pdf.objects[(pdf.page 2).page_object[:Contents]].data @@ -1149,7 +1149,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do footer_recto_right_content: %(image:#{fixture_file 'svg-with-text.svg'}[]), footer_verso_left_content: %(image:#{fixture_file 'svg-with-text.svg'}[]), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true first <<< @@ -1159,7 +1159,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do image::tall.svg[pdfwidth=25%] after - EOS + END (expect pdf.pages).to have_size 2 [1, 2].each do |pagenum| @@ -1170,19 +1170,19 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not embed local SVG in inline image', visual: true do (expect do - to_file = to_pdf_file <<~'EOS', 'image-inline-svg-with-local-svg.pdf' + to_file = to_pdf_file <<~'END', 'image-inline-svg-with-local-svg.pdf' image:svg-with-local-svg.svg[pdfwidth=1.27cm] lacks the red square. - EOS + END (expect to_file).to visually_match 'image-inline-svg-with-local-svg.pdf' end).to log_message severity: :WARN, message: %(~problem encountered in image: #{fixture_file 'svg-with-local-svg.svg'}; Unsupported image type supplied to image tag) end it 'should not embed local SVG in block image', visual: true do (expect do - to_file = to_pdf_file <<~'EOS', 'image-block-svg-with-local-svg.pdf' + to_file = to_pdf_file <<~'END', 'image-block-svg-with-local-svg.pdf' .Lacks the red square image::svg-with-local-svg.svg[pdfwidth=5in] - EOS + END (expect to_file).to visually_match 'image-block-svg-with-local-svg.pdf' end).to log_message severity: :WARN, message: %(~problem encountered in image: #{fixture_file 'svg-with-local-svg.svg'}; Unsupported image type supplied to image tag) end @@ -1217,11 +1217,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do call_count += 1 image_handler end - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image **** image::tux.png[] **** - EOS + END (expect pdf.images).to have_size 1 (expect call_count).to eql 1 ensure @@ -1230,18 +1230,18 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should set color space on page that only has image and stamp' do - pdf = to_pdf <<~'EOS', pdf_theme: { footer_recto_right_content: 'pg {page-number}' }, enable_footer: true + pdf = to_pdf <<~'END', pdf_theme: { footer_recto_right_content: 'pg {page-number}' }, enable_footer: true image::tux.png[] - EOS + END (expect (pdf.page 1).text.squeeze).to eql 'pg 1' raw_content = (pdf.page 1).raw_content - color_space_idx = raw_content.index <<~'EOS' + color_space_idx = raw_content.index <<~'END' /DeviceRGB cs 0.0 0.0 0.0 scn /DeviceRGB CS 0.0 0.0 0.0 SCN - EOS + END stamp_idx = raw_content.index %(\n/Stamp) (expect color_space_idx).to be > 0 (expect stamp_idx).to be > 0 @@ -1252,11 +1252,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do pdf_theme = { page_size: 'Letter', page_margin: 50 } expected_top = (to_pdf 'image::cover.jpg[pdfwidth=1in]', pdf_theme: pdf_theme, analyze: :image).images[0][:y] expected_height = 11 * 72.0 - 100 - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :image before image::cover.jpg[pdfwidth=100%] - EOS + END images = pdf.images (expect images).to have_size 1 @@ -1269,13 +1269,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not scale image if it can fit on next page' do reference_width = (to_pdf 'image::cover.jpg[]', analyze: :image).images[0][:width] - pdf = to_pdf <<~EOS, analyze: :image + pdf = to_pdf <<~END, analyze: :image :pdf-page-size: A5 #{(%w(filler) * 8).join %(\n\n)} image::cover.jpg[] - EOS + END (expect pdf.images[0][:width]).to eql reference_width end @@ -1288,9 +1288,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_path = tmp_file.path { '::' => %([Incomplete PNG] | #{image_path}), ':' => '[Incomplete PNG]' }.each do |macro_delim, alt_text| (expect do - input = <<~EOS + input = <<~END image#{macro_delim}#{image_path}[Incomplete PNG] - EOS + END pdf = to_pdf input, pdf_theme: { page_layout: 'landscape' }, analyze: true (expect pdf.lines).to eql [alt_text] end).to log_message severity: :WARN, message: %(could not embed image: #{image_path}; image file is an unrecognised format) @@ -1301,12 +1301,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should fail to embed interlaced PNG image with warning', unless: (defined? GMagick::Image) do { '::' => '[Interlaced PNG] | interlaced.png', ':' => '[Interlaced PNG]' }.each do |macro_delim, alt_text| (expect do - input = <<~EOS + input = <<~END [%unbreakable] -- image#{macro_delim}interlaced.png[Interlaced PNG] -- - EOS + END pdf = to_pdf input, analyze: true (expect pdf.lines).to eql [alt_text] end).to log_message severity: :WARN, message: %(could not embed image: #{fixture_file 'interlaced.png'}; PNG uses unsupported interlace method; install prawn-gmagick gem to add support for PNG image format) @@ -1323,12 +1323,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not suggest installing prawn-gmagick if gem has already been loaded', if: (defined? GMagick::Image) do ['::', ':'].each do |macro_delim| (expect do - input = <<~EOS + input = <<~END [%unbreakable] -- image#{macro_delim}lorem-ipsum.yml[Unrecognized image format] -- - EOS + END pdf = to_pdf input, analyze: :image (expect pdf.images).to have_size 0 end).to log_message severity: :WARN, message: %(could not embed image: #{fixture_file 'lorem-ipsum.yml'}; image file is an unrecognised format) @@ -1337,9 +1337,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do # NOTE: gmagick reads `Depth: 8/2-bit` as 2 instead of 8 it 'should reread bit depth if gmagick fails to read bit depth correctly', if: (defined? GMagick::Image), visual: true do - to_file = to_pdf_file <<~'EOS', 'image-png-depth.pdf' + to_file = to_pdf_file <<~'END', 'image-png-depth.pdf' image::square.png[pdfwidth=25%] - EOS + END (expect to_file).to visually_match 'image-png-depth.pdf' end @@ -1349,7 +1349,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do footer_recto_right_content: %(image:#{fixture_file 'svg-with-text.svg'}[]), footer_verso_left_content: %(image:#{fixture_file 'svg-with-text.svg'}[]), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true :pdf-page-size: Letter before @@ -1357,7 +1357,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do image::cover.jpg[pdfwidth=100%] after - EOS + END (expect pdf.pages).to have_size 3 page_contents = pdf.objects[(pdf.page 2).page_object[:Contents]].data @@ -1476,13 +1476,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should insert page at location of block macro if target is a PDF' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true before image::blue-letter.pdf[] after - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -1495,7 +1495,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should replace empty page at location of block macro if target is a PDF' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true :page-background-image: image:bg.png[] before @@ -1507,7 +1507,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do <<< after - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -1520,7 +1520,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should not break internal references when PDF is imported on first page' do - pdf = to_pdf <<~'EOS', enable_footer: true, attribute_overrides: { 'pdf-page-size' => 'Letter' } + pdf = to_pdf <<~'END', enable_footer: true, attribute_overrides: { 'pdf-page-size' => 'Letter' } image::blue-letter.pdf[] see <<Section>> @@ -1537,7 +1537,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do [#last] last - EOS + END names = get_names pdf (expect names).to have_size 3 @@ -1566,10 +1566,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should not insert blank page between consecutive PDF page imports' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' image::red-green-blue.pdf[page=1] image::red-green-blue.pdf[page=2] - EOS + END (expect pdf.pages).to have_size 2 p1_contents = pdf.objects[(pdf.page 1).page_object[:Contents][0]].data (expect (p1_contents.split ?\n).slice 0, 3).to eql ['q', '/DeviceRGB cs', '1.0 0.0 0.0 scn'] @@ -1579,9 +1579,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should insert all pages specified by pages attribute without leaving blank pages in between' do ['pages="3,1,2"', 'pages=3;1..2'].each do |pages_attr| - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END image::red-green-blue.pdf[#{pages_attr}] - EOS + END (expect pdf.pages).to have_size 3 p1_contents = pdf.objects[(pdf.page 1).page_object[:Contents][0]].data (expect (p1_contents.split ?\n).slice 0, 3).to eql ['q', '/DeviceRGB cs', '0.0 0.0 1.0 scn'] @@ -1593,9 +1593,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should ignore page numbers not found in imported PDF' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' image::red-green-blue.pdf[pages=1..10] - EOS + END (expect pdf.pages).to have_size 3 p1_contents = pdf.objects[(pdf.page 1).page_object[:Contents][0]].data (expect (p1_contents.split ?\n).slice 0, 3).to eql ['q', '/DeviceRGB cs', '1.0 0.0 0.0 scn'] @@ -1606,13 +1606,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should not create empty page if imported PDF has no pages' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' == Before image::no-pages.pdf[] == After - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.page 2).text).to eql 'After' @@ -1622,7 +1622,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should restore rotated margin after imported page' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :pdf-page-margin-rotated: 0 portrait @@ -1635,7 +1635,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do image::blue-letter.pdf[] landscape again - EOS + END (expect pdf.pages).to have_size 4 (expect (pdf.find_unique_text 'landscape')[:x]).to eql 0.0 @@ -1643,13 +1643,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should add destination to top of imported page if ID is specified' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' go to <<red>> .Red Page [#red] image::red-green-blue.pdf[page=1] - EOS + END (expect get_names pdf).to have_key 'red' annotations = get_annotations pdf, 1 @@ -1659,13 +1659,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should add destination to top of first import page if ID is specified' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' go to <<red>> .Red Page [#red] image::red-green-blue.pdf[pages=1..3] - EOS + END (expect get_names pdf).to have_key 'red' annotations = get_annotations pdf, 1 @@ -1675,7 +1675,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should restore anchor of hidden section title on imported page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :notitle: :doctype: book @@ -1686,7 +1686,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do == Blue Page image::blue-letter.pdf[] - EOS + END annotations = get_annotations pdf, 1 (expect annotations).to have_size 1 @@ -1700,7 +1700,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should allow imported page to be referenced from TOC by way of notitle section' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toc: @@ -1709,7 +1709,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do == Blue Page image::blue-letter.pdf[] - EOS + END toc_page = pdf.page 2 annotations = get_annotations pdf, 2 @@ -1822,13 +1822,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should only read remote image once if allow-uri-read is set' do pdf = with_local_webserver do |base_url, thr| image_macro = %(image::#{base_url}/logo.png[Remote Image]) - result = to_pdf <<~EOS, attribute_overrides: { 'allow-uri-read' => '' } + result = to_pdf <<~END, attribute_overrides: { 'allow-uri-read' => '' } #{image_macro} ==== #{image_macro} ==== - EOS + END requests = thr[:requests] (expect requests).to have_size 1 (expect requests[0]).to include '/logo.png' @@ -1844,13 +1844,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_url = %(#{base_url}/no-such-image.png) (expect do image_macro = %(image::#{image_url}[Remote Image]) - pdf = to_pdf <<~EOS, attribute_overrides: { 'allow-uri-read' => '' } + pdf = to_pdf <<~END, attribute_overrides: { 'allow-uri-read' => '' } #{image_macro} ==== #{image_macro} ==== - EOS + END requests = thr[:requests] (expect requests).to have_size 1 (expect requests[0]).to include '/no-such-image.png' @@ -1864,11 +1864,11 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should read same remote image for each unique query string if allow-uri-read is set' do with_local_webserver do |base_url, thr| - pdf = to_pdf <<~EOS, attribute_overrides: { 'allow-uri-read' => '' } + pdf = to_pdf <<~END, attribute_overrides: { 'allow-uri-read' => '' } image::#{base_url}/logo.png?v=1[Remote Image,format=png] image::#{base_url}/logo.png?v=2[Remote Image,format=png] - EOS + END requests = thr[:requests] (expect requests).to have_size 2 (expect requests[0]).to include '/logo.png?v=1' @@ -1888,9 +1888,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do footer_columns: '=100%', footer_recto_center_content: %(image:#{base_url}/logo.png[Remote Image]), } - result = to_pdf <<~EOS, pdf_theme: pdf_theme, enable_footer: true, attribute_overrides: { 'allow-uri-read' => '' } + result = to_pdf <<~END, pdf_theme: pdf_theme, enable_footer: true, attribute_overrides: { 'allow-uri-read' => '' } image::#{base_url}/logo.png[Remote Image] - EOS + END requests = thr[:requests] (expect requests).to have_size 1 (expect requests[0]).to include '/logo.png' @@ -1941,12 +1941,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should use image format specified by format attribute' do pdf = with_local_webserver do |base_url| - to_pdf <<~EOS, attribute_overrides: { 'allow-uri-read' => '' }, analyze: :rect + to_pdf <<~END, attribute_overrides: { 'allow-uri-read' => '' }, analyze: :rect :pdf-page-size: 200x400 :pdf-page-margin: 0 image::#{base_url}/square.svg?v=1[format=svg,pdfwidth=100%] - EOS + END end (expect pdf.rectangles).to have_size 1 rect = pdf.rectangles[0] @@ -1959,13 +1959,13 @@ describe 'Asciidoctor::PDF::Converter - Image' do (expect do FileUtils.cp (fixture_file 'square.svg'), (fixture_file 'square') pdf = with_local_webserver do |base_url| - to_pdf <<~EOS, attribute_overrides: { 'allow-uri-read' => '' }, analyze: :rect + to_pdf <<~END, attribute_overrides: { 'allow-uri-read' => '' }, analyze: :rect :pdf-page-size: 200x400 :pdf-page-margin: 0 :format: svg image::#{base_url}/square[pdfwidth=100%] - EOS + END ensure File.unlink fixture_file 'square' end @@ -2014,9 +2014,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do context 'Inline' do it 'should resolve target of inline image relative to imagesdir', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-inline.pdf', attribute_overrides: { 'imagesdir' => examples_dir } image:sample-logo.jpg[ACME,12] ACME products are the best! - EOS + END (expect to_file).to visually_match 'image-inline.pdf' end @@ -2036,10 +2036,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should only render inline image once if alt text is chunked to apply a fallback font' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'imagesdir' => examples_dir, 'pdf-theme' => 'default-with-font-fallbacks' }, analyze: :image + pdf = to_pdf <<~'END', attribute_overrides: { 'imagesdir' => examples_dir, 'pdf-theme' => 'default-with-font-fallbacks' }, analyze: :image How many wolpertingers do you see? + image:wolpertinger.jpg[チのデータレプリケーションです。] - EOS + END (expect pdf.images).to have_size 1 end @@ -2058,15 +2058,15 @@ describe 'Asciidoctor::PDF::Converter - Image' do # NOTE: this test also verifies space is allocated for an inline image at the start of a line it 'should convert multiple images on the same line', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-multiple-inline.pdf' + to_file = to_pdf_file <<~'END', 'image-multiple-inline.pdf' image:logo.png[Asciidoctor,12] is developed on image:tux.png[Linux,12]. - EOS + END (expect to_file).to visually_match 'image-multiple-inline.pdf' end it 'should not mangle character spacing in line if inline image wraps', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-wrap-inline.pdf' + to_file = to_pdf_file <<~'END', 'image-wrap-inline.pdf' [cols="30e,58,12",width=75%] |=== |Name |Description |Min # data points @@ -2079,27 +2079,27 @@ describe 'Asciidoctor::PDF::Converter - Image' do a|The confidence interval of the mean is image:equation.svg[width=118], where image:symbol-m.svg[width=11] is the mean, image:symbol-s.svg[width=6] is the estimated sample standard deviation, and so on. |2 |=== - EOS + END (expect to_file).to visually_match 'image-wrap-inline.pdf' end it 'should increase line height if height if image height is more than 1.5x line height', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline-extends-line-height.pdf' + to_file = to_pdf_file <<~'END', 'image-inline-extends-line-height.pdf' see tux run + see image:tux.png[tux] run + see tux run - EOS + END (expect to_file).to visually_match 'image-inline-extends-line-height.pdf' end it 'should not increase line height if image height does not exceed 1.5x line height' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true see tux run + see tux run + see image:tux.png[tux,24] run - EOS + END text = pdf.text line1_spacing = (text[0][:y] - text[1][:y]).round 2 @@ -2108,14 +2108,14 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should scale image down to fit available height on next page', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline-pushed-scale-down-height.pdf' + to_file = to_pdf_file <<~'END', 'image-inline-pushed-scale-down-height.pdf' :pdf-page-size: A6 :pdf-page-layout: landscape before image:cover.jpg[] - EOS + END to_file = to_pdf_file %(image::#{to_file}[page=2]), 'image-inline-pushed-scale-down-height-2.pdf' @@ -2123,22 +2123,22 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should scale image down to fit available height inside delimited block', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline-in-block-scale-down-height.pdf' + to_file = to_pdf_file <<~'END', 'image-inline-in-block-scale-down-height.pdf' :pdf-page-size: A6 :pdf-page-layout: landscape **** image:cover.jpg[] **** - EOS + END (expect to_file).to visually_match 'image-inline-in-block-scale-down-height.pdf' end it 'should not scale image if pdfwidth matches intrinsic width' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image see image:tux.png[pdfwidth=204] run - EOS + END images = pdf.images (expect images).to have_size 1 @@ -2148,22 +2148,22 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should scale image down to fit available height', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline-scale-down-height.pdf' + to_file = to_pdf_file <<~'END', 'image-inline-scale-down-height.pdf' :pdf-page-size: A6 :pdf-page-layout: landscape image:cover.jpg[] - EOS + END (expect to_file).to visually_match 'image-inline-scale-down-height.pdf' end it 'should scale image down to fit available width', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline-scale-down-width.pdf' + to_file = to_pdf_file <<~'END', 'image-inline-scale-down-width.pdf' :pdf-page-size: A6 image:cover.jpg[] - EOS + END (expect to_file).to visually_match 'image-inline-scale-down-width.pdf' end @@ -2171,7 +2171,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should compute scaled width relative to container size' do midpoint = (get_page_size to_pdf 'body', analyze: true)[0] * 0.5 - input = <<~'EOS' + input = <<~'END' **** ==== ****** @@ -2183,7 +2183,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do ****** ==== **** - EOS + END pdf = to_pdf input, analyze: true midpoint_text = pdf.find_unique_text 'midpoint' @@ -2199,17 +2199,17 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should scale image down to fit line if fit=line', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline-fit-line.pdf' + to_file = to_pdf_file <<~'END', 'image-inline-fit-line.pdf' See image:tux.png[fit=line] run. - EOS + END (expect to_file).to visually_match 'image-inline-fit-line.pdf' end it 'should not alter character spacing of text in inline SVG image', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline-svg-with-text.pdf' + to_file = to_pdf_file <<~'END', 'image-inline-svg-with-text.pdf' before image:svg-with-text.svg[width=200] after - EOS + END (expect to_file).to visually_match 'image-inline-svg-with-text.pdf' end @@ -2224,9 +2224,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should not fail to parse raw image HTML if width attribute not specified' do - pdf = to_pdf <<~EOS, analyze: :image + pdf = to_pdf <<~END, analyze: :image Look for pass:[<img src="#{fixture_file 'logo.png'}" alt="no cow">] when you buy. - EOS + END images = pdf.images (expect images).to have_size 1 @@ -2234,9 +2234,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should use intrinsic width if value of width is not numeric', visual: true do - to_file = to_pdf_file <<~'EOS', 'image-inline-intrinsic-width.pdf', attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-inline-intrinsic-width.pdf', attribute_overrides: { 'imagesdir' => examples_dir } image:wolpertinger.jpg[,invalid] - EOS + END (expect to_file).to visually_match 'image-inline-intrinsic-width.pdf' end @@ -2244,9 +2244,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do context 'Link' do it 'should add link around block raster image if link attribute is set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' image::tux.png[pdfwidth=1in,link=https://www.linuxfoundation.org/projects/linux/] - EOS + END annotations = get_annotations pdf, 1 (expect annotations).to have_size 1 @@ -2279,9 +2279,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should add link around block SVG image if link attribute is set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' image::square.svg[pdfwidth=1in,link=https://example.org] - EOS + END annotations = get_annotations pdf, 1 (expect annotations).to have_size 1 @@ -2308,9 +2308,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should add link around inline image if link attribute is set' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'imagesdir' => examples_dir } + pdf = to_pdf <<~'END', attribute_overrides: { 'imagesdir' => examples_dir } image:sample-logo.jpg[ACME,pdfwidth=1pc,link=https://example.org] is a sign of quality! - EOS + END annotations = get_annotations pdf, 1 (expect annotations).to have_size 1 @@ -2324,9 +2324,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should add link around alt text of inline image if link attribute is set and image is not found' do - input = <<~'EOS' + input = <<~'END' image:sample-logo.jpg[ACME,pdfwidth=1pc,link=https://example.org] is a sign of quality! - EOS + END pdf = nil (expect do @@ -2347,9 +2347,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should add link around inline image if image macro is enclosed in link macro' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'imagesdir' => examples_dir } + pdf = to_pdf <<~'END', attribute_overrides: { 'imagesdir' => examples_dir } https://example.org[image:sample-logo.jpg[ACME,pdfwidth=1pc]] is a sign of quality! - EOS + END annotations = get_annotations pdf, 1 (expect annotations).to have_size 1 @@ -2365,10 +2365,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do context 'Caption' do it 'should render caption under an image with a title' do - input = <<~'EOS' + input = <<~'END' .Tux, the Linux mascot image::tux.png[tux] - EOS + END pdf = to_pdf input, analyze: :image images = pdf.images @@ -2386,10 +2386,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should render caption above an image with a title when image_caption_end is top' do pdf_theme = { image_caption_end: 'top' } - input = <<~'EOS' + input = <<~'END' .Tux, the Linux mascot image::tux.png[tux] - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :image images = pdf.images @@ -2406,10 +2406,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should not duplicate footnote in a caption' do - input = <<~'EOS' + input = <<~'END' .Tux, the Linux mascotfootnote:[The one and only.] image::tux.png[tux] - EOS + END pdf = to_pdf input, analyze: true expected_lines = ['Figure 1. Tux, the Linux mascot[1]', '1. The one and only.'] @@ -2428,21 +2428,21 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should show caption for missing image' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true .A missing image image::no-such-image.png[Missing Image] - EOS + END (expect pdf.lines).to eql ['[Missing Image] | no-such-image.png', 'Figure 1. A missing image'] end).to log_message severity: :WARN, message: '~image to embed not found or not readable' end it 'should keep caption on same page as image when image exceeds height of page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' before image .Image caption image::tall-diagram.png[Tall diagram] - EOS + END (expect pdf.pages).to have_size 2 (expect get_images pdf, 2).to have_size 1 @@ -2452,12 +2452,12 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should keep caption on same page as image when image exceeds height of page and image_caption_end is top' do pdf_theme = { image_caption_end: 'top' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme before image .Image caption image::tall-diagram.png[Tall diagram] - EOS + END (expect pdf.pages).to have_size 2 (expect get_images pdf, 2).to have_size 1 @@ -2467,22 +2467,22 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should raise error if caption does not fit on a single page' do (expect do caption = (['excessive caption'] * 300).join ' ' - to_pdf <<~EOS + to_pdf <<~END before image .#{caption} image::tall-diagram.png[Tall diagram] - EOS + END end).to raise_exception Prawn::Errors::CannotFit end it 'should scale down SVG at top of page to fit image and caption if dimensions exceed page size', visual: true do - to_file = to_pdf_file <<~EOS, 'image-svg-with-caption-scale-to-fit-page.pdf' + to_file = to_pdf_file <<~END, 'image-svg-with-caption-scale-to-fit-page.pdf' :pdf-page-size: Letter .#{(['title text'] * 15).join ' '} image::watermark.svg[pdfwidth=100%] - EOS + END (expect to_file).to visually_match 'image-svg-with-caption-scale-to-fit-page.pdf' end @@ -2492,10 +2492,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_caption_align: 'inherit', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, attribute_overrides: { 'imagesdir' => examples_dir }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, attribute_overrides: { 'imagesdir' => examples_dir }, analyze: true .Behold, the great Wolpertinger! image::wolpertinger.jpg[,144,align=right] - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 (expect pdf.text[0][:x]).to be > midpoint @@ -2507,10 +2507,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_caption_max_width: '25%', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .This is a picture of our beloved Tux. image::tux.png[] - EOS + END midpoint = (get_page_size pdf, 1)[0] * 0.5 (expect pdf.lines).to eql ['Figure 1. This is a picture', 'of our beloved Tux.'] @@ -2526,10 +2526,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_caption_max_width: 'fit-content', } - input = <<~'EOS' + input = <<~'END' .This is a picture of our beloved Tux. image::tux.png[align=right] - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :image @@ -2552,10 +2552,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do end it 'should configure caption width to fit image width if float attribute is set on image' do - input = <<~'EOS' + input = <<~'END' .This is a picture of our beloved Tux. image::tux.png[align=right,float=right] - EOS + END tux_image = (to_pdf input, analyze: :image).images[0] pdf = to_pdf input, analyze: true @@ -2572,10 +2572,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do it 'should not change caption width if float attribute is set on image and caption max width is fit-content' do pdf_theme = { image_caption_align: 'inherit', image_caption_max_width: 'fit-content(50%)' } - input = <<~'EOS' + input = <<~'END' .This is a picture of our beloved Tux. image::tux.png[align=right,float=right] - EOS + END tux_image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -2597,10 +2597,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_caption_max_width: 'fit-content(50%)', } - input = <<~'EOS' + input = <<~'END' .This is a picture of our beloved Tux. image::tux.png[align=right] - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -2617,10 +2617,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_caption_max_width: 'fit-content', } - input = <<~'EOS' + input = <<~'END' .This is a picture of our beloved Tux. image::tux.png[align=right] - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :image @@ -2647,10 +2647,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_caption_max_width: 'fit-content(50%)', } - input = <<~'EOS' + input = <<~'END' .This is a picture of our beloved Tux. image::tux.png[align=right] - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :image @@ -2682,10 +2682,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_color: 'transparent', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line .Tux image::tux.png[align=center] - EOS + END (expect pdf.lines).to be_empty end @@ -2698,10 +2698,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_radius: 2, } - to_file = to_pdf_file <<~'EOS', 'image-border.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'image-border.pdf', pdf_theme: pdf_theme .Tux image::tux.png[align=center] - EOS + END (expect to_file).to visually_match 'image-border.pdf' end @@ -2712,10 +2712,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_color: '5D5D5D', } - to_file = to_pdf_file <<~'EOS', 'image-border-align-left.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'image-border-align-left.pdf', pdf_theme: pdf_theme .Tux image::tux.png[] - EOS + END (expect to_file).to visually_match 'image-border-align-left.pdf' end @@ -2728,10 +2728,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_fit: 'auto', } - to_file = to_pdf_file <<~'EOS', 'image-border-fit-page.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'image-border-fit-page.pdf', pdf_theme: pdf_theme .Tux image::tux.png[align=center] - EOS + END (expect to_file).to visually_match 'image-border-fit-page.pdf' end @@ -2743,10 +2743,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_color: '000000', } - to_file = to_pdf_file <<~'EOS', 'image-svg-border.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'image-svg-border.pdf', pdf_theme: pdf_theme .Square image::square.svg[align=right,pdfwidth=25%] - EOS + END (expect to_file).to visually_match 'image-svg-border.pdf' end @@ -2758,10 +2758,10 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_fit: 'auto', } - to_file = to_pdf_file <<~'EOS', 'image-svg-border-fit-page.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'image-svg-border-fit-page.pdf', pdf_theme: pdf_theme .Square image::square.svg[align=center,pdfwidth=25%] - EOS + END (expect to_file).to visually_match 'image-svg-border-fit-page.pdf' end @@ -2771,9 +2771,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_width: 1, image_border_color: '000000', } - to_file = to_pdf_file <<~'EOS', 'image-raster-noborder.pdf', pdf_theme: pdf_theme, attribute_overrides: { 'imagesdir' => examples_dir } + to_file = to_pdf_file <<~'END', 'image-raster-noborder.pdf', pdf_theme: pdf_theme, attribute_overrides: { 'imagesdir' => examples_dir } image::wolpertinger.jpg[,144,role=specimen noborder] - EOS + END (expect to_file).to visually_match 'image-wolpertinger.pdf' end @@ -2783,9 +2783,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_width: 1, image_border_color: 'DEDEDE', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line image::square-viewbox-only.svg[role=noborder] - EOS + END (expect pdf.lines.select {|it| it[:color] == 'DEDEDE' }).to be_empty end @@ -2795,9 +2795,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_width: [1, 2, 3, 4], image_border_color: 'DEDEDE', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line image::square.png[] - EOS + END lines = pdf.lines (expect lines).to have_size 4 (expect lines.map {|it| it[:width] }.sort).to eql [1, 2, 3, 4] @@ -2809,9 +2809,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do image_border_width: [4, 1], image_border_color: 'DEDEDE', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line image::square.png[] - EOS + END lines = pdf.lines (expect lines).to have_size 4 (expect lines.map {|it| it[:width] }.sort).to eql [1, 1, 4, 4] @@ -2829,9 +2829,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do } %w([.enclose]#image:tux.png[tux,fit=line]# image:tux.png[tux,fit=line,role=enclose]).each do |image| - to_file = to_pdf_file <<~EOS, 'image-inline-border.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'image-inline-border.pdf', pdf_theme: pdf_theme before #{image} after - EOS + END (expect to_file).to visually_match 'image-inline-border.pdf' end @@ -2845,9 +2845,9 @@ describe 'Asciidoctor::PDF::Converter - Image' do } %w([.enclose]#image:tux.png[tux,fit=line]# image:tux.png[tux,fit=line,role=enclose]).each do |image| - to_file = to_pdf_file <<~EOS, 'image-inline-background.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'image-inline-background.pdf', pdf_theme: pdf_theme before #{image} after - EOS + END (expect to_file).to visually_match 'image-inline-background.pdf' end diff --git a/spec/index_spec.rb b/spec/index_spec.rb index 35556a01..685cc5ac 100644 --- a/spec/index_spec.rb +++ b/spec/index_spec.rb @@ -4,16 +4,16 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Index' do it 'should not add index entries to the document if an index section is not present' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true You can add a ((visible index entry)) to your document by enclosing it in double round brackets. - EOS + END (expect pdf.find_text %r/visible index entry/).to have_size 1 (expect pdf.lines).to eql ['You can add a visible index entry to your document by enclosing it in double round brackets.'] end it 'should collapse space in front of hidden index terms' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true before (((zen))) (((yin))) @@ -21,13 +21,13 @@ describe 'Asciidoctor::PDF::Converter - Index' do after foo (((bar))) baz - EOS + END (expect pdf.lines).to eql ['before after', 'foo baz'] end it 'should normalize space in term in body and index section' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true ((foo {empty} bar))(((yin @@ -39,7 +39,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END p1_text = pdf.find_text page_number: 1 body_lines = pdf.lines p1_text @@ -51,21 +51,21 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not add index section if there are no index entries' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true == About This document has no index entries. [index] == Index - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.find_text 'Index').to be_empty end it 'should not include index section in TOC if index is empty' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toc: @@ -76,13 +76,13 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END (expect (pdf.page 2).text).not_to include 'Index' end it 'should add the index entries to the section with the index style' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title == Chapter About Cats @@ -99,7 +99,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END index_text = pdf.find_text 'Index', page_number: 4, font_size: 22 (expect index_text).to have_size 1 @@ -112,7 +112,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do category_k_text = pdf.find_text 'K', page_number: 4 (expect category_k_text).to have_size 1 (expect category_k_text[0][:font_name].downcase).to include 'bold' - (expect (pdf.lines pdf.find_text page_number: 4).join ?\n).to eql <<~'EOS'.chomp + (expect (pdf.lines pdf.find_text page_number: 4).join ?\n).to eql <<~'END'.chomp Index C cats, 1 @@ -122,11 +122,11 @@ describe 'Asciidoctor::PDF::Converter - Index' do dogs, 2 K king of the jungle, 1 - EOS + END end it 'should add index terms to index defined in section title with autogenerated ID' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Guide :doctype: book @@ -137,7 +137,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END index_title_text = pdf.find_unique_text 'Index' (expect index_title_text[:page_number]).to be 3 @@ -149,7 +149,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should preserve text formatting in display of index term' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title == Content @@ -162,7 +162,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] = Index - EOS + END (expect pdf.pages).to have_size 3 return_entry_text = pdf.find_unique_text 'return', page_number: 3 @@ -176,12 +176,12 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not group term with and without formatting' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true The ((`proc`)) keyword in Ruby defines a ((proc)), which is a block of code. [index] = Index - EOS + END (expect pdf.pages).to have_size 2 proc_text = (pdf.find_text %r/^proc/, page_number: 2).sort_by {|it| it[:string].length } @@ -194,7 +194,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not add index entries inside delimited block to index twice' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title == Chapter about Cats @@ -212,7 +212,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END index_heading_text = pdf.find_unique_text 'Index', page_number: 3, font_size: 22 (expect index_heading_text).not_to be_nil @@ -222,7 +222,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should create link from entry in index to location of term' do - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book @@ -233,7 +233,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END pdf = to_pdf input, analyze: true dogs_text = (pdf.find_text 'dogs are a human’s best friend.')[0] @@ -248,7 +248,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should target first occurance of index term, not in xreftext' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :notitle: @@ -277,7 +277,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END index_pgnum = (pdf.find_text 'Index')[0][:page_number] index_lines = pdf.lines pdf.find_text page_number: index_pgnum @@ -285,7 +285,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not assign number or chapter label to index section' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Cats & Dogs :sectnums: @@ -300,7 +300,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END index_text = pdf.find_text 'Chapter 3. Index', page_number: 4 (expect index_text).to be_empty @@ -309,7 +309,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should generate anchor names for indexterms which are reproducible between runs' do - input = <<~'EOS' + input = <<~'END' = Cats & Dogs :reproducible: @@ -324,7 +324,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END to_file_a = to_pdf_file input, 'index-reproducible-a.pdf', doctype: :book to_file_b = to_pdf_file input, 'index-reproducible-b.pdf', doctype: :book @@ -332,7 +332,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not automatically promote nested index terms' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title == Big Cats @@ -343,7 +343,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END category_c_text = pdf.find_text 'C', page_number: 3 (expect category_c_text).to have_size 1 @@ -352,67 +352,67 @@ describe 'Asciidoctor::PDF::Converter - Index' do (expect category_b_text).to be_empty category_l_text = pdf.find_text 'L', page_number: 3 (expect category_l_text).to be_empty - (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'EOS'.chomp + (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'END'.chomp Index C cats big cats, 1 lion, 1 - EOS + END end it 'should ignore empty list of terms' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true Not worth indexing. indexterm:[ ] [index] == Index - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.find_text 'Index').to be_empty end it 'should not group terms with different casing' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title ((This)) is not the same as ((this)) or ((that)). [index] == Index - EOS + END - (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'EOS'.chomp + (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'END'.chomp Index T that, 1 this, 1 This, 1 - EOS + END end it 'should sort capitalized terms ahead of non-capitalized terms' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title ((O.A.R.)) is a band, whereas ((oar)) is something you use to propel a boat. [index] == Index - EOS + END - (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'EOS'.chomp + (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'END'.chomp Index O O.A.R., 1 oar, 1 - EOS + END end it 'should group index entries that start with symbol under symbol category' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title == Symbols @@ -423,18 +423,18 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END - (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'EOS'.chomp + (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'END'.chomp Index @ @Transactional, 1 ©, 1 - EOS + END end it 'should handle XML special chars in index term' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true Put styles in the ((<head>)) tag. <<< @@ -443,9 +443,9 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END - (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'EOS'.chomp + (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql <<~'END'.chomp Index @ <head>, 1 @@ -454,11 +454,11 @@ describe 'Asciidoctor::PDF::Converter - Index' do &, 2 <, 2 >, 2 - EOS + END end it 'should not put letters outside of ASCII charset in symbol category' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title == Unicode Party @@ -469,30 +469,30 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END if gem_available? 'ffi-icu' - expected = <<~'EOS'.chomp + expected = <<~'END'.chomp Index E étudier, 1 L λ, 1 - EOS + END else - expected = <<~'EOS'.chomp + expected = <<~'END'.chomp Index É étudier, 1 Λ λ, 1 - EOS + END end (expect (pdf.lines pdf.find_text page_number: 3).join ?\n).to eql expected end it 'should sort terms in index, ignoring case' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book @@ -511,7 +511,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END index_pagenum = (pdf.find_text 'Index')[0][:page_number] index_page_lines = pdf.lines pdf.find_text page_number: index_pagenum @@ -563,7 +563,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not combine deduplicate page numbers if same index entry occurs on the same page when media is screen' do - input = <<~'EOS' + input = <<~'END' = Document Title == First Chapter @@ -582,7 +582,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END pdf = to_pdf input, doctype: :book, analyze: true (expect (pdf.lines pdf.find_text page_number: 5).join ?\n).to include 'coming soon, 1, 2, 2, 3, 3' @@ -593,7 +593,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not combine range if same index entry occurs on sequential pages when media is screen' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title == First Chapter @@ -610,13 +610,13 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END (expect (pdf.lines pdf.find_text page_number: 5).join ?\n).to include 'coming soon, 1, 2, 3' end it 'should remove duplicate sequential pages and link to first occurrence when index-pagenum-sequence-style is page' do - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book :index-pagenum-sequence-style: page @@ -639,7 +639,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END pdf = to_pdf input, analyze: true index_lines = pdf.lines pdf.find_text page_number: 5 @@ -656,7 +656,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should combine range if same index entry occurs on sequential pages when index-pagenum-sequence-style is range' do - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book :index-pagenum-sequence-style: range @@ -675,7 +675,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END pdf = to_pdf input, analyze: true index_lines = pdf.lines pdf.find_text page_number: 5 @@ -690,7 +690,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should combine range if same index entry occurs on sequential pages when media is not screen' do - pdf = to_pdf <<~'EOS', doctype: :book, attribute_overrides: { 'media' => 'print' }, analyze: true + pdf = to_pdf <<~'END', doctype: :book, attribute_overrides: { 'media' => 'print' }, analyze: true = Document Title == First Chapter @@ -707,7 +707,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END index_lines = pdf.lines pdf.find_text page_number: 5 (expect index_lines).to include 'coming soon, 1-3' @@ -716,12 +716,12 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not enclose page number in link or apply link styles if media is not screen' do - pdf = to_pdf <<~'EOS', doctype: :book, attribute_overrides: { 'media' => 'print', 'pdf-theme' => 'default' }, analyze: true + pdf = to_pdf <<~'END', doctype: :book, attribute_overrides: { 'media' => 'print', 'pdf-theme' => 'default' }, analyze: true ((index term)) [index] == Index - EOS + END index_term_text = pdf.find_unique_text %r/^index term/, page_number: 2 (expect index_term_text[:string]).to eql 'index term, 1' @@ -732,7 +732,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do indexterm_pagenums = [1, 10, 11, 13, 15, 16, 100, 150] pagebreak = %(\n\n<<<\n\n) input_lines = (1.upto 150).map {|pagenum| (indexterm_pagenums.include? pagenum) ? '((monkey))' : 'business' } - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :doctype: book :media: print @@ -740,13 +740,13 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END (expect pdf.lines pdf.pages[-1][:text]).to include 'monkey, 1, 10-11, 13, 15-16, 100, 150' end it 'should apply hanging indent to wrapped lines equal to twice level indent' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book @@ -754,7 +754,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END searching_text = (pdf.find_text page_number: 3, string: 'searching')[0] fun_profit_text = (pdf.find_text page_number: 3, string: /^for fun/)[0] @@ -766,7 +766,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not insert blank line if index term is forced to break' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :notitle: @@ -775,7 +775,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END flags_text = (pdf.find_text 'flags', page_number: 2)[0] short_flag_text = (pdf.find_text %r/^SHORT_FLAG/, page_number: 2)[0] @@ -786,7 +786,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should arrange index entries into two columns by default' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :doctype: book :notitle: @@ -795,7 +795,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END category_a_text = (pdf.find_text 'A')[0] category_p_text = (pdf.find_text 'P')[0] @@ -806,7 +806,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should allow theme to configure number of columns' do - pdf = to_pdf <<~EOS, pdf_theme: { index_columns: 3 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { index_columns: 3 }, analyze: true = Document Title :doctype: book :notitle: @@ -815,7 +815,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END category_a_text = (pdf.find_text 'A')[0] category_l_text = (pdf.find_text 'L')[0] @@ -830,7 +830,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should ignore index columns if columns are set on page' do - pdf = to_pdf <<~EOS, pdf_theme: { page_columns: 2, index_columns: 3 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { page_columns: 2, index_columns: 3 }, analyze: true = Document Title :notitle: @@ -838,7 +838,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 category_g_text = (pdf.find_text 'A')[0] @@ -862,14 +862,14 @@ describe 'Asciidoctor::PDF::Converter - Index' do base_font_family: 'Missing Null', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true foo ((bar)) #baz# foo bar #baz# [index] == Index - EOS + END baz_texts = pdf.find_text 'baz' (expect baz_texts).to have_size 2 @@ -877,7 +877,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not distribute excess bottom margin at top of next column' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :pdf-page-size: A6 @@ -886,7 +886,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END b_category_text = pdf.find_unique_text 'B', page_number: 3 z_category_text = pdf.find_unique_text 'Z', page_number: 3 @@ -900,7 +900,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do page_margin_outer: 36, index_columns: 1, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :notitle: @@ -929,7 +929,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END d_category_text = pdf.find_unique_text 'D', page_number: 3 s_category_text = pdf.find_unique_text 'S', page_number: 4 @@ -945,7 +945,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do page_margin_inner: 54, page_margin_outer: 18, } - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :notitle: @@ -958,7 +958,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END (expect pdf.pages).to have_size 5 midpoint_recto = 54 + (pdf.pages[0][:size][0] - 72) * 0.5 @@ -983,7 +983,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should indent TOC title properly when index exceeds a page and section indent is positive' do - pdf = to_pdf <<~EOS, pdf_theme: { section_indent: 50 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { section_indent: 50 }, analyze: true = Document Title :doctype: book :toc: @@ -1000,7 +1000,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do [index] == Index - EOS + END toc_title_text = pdf.find_unique_text 'Table of Contents' (expect toc_title_text[:x]).to eql 48.24 @@ -1010,7 +1010,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not push following section to new page if index section does not extend to bottom of page' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title == Chapter About Cats @@ -1029,7 +1029,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do == Index == Section After Index - EOS + END (expect pdf.pages).to have_size 1 category_k_text = pdf.find_unique_text 'K' @@ -1040,7 +1040,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should not push following section to new page if index section does not extend to bottom of second page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title #{('a'..'z').map {|it| %(((#{it}-term))) }.join} @@ -1061,7 +1061,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do == Index == Section After Index - EOS + END (expect pdf.pages).to have_size 2 category_z_text = pdf.find_unique_text 'Z' @@ -1074,14 +1074,14 @@ describe 'Asciidoctor::PDF::Converter - Index' do context 'ICU', if: (gem_available? 'ffi-icu'), &(proc do it 'should group terms by uppercase ASCII letter' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :doctype: book ((écriter)) ((être)) [index] == Index - EOS + END categories = (pdf.find_text page_number: 2).select {|it| it[:string].length == 1 && it[:font_name] == 'NotoSerif-Bold' } (expect categories).to have_size 1 @@ -1089,17 +1089,17 @@ describe 'Asciidoctor::PDF::Converter - Index' do end it 'should sort terms in index asciibetically' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :doctype: book ((ecouter)) ((Écriter)) ((être)) ((empêcher)) ((Европа)) ((alpha)) ((gamma)) [index] == Index - EOS + END index_pagenum = (pdf.find_text 'Index')[0][:page_number] - expected_lines = <<~'EOS'.lines.map(&:chomp) + expected_lines = <<~'END'.lines.map(&:chomp) Index A alpha, 1 @@ -1111,7 +1111,7 @@ describe 'Asciidoctor::PDF::Converter - Index' do Европа, 1 G gamma, 1 - EOS + END index_lines = pdf.lines pdf.find_text page_number: index_pagenum (expect index_lines).to eql expected_lines end diff --git a/spec/link_spec.rb b/spec/link_spec.rb index d79efc13..daa58f07 100644 --- a/spec/link_spec.rb +++ b/spec/link_spec.rb @@ -76,9 +76,9 @@ describe 'Asciidoctor::PDF::Converter - Link' do end it 'should not break on last character of bare URL' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true https://this.is.a.very.long.url.that.is.going.to.be.split.at.a.breakable.location.com/verylongpathname?a[] - EOS + END lines = pdf.lines (expect lines).to have_size 2 (expect lines[0]).to end_with '/' @@ -93,18 +93,18 @@ describe 'Asciidoctor::PDF::Converter - Link' do end it 'should not split bare URL when using an AFM font' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_font_family: 'Helvetica' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_font_family: 'Helvetica' }, analyze: true this line contains a URL that falls at the end of the line and yet cannot be split https://goo.gl/search/asciidoctor - EOS + END lines = pdf.lines (expect lines).to have_size 2 (expect lines[1]).to eql 'https://goo.gl/search/asciidoctor' end it 'should not split bare URL after scheme' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true this line contains a URL that falls at the end of the line that is not split after the scheme https://goo.gl/search/asciidoctor - EOS + END lines = pdf.lines (expect lines).to have_size 2 (expect lines[1]).to eql 'https://goo.gl/search/asciidoctor' @@ -112,31 +112,31 @@ describe 'Asciidoctor::PDF::Converter - Link' do it 'should reveal URL of link when media=print or media=prepress' do %w(print prepress).each do |media| - pdf = to_pdf <<~'EOS', attribute_overrides: { 'media' => media }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'media' => media }, analyze: true https://asciidoctor.org[Asciidoctor] is a text processor. - EOS + END (expect pdf.lines).to eql ['Asciidoctor [https://asciidoctor.org] is a text processor.'] end end it 'should reveal URL of link when show-link-uri is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :show-link-uri: https://asciidoctor.org[Asciidoctor] is a text processor. - EOS + END (expect pdf.lines).to eql ['Asciidoctor [https://asciidoctor.org] is a text processor.'] end it 'should not reveal URL of link when show-link-uri is unset in document even when media is print or prepress' do %w(print prepress).each do |media| - pdf = to_pdf <<~'EOS', attribute_overrides: { 'media' => media }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'media' => media }, analyze: true :!show-link-uri: https://asciidoctor.org[Asciidoctor] is a text processor. - EOS + END (expect pdf.lines).to eql ['Asciidoctor is a text processor.'] end @@ -144,9 +144,9 @@ describe 'Asciidoctor::PDF::Converter - Link' do it 'should not reveal URL of link when show-link-uri is unset from API even media is print or prepress' do %w(print prepress).each do |media| - pdf = to_pdf <<~'EOS', attribute_overrides: { 'media' => media, 'show-link-uri' => nil }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'media' => media, 'show-link-uri' => nil }, analyze: true https://asciidoctor.org[Asciidoctor] is a text processor. - EOS + END (expect pdf.lines).to eql ['Asciidoctor is a text processor.'] end diff --git a/spec/list_spec.rb b/spec/list_spec.rb index 433557ae..8e865168 100644 --- a/spec/list_spec.rb +++ b/spec/list_spec.rb @@ -5,13 +5,13 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - List' do context 'Unordered' do it 'should use different marker for first three list levels' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * level one ** level two *** level three **** level four * back to level one - EOS + END expected_lines = [ '• level one', @@ -25,12 +25,12 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should indent each nested list' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * level one ** level two *** level three * back to level one - EOS + END prev_it = nil %w(one two three).each do |it| @@ -45,13 +45,13 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should use list item spacing between lineal lists' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * yak * foo ** bar * yin ** yang - EOS + END item_texts = pdf.find_text %r/^\p{Alpha}/ (expect item_texts).to have_size 5 @@ -63,7 +63,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should disable indent for list if list_indent is 0' do - pdf = to_pdf <<~'EOS', pdf_theme: { list_indent: 0 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { list_indent: 0 }, analyze: true before * a @@ -71,7 +71,7 @@ describe 'Asciidoctor::PDF::Converter - List' do * c after - EOS + END (expect pdf.lines).to include %(\u2022 a) before_text = pdf.find_unique_text 'before' @@ -80,24 +80,24 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should use marker specified by style' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [square] * one * two * three - EOS + END (expect pdf.lines).to eql ['▪ one', '▪ two', '▪ three'] end it 'should emit warning if list style is unrecognized and fall back to disc' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [oval] * one * two * three - EOS + END (expect pdf.find_text ?\u2022).to have_size 3 end).to log_message severity: :WARN, message: 'unknown unordered list style: oval' @@ -105,7 +105,7 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should not emit warning if list style is unrecognized in scratch document' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%unbreakable] -- [foobarbaz] @@ -113,21 +113,21 @@ describe 'Asciidoctor::PDF::Converter - List' do * bar * baz -- - EOS + END (expect pdf.find_text ?\u2022).to have_size 3 end).to log_message severity: :WARN, message: 'unknown unordered list style: foobarbaz' # asserts count of 1 end it 'should make bullets invisible if list has no-bullet style' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true reference [no-bullet] * wood * hammer * nail - EOS + END (expect pdf.lines[1..-1]).to eql %w(wood hammer nail) left_margin = pdf.text[0][:x] @@ -138,7 +138,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should disable indent for no-bullet list if list_indent is 0' do - pdf = to_pdf <<~'EOS', pdf_theme: { list_indent: 0 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { list_indent: 0 }, analyze: true before [no-bullet] @@ -147,7 +147,7 @@ describe 'Asciidoctor::PDF::Converter - List' do * c after - EOS + END (expect pdf.lines).to include 'a' before_text = pdf.find_unique_text 'before' @@ -156,7 +156,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should apply proper indentation for each list style that hides the marker' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true reference [unstyled] @@ -167,7 +167,7 @@ describe 'Asciidoctor::PDF::Converter - List' do [none] * none - EOS + END (expect pdf.text).to have_size 4 left_margin = (pdf.find_unique_text 'reference')[:x] @@ -181,7 +181,7 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should not indent list with no marker if list indent is not set or set to 0 in theme' do [nil, 0].each do |indent| - pdf = to_pdf <<~'EOS', pdf_theme: { list_indent: indent }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { list_indent: indent }, analyze: true before [no-bullet] @@ -190,7 +190,7 @@ describe 'Asciidoctor::PDF::Converter - List' do * c after - EOS + END left_margin = (pdf.find_unique_text 'before')[:x] none_item = pdf.find_unique_text 'a' @@ -205,22 +205,22 @@ describe 'Asciidoctor::PDF::Converter - List' do ulist_marker_square_content: '$', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true * diamond ** dotted circle *** dollar - EOS + END (expect pdf.lines).to eql [%(\u25ca diamond), %(\u25cc dotted circle), '$ dollar'] end it 'should allow theme to change marker color for ulist' do [:list_marker_font_color, :ulist_marker_font_color].each do |key| - pdf = to_pdf <<~'EOS', pdf_theme: { key => '00FF00' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { key => '00FF00' }, analyze: true * all * the * things - EOS + END marker_colors = (pdf.find_text ?\u2022).map {|it| it[:font_color] }.uniq (expect marker_colors).to eql ['00FF00'] @@ -235,11 +235,11 @@ describe 'Asciidoctor::PDF::Converter - List' do ulist_marker_line_height: 0.625, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true * all * the * things - EOS + END marker = (pdf.find_text %(\u2022))[0] text = pdf.find_unique_text 'all' @@ -251,11 +251,11 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should allow theme to change marker font style for ulist' do pdf_theme = { ulist_marker_font_style: 'bold' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true * one * two * three - EOS + END marker = (pdf.find_text ?\u2022)[0] (expect marker[:font_name]).to eql 'NotoSerif-Bold' @@ -264,12 +264,12 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should allow theme to change specific marker font style for ulist' do pdf_theme = { ulist_marker_circle_font_style: 'bold' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [circle] * one * two * three - EOS + END marker = (pdf.find_text ?\u25e6)[0] (expect marker[:font_name]).to eql 'NotoSerif-Bold' @@ -280,9 +280,9 @@ describe 'Asciidoctor::PDF::Converter - List' do extends: 'default-with-font-fallbacks', ulist_marker_disc_content: ?\u2055, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true * missing marker - EOS + END marker_text = pdf.find_unique_text ?\u2055 (expect marker_text[:width]).to eql 5.25 @@ -295,9 +295,9 @@ describe 'Asciidoctor::PDF::Converter - List' do ulist_marker_disc_content: ?\uf192, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true * bullseye! - EOS + END (expect pdf.lines).to eql [%(\uf192 bullseye!)] marker_text = pdf.find_unique_text ?\uf192 @@ -307,11 +307,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should not insert extra blank line if list item text is forced to break' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true * #{'a' * 100} * b + b - EOS + END a1_marker_text, b1_marker_text = pdf.find_text ?\u2022 a1_text, a2_text = pdf.find_text %r/^a+$/ @@ -322,11 +322,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should use consistent line height even if list item is entirely monospace' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * foo * `mono` * bar - EOS + END mark_texts = pdf.find_text '•' (expect mark_texts).to have_size 3 @@ -336,12 +336,12 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should apply consistent line height to wrapped line that only contained monospaced text' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * A list item containing a `short code phrase` and a `slightly longer code phrase` and a `very long code phrase that wraps to the next line` * B + `code phrase for reference` * C - EOS + END mark_texts = pdf.find_text ?\u2022 a1_text = pdf.find_unique_text %r/^A / @@ -355,11 +355,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should apply correct margin if primary text of list item is blank' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * foo * {blank} * bar - EOS + END mark_texts = pdf.find_text '•' (expect mark_texts).to have_size 3 @@ -369,11 +369,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should align first block of list item with marker if primary text is blank' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * {blank} + text - EOS + END text = pdf.text (expect text).to have_size 2 @@ -381,7 +381,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should keep list marker with primary text' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :pdf-page-size: 52mm x 74mm :pdf-page-margin: 0 @@ -390,7 +390,7 @@ describe 'Asciidoctor::PDF::Converter - List' do .... * list item - EOS + END marker_text = pdf.find_unique_text ?\u2022 (expect marker_text[:page_number]).to be 2 @@ -399,7 +399,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should position marker correctly when media is prepress and list item is advanced to next page' do - pdf = to_pdf <<~'EOS', pdf_theme: { prose_margin_bottom: 705.5 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { prose_margin_bottom: 705.5 }, analyze: true :media: prepress filler @@ -407,7 +407,7 @@ describe 'Asciidoctor::PDF::Converter - List' do * first * middle * last - EOS + END marker_texts = pdf.find_text '•', page_number: 2 (expect marker_texts).to have_size 2 @@ -415,7 +415,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should position marker correctly when media is prepress and list item is split across page' do - pdf = to_pdf <<~'EOS', pdf_theme: { prose_margin_bottom: 705 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { prose_margin_bottom: 705 }, analyze: true :media: prepress filler @@ -424,7 +424,7 @@ describe 'Asciidoctor::PDF::Converter - List' do * middle + more middle * last - EOS + END (expect (pdf.find_unique_text 'middle')[:page_number]).to be 1 (expect (pdf.find_text '•')[1][:page_number]).to be 1 @@ -434,7 +434,7 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should reuse next page of block with background when positioning marker when media is prepress' do filler = ['filler'] filler_list_item = ['* Ex nam suas nemore dignissim, vel apeirian democritum et. At ornatus splendide sed, phaedrum omittantur usu an, vix an noster voluptatibus.'] - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END :media: prepress .Sidebar @@ -457,7 +457,7 @@ describe 'Asciidoctor::PDF::Converter - List' do [%hardbreaks] #{filler * 5 * ?\n} - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -473,27 +473,27 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow text alignment to be set using role', visual: true do - to_file = to_pdf_file <<~EOS, 'list-text-left-role.pdf' + to_file = to_pdf_file <<~END, 'list-text-left-role.pdf' [.text-left] * #{lorem_ipsum '2-sentences-1-paragraph'} - EOS + END (expect to_file).to visually_match 'list-text-left.pdf' end it 'should allow text alignment to be set using theme', visual: true do - to_file = to_pdf_file <<~EOS, 'list-text-left-theme.pdf', pdf_theme: { list_text_align: 'left' } + to_file = to_pdf_file <<~END, 'list-text-left-theme.pdf', pdf_theme: { list_text_align: 'left' } * #{lorem_ipsum '2-sentences-1-paragraph'} - EOS + END (expect to_file).to visually_match 'list-text-left.pdf' end end context 'Checklist' do it 'should replace markers with checkboxes in checklist' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * [ ] todo * [x] done - EOS + END (expect pdf.lines).to eql [%(\u2610 todo), %(\u2611 done)] end @@ -504,10 +504,10 @@ describe 'Asciidoctor::PDF::Converter - List' do ulist_marker_checked_content: ?\u25d9, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true * [ ] todo * [x] done - EOS + END (expect pdf.lines).to eql [%(\u25d8 todo), %(\u25d9 done)] end @@ -517,9 +517,9 @@ describe 'Asciidoctor::PDF::Converter - List' do extends: 'default-with-font-fallbacks', ulist_marker_checked_content: ?\u303c, } - to_file = to_pdf_file <<~'EOS', 'list-checked-glyph-fallback.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'list-checked-glyph-fallback.pdf', pdf_theme: pdf_theme * [x] done - EOS + END (expect to_file).to visually_match 'list-checked-glyph-fallback.pdf' end @@ -533,10 +533,10 @@ describe 'Asciidoctor::PDF::Converter - List' do ulist_marker_checked_content: ?\uf046, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true * [ ] todo * [x] done - EOS + END (expect pdf.lines).to eql [%(\uf096 todo), %(\uf046 done)] unchecked_marker_text = pdf.find_unique_text ?\uf096 @@ -551,7 +551,7 @@ describe 'Asciidoctor::PDF::Converter - List' do context 'Ordered' do it 'should number list items using arabic, loweralpha, lowerroman, upperalpha, upperroman numbering by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true . 1 .. a ... i @@ -559,13 +559,13 @@ describe 'Asciidoctor::PDF::Converter - List' do ..... I . 2 . 3 - EOS + END (expect pdf.lines).to eql ['1. 1', 'a. a', 'i. i', 'A. A', 'I. I', '2. 2', '3. 3'] end it 'should indent each nested list' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true . 1 .. a ... i @@ -573,7 +573,7 @@ describe 'Asciidoctor::PDF::Converter - List' do ..... I . 2 . 3 - EOS + END prev_it = nil %w(1 a i A I).each do |it| @@ -588,24 +588,24 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should use marker specified by style' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [lowerroman] . one . two . three - EOS + END (expect pdf.lines).to eql ['i. one', 'ii. two', 'iii. three'] end it 'should fall back to arabic if list style is unknown' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [binary] . one . two . three - EOS + END (expect pdf.lines[0]).to eql '1. one' end).to not_log_message @@ -613,10 +613,10 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should support decimal marker style' do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true [decimal] #{(?a..?z).map {|c| '. ' + c }.join blank_line} - EOS + END lines = pdf.lines (expect lines).to have_size 26 @@ -626,10 +626,10 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should support decimal marker style when start value has two digits' do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true [decimal,start=10] #{(?a..?z).map {|c| '. ' + c }.join blank_line} - EOS + END lines = pdf.lines (expect lines).to have_size 26 @@ -639,11 +639,11 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should allow theme to change marker color for olist' do [:list_marker_font_color, :olist_marker_font_color].each do |key| - pdf = to_pdf <<~'EOS', pdf_theme: { key => '00FF00' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { key => '00FF00' }, analyze: true . one . two . three - EOS + END marker_colors = (pdf.find_text %r/\d\./).map {|it| it[:font_color] }.uniq (expect marker_colors).to eql ['00FF00'] @@ -657,11 +657,11 @@ describe 'Asciidoctor::PDF::Converter - List' do olist_marker_line_height: 0.976, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true . one . two . three - EOS + END marker = pdf.find_unique_text '1.' text = pdf.find_unique_text 'one' @@ -673,22 +673,22 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should allow theme to change marker font style for olist' do pdf_theme = { olist_marker_font_style: 'bold' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true . one . two . three - EOS + END marker = pdf.find_unique_text '1.' (expect marker[:font_name]).to eql 'NotoSerif-Bold' end it 'should use consistent line height even if list item is entirely monospace' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true . foo . `mono` . bar - EOS + END mark_texts = pdf.text.select {|it| it[:string].end_with? '.' } (expect mark_texts).to have_size 3 @@ -698,7 +698,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should align list numbers to right and extend towards left margin' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true . one . two . three @@ -709,7 +709,7 @@ describe 'Asciidoctor::PDF::Converter - List' do . eight . nine . ten - EOS + END nine_text = pdf.find_unique_text 'nine' ten_text = pdf.find_unique_text 'ten' @@ -730,10 +730,10 @@ describe 'Asciidoctor::PDF::Converter - List' do 'loweralpha' => %w(j a), 'upperalpha' => %w(J A), }.each do |style, (last, first)| - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true [#{style}%reversed] #{items.map {|it| %(. #{it}) }.join ?\n} - EOS + END lines = pdf.lines expect(lines[0]).to eql %(#{last}. ten) expect(lines[-1]).to eql %(#{first}. one) @@ -744,11 +744,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should start numbering at value of start attribute if specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [start=9] . nine . ten - EOS + END no1_text = pdf.find_unique_text '1.' (expect no1_text).to be_nil @@ -759,11 +759,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should start numbering at value of specified start attribute using specified numeration style' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [upperroman,start=9] . nine . ten - EOS + END no1_text = pdf.find_unique_text 'I.' (expect no1_text).to be_nil @@ -774,83 +774,83 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should ignore start attribute if marker is disabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [unstyled,start=10] . a . b . c - EOS + END (expect pdf.lines).to eql %w(a b c) end it 'should ignore start value of 1' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [start=1] . one . two . three - EOS + END (expect pdf.lines).to eql ['1. one', '2. two', '3. three'] end it 'should allow start value to be less than 1 for list with arabic numbering' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [start=-1] . negative one . zero . positive one - EOS + END (expect pdf.lines).to eql ['-1. negative one', '0. zero', '1. positive one'] end it 'should allow start value to be less than 1 for list with roman numbering' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [lowerroman,start=-1] . negative one . zero . positive one - EOS + END (expect pdf.lines).to eql ['-1. negative one', '0. zero', 'i. positive one'] end it 'should allow start value to be less than 1 for list with decimal numbering' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [decimal,start=-3] . on . our . way . to . one - EOS + END (expect pdf.lines).to eql ['-03. on', '-02. our', '-01. way', '00. to', '01. one'] end # FIXME: this should be -1, 0, a it 'should ignore start value less than 1 for list with alpha numbering' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [loweralpha,start=-1] . negative one . zero . positive one - EOS + END (expect pdf.lines).to eql ['a. negative one', 'b. zero', 'c. positive one'] end it 'should make numbers invisible if list has unnumbered style' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true reference [unnumbered] . one . two . three - EOS + END (expect pdf.lines[1..-1]).to eql %w(one two three) left_margin = pdf.text[0][:x] @@ -861,7 +861,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should apply proper indentation for each list style that hides the marker' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true reference [unstyled] @@ -875,7 +875,7 @@ describe 'Asciidoctor::PDF::Converter - List' do [none] . none - EOS + END (expect pdf.text).to have_size 5 left_margin = (pdf.find_unique_text 'reference')[:x] @@ -890,7 +890,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should keep list marker with primary text' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :pdf-page-size: 52mm x 74mm :pdf-page-margin: 0 @@ -899,7 +899,7 @@ describe 'Asciidoctor::PDF::Converter - List' do .... . list item - EOS + END marker_text = pdf.find_unique_text '1.' (expect marker_text[:page_number]).to be 2 @@ -910,7 +910,7 @@ describe 'Asciidoctor::PDF::Converter - List' do context 'Mixed' do it 'should use correct default markers for mixed nested lists' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * l1 . l2 ** l3 @@ -918,14 +918,14 @@ describe 'Asciidoctor::PDF::Converter - List' do *** l5 ... l6 * l1 - EOS + END (expect pdf.lines).to eql ['• l1', '1. l2', '▪ l3', 'a. l4', '▪ l5', 'i. l6', '• l1'] end # NOTE: expand this test as necessary to cover the various permutations it 'should not insert excess space between nested lists or list items with block content', visual: true do - to_file = to_pdf_file <<~'EOS', 'list-complex-nested.pdf' + to_file = to_pdf_file <<~'END', 'list-complex-nested.pdf' * list item . first + @@ -940,7 +940,7 @@ describe 'Asciidoctor::PDF::Converter - List' do attached paragraph * list item - EOS + END (expect to_file).to visually_match 'list-complex-nested.pdf' end @@ -948,7 +948,7 @@ describe 'Asciidoctor::PDF::Converter - List' do context 'Description' do it 'should keep term with primary text' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :pdf-page-size: 52mm x 80mm :pdf-page-margin: 0 @@ -958,7 +958,7 @@ describe 'Asciidoctor::PDF::Converter - List' do term:: desc - EOS + END term_text = pdf.find_unique_text 'term' (expect term_text[:page_number]).to be 2 @@ -967,7 +967,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should keep all terms with primary text' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :pdf-page-size: 52mm x 87.5mm :pdf-page-margin: 0 @@ -978,7 +978,7 @@ describe 'Asciidoctor::PDF::Converter - List' do term 1:: term 2:: desc - EOS + END term1_text = pdf.find_unique_text 'term 1' (expect term1_text[:page_number]).to be 2 @@ -1011,11 +1011,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow theme to control line height of term' do - input = <<~'EOS' + input = <<~'END' first term:: second term:: description - EOS + END pdf = to_pdf input, analyze: true @@ -1030,7 +1030,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should support complex content', visual: true do - to_file = to_pdf_file <<~'EOS', 'list-complex-dlist.pdf' + to_file = to_pdf_file <<~'END', 'list-complex-dlist.pdf' term:: desc + @@ -1040,14 +1040,14 @@ describe 'Asciidoctor::PDF::Converter - List' do yin:: yang - EOS + END (expect to_file).to visually_match 'list-complex-dlist.pdf' end it 'should put margin below description when item has an attached block' do pdf_theme = { base_line_height: 1, sidebar_background_color: 'transparent' } - input = <<~'EOS' + input = <<~'END' term:: desc + **** @@ -1057,7 +1057,7 @@ describe 'Asciidoctor::PDF::Converter - List' do **** after **** - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true horizontal_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -1068,11 +1068,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should use narrow spacing around lineal list' do - pdf = to_pdf <<~'EOS', pdf_theme: { extends: 'base', base_line_height: 1 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { extends: 'base', base_line_height: 1 }, analyze: true yin:: * foobar yang:: - EOS + END spacing_above = (pdf.find_unique_text %r/^yin/)[:y] - (pdf.find_unique_text 'foobar').yield_self {|it| it[:y] + it[:font_size] } spacing_below = (pdf.find_unique_text 'foobar')[:y] - (pdf.find_unique_text 'yang').yield_self {|it| it[:y] + it[:font_size] } @@ -1081,12 +1081,12 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should put margin below description when item has a single nested list' do - input = <<~'EOS' + input = <<~'END' term:: desc * nested item after - EOS + END pdf = to_pdf input, pdf_theme: { base_line_height: 1 }, analyze: true desc_text = pdf.find_unique_text 'desc' @@ -1099,10 +1099,10 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should support last item with no description' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true yin:: yang foo:: - EOS + END (expect pdf.lines).to eql %w(yin yang foo) (expect pdf.find_text 'foo').not_to be_empty @@ -1112,7 +1112,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should apply correct margin to last item with no description' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=2*a] |=== | @@ -1124,7 +1124,7 @@ describe 'Asciidoctor::PDF::Converter - List' do | term:: desc |=== - EOS + END after_text = pdf.find_unique_text 'after' desc_text = pdf.find_unique_text 'desc' @@ -1135,10 +1135,10 @@ describe 'Asciidoctor::PDF::Converter - List' do context 'Horizontal' do it 'should not modify original document model during conversion' do - doc = Asciidoctor.load <<~'EOS', backend: 'pdf' + doc = Asciidoctor.load <<~'END', backend: 'pdf' [horizontal] foo:: bar - EOS + END original_dlist = doc.blocks[0] original_term, original_desc = (original_item = (original_items = original_dlist.items)[0]) @@ -1153,11 +1153,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should arrange horizontal list in two columns' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [horizontal] foo:: bar yin:: yang - EOS + END foo_text = pdf.find_unique_text 'foo' bar_text = pdf.find_unique_text 'bar' @@ -1171,10 +1171,10 @@ describe 'Asciidoctor::PDF::Converter - List' do description_list_term_font_color: 'AA0000', description_list_term_text_transform: 'uppercase', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [horizontal] term:: desc - EOS + END term_text = pdf.find_unique_text 'TERM' (expect term_text[:font_name]).to eql 'NotoSerif-Italic' @@ -1182,12 +1182,12 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow theme to control line height of term' do - input = <<~'EOS' + input = <<~'END' [horizontal] first term:: second term:: description - EOS + END pdf = to_pdf input, analyze: true @@ -1202,12 +1202,12 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should include title above horizontal list' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true .Balance [horizontal] foo:: bar yin:: yang - EOS + END title_text = pdf.find_text 'Balance' (expect title_text).to have_size 1 @@ -1218,10 +1218,10 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should inherit term font styles from theme' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [horizontal] __f__oo:: bar - EOS + END text = pdf.text (expect text).to have_size 3 @@ -1232,10 +1232,10 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should apply inline formatted to term even if font style is set to normal by theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { description_list_term_font_style: 'normal' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { description_list_term_font_style: 'normal' }, analyze: true [horizontal] **f**oo:: bar - EOS + END text = pdf.text (expect text).to have_size 3 @@ -1246,11 +1246,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should support item with no desc' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [horizontal] yin:: yang foo:: - EOS + END (expect pdf.find_text 'foo').not_to be_empty yin_text = pdf.find_unique_text 'yin' @@ -1259,14 +1259,14 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should support item with only blocks' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [horizontal] yin:: + yang foo:: bar - EOS + END (expect pdf.lines).to eql ['yin yang', 'foo bar'] yin_text = pdf.find_unique_text 'yin' @@ -1277,13 +1277,13 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should support multiple terms in horizontal list' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [horizontal] foo:: bar:: baz:: desc - EOS + END (expect pdf.find_text 'foo').not_to be_empty (expect pdf.find_text 'bar').not_to be_empty @@ -1295,14 +1295,14 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should align term to top when description spans multiple lines' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [horizontal] foo:: desc + _more desc_ + even more desc - EOS + END (expect pdf.find_text 'foo').not_to be_empty (expect pdf.find_text 'desc').not_to be_empty @@ -1314,25 +1314,25 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should not break term that does not extend past the midpoint of the page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true [horizontal] handoverallthekeystoyourkingdom:: #{(['submit'] * 50).join ' '} - EOS + END (expect pdf.lines[0]).to start_with 'handoverallthekeystoyourkingdom submit submit' end it 'should break term that extends past the midpoint of the page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true [horizontal] handoverallthekeystoyourkingdomtomenow:: #{(['submit'] * 50).join ' '} - EOS + END (expect pdf.lines[0]).not_to start_with 'handoverallthekeystoyourkingdomtomenow' end it 'should support complex content in horizontal list', visual: true do - to_file = to_pdf_file <<~'EOS', 'list-horizontal-dlist.pdf' + to_file = to_pdf_file <<~'END', 'list-horizontal-dlist.pdf' [horizontal] term:: desc @@ -1343,14 +1343,14 @@ describe 'Asciidoctor::PDF::Converter - List' do yin:: yang - EOS + END (expect to_file).to visually_match 'list-horizontal-dlist.pdf' end it 'should correctly compute height of attached delimited block inside dlist at page top' do pdf_theme = { sidebar_background_color: 'transparent' } - input = <<~'EOS' + input = <<~'END' [horizontal] first term:: + @@ -1361,7 +1361,7 @@ describe 'Asciidoctor::PDF::Converter - List' do **** sidebar outside list **** - EOS + END horizontal_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines .select {|it| it[:from][:y] == it[:to][:y] }.sort_by {|it| -it[:from][:y] } @@ -1373,7 +1373,7 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should correctly compute height of attached delimited block inside dlist below page top' do pdf_theme = { sidebar_background_color: 'transparent' } - input = <<~'EOS' + input = <<~'END' **** sidebar outside list **** @@ -1384,7 +1384,7 @@ describe 'Asciidoctor::PDF::Converter - List' do **** sidebar inside list **** - EOS + END horizontal_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines .select {|it| it[:from][:y] == it[:to][:y] }.sort_by {|it| -it[:from][:y] } @@ -1396,7 +1396,7 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should leave correct spacing after last attached block' do pdf_theme = { sidebar_background_color: 'transparent' } - input = <<~'EOS' + input = <<~'END' [horizontal] first term:: + @@ -1413,7 +1413,7 @@ describe 'Asciidoctor::PDF::Converter - List' do **** sidebar outside list **** - EOS + END horizontal_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines .select {|it| it[:from][:y] == it[:to][:y] }.sort_by {|it| -it[:from][:y] } @@ -1426,7 +1426,7 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should convert horizontal dlist inside AsciiDoc table cell and not add bottom margin' do pdf_theme = { sidebar_background_color: 'transparent' } - input = <<~'EOS' + input = <<~'END' [frame=ends,grid=none] |=== a| @@ -1437,7 +1437,7 @@ describe 'Asciidoctor::PDF::Converter - List' do sidebar for term **** |=== - EOS + END horizontal_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines .select {|it| it[:from][:y] == it[:to][:y] }.sort_by {|it| -it[:from][:y] } @@ -1447,7 +1447,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should apply correct margin to last item with no description' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=2*a] |=== | @@ -1463,7 +1463,7 @@ describe 'Asciidoctor::PDF::Converter - List' do [] after horizontal |=== - EOS + END term_texts = pdf.find_text 'term' (expect term_texts).to have_size 2 @@ -1474,7 +1474,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should use prose margin around dlist nested in regular list' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=2*a] |=== | @@ -1492,7 +1492,7 @@ describe 'Asciidoctor::PDF::Converter - List' do second list item |=== - EOS + END ['list item', 'term', 'second list item'].each do |string| texts = pdf.find_text string @@ -1504,7 +1504,7 @@ describe 'Asciidoctor::PDF::Converter - List' do context 'Unordered' do it 'should layout unordered description list like an unordered list with subject in bold' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [unordered] item a:: about item a + @@ -1516,7 +1516,7 @@ describe 'Asciidoctor::PDF::Converter - List' do item c:: + details about item c - EOS + END (expect pdf.lines).to eql [ '• item a: about item a', @@ -1531,7 +1531,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow subject stop to be customized using subject-stop attribute' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [unordered,subject-stop=.] item a:: about item a + @@ -1539,13 +1539,13 @@ describe 'Asciidoctor::PDF::Converter - List' do item b:: about item b - EOS + END (expect pdf.lines).to eql ['• item a. about item a', 'more about item a', '• item b. about item b'] end it 'should not add subject stop if subject ends with stop punctuation' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [unordered,subject-stop=.] item a.:: about item a + @@ -1556,23 +1556,23 @@ describe 'Asciidoctor::PDF::Converter - List' do well?:: yes - EOS + END (expect pdf.lines).to eql ['• item a. about item a', 'more about item a', '• item b: about item b', '• well? yes'] end it 'should add subject stop if subject ends with character reference' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [unordered] &:: ampersand >:: greater than - EOS + END (expect pdf.lines).to eql ['• &: ampersand', '• >: greater than'] end it 'should stack subject on top of text if stack role is present' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [unordered.stack] item a:: about item a + @@ -1580,17 +1580,17 @@ describe 'Asciidoctor::PDF::Converter - List' do item b:: about item b - EOS + END (expect pdf.lines).to eql ['• item a', 'about item a', 'more about item a', '• item b', 'about item b'] end it 'should support item with no desc' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [unordered] yin:: yang foo:: - EOS + END (expect pdf.find_text 'foo').not_to be_empty yin_text = pdf.find_unique_text 'yin:' @@ -1601,7 +1601,7 @@ describe 'Asciidoctor::PDF::Converter - List' do context 'Ordered' do it 'should layout ordered description list like an ordered list with subject in bold' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [ordered] item a:: about item a + @@ -1613,7 +1613,7 @@ describe 'Asciidoctor::PDF::Converter - List' do item c:: + details about item c - EOS + END (expect pdf.lines).to eql [ '1. item a: about item a', @@ -1628,7 +1628,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow subject stop to be customized using subject-stop attribute' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [ordered,subject-stop=.] item a:: about item a + @@ -1636,13 +1636,13 @@ describe 'Asciidoctor::PDF::Converter - List' do item b:: about item b - EOS + END (expect pdf.lines).to eql ['1. item a. about item a', 'more about item a', '2. item b. about item b'] end it 'should not add subject stop if subject ends with stop punctuation' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [ordered,subject-stop=.] item a.:: about item a + @@ -1653,23 +1653,23 @@ describe 'Asciidoctor::PDF::Converter - List' do well?:: yes - EOS + END (expect pdf.lines).to eql ['1. item a. about item a', 'more about item a', '2. item b: about item b', '3. well? yes'] end it 'should add subject stop if subject ends with character reference' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [ordered] &:: ampersand >:: greater than - EOS + END (expect pdf.lines).to eql ['1. &: ampersand', '2. >: greater than'] end it 'should stack subject on top of text if stack role is present' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [ordered.stack] item a:: about item a + @@ -1677,7 +1677,7 @@ describe 'Asciidoctor::PDF::Converter - List' do item b:: about item b - EOS + END (expect pdf.lines).to eql ['1. item a', 'about item a', 'more about item a', '2. item b', 'about item b'] end @@ -1686,14 +1686,14 @@ describe 'Asciidoctor::PDF::Converter - List' do context 'Q & A' do it 'should convert qanda to ordered list' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [qanda] What is Asciidoctor?:: An implementation of the AsciiDoc processor in Ruby. What is the answer to the Ultimate Question?:: 42 - EOS + END (expect pdf.strings).to eql [ '1.', 'What is Asciidoctor?', @@ -1705,20 +1705,20 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should layout Q & A list like a description list with questions in italic', visual: true do - to_file = to_pdf_file <<~'EOS', 'list-qanda.pdf' + to_file = to_pdf_file <<~'END', 'list-qanda.pdf' [qanda] What's the answer to the ultimate question?:: 42 Do you have an opinion?:: Would you like to share it?:: Yes and no. - EOS + END (expect to_file).to visually_match 'list-qanda.pdf' end it 'should convert question with only block answer in Q & A list' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [qanda] Ultimate Question:: + @@ -1729,7 +1729,7 @@ describe 'Asciidoctor::PDF::Converter - List' do Only at the end will you come to understand that the answer is 42. -- - EOS + END (expect pdf.lines).to eql ['1. Ultimate Question', 'How much time do you have?', 'You must embark on a journey.', 'Only at the end will you come to understand that the answer is 42.'] unanswerable_q_text = pdf.find_unique_text 'Ultimate Question' @@ -1741,11 +1741,11 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should convert question with no answer in Q & A list' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [qanda] Question:: Answer Unanswerable Question:: - EOS + END unanswerable_q_text = pdf.find_unique_text 'Unanswerable Question' (expect pdf.lines).to eql ['1. Question', 'Answer', '2. Unanswerable Question'] @@ -1755,7 +1755,7 @@ describe 'Asciidoctor::PDF::Converter - List' do context 'Callout' do it 'should use callout numbers as list markers and in referenced block' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true .... line one <1> line two @@ -1763,7 +1763,7 @@ describe 'Asciidoctor::PDF::Converter - List' do .... <1> First line <2> Last line - EOS + END one_text = pdf.find_text ?\u2460 two_text = pdf.find_text ?\u2461 @@ -1777,7 +1777,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should use consistent line height even if list item is entirely monospace' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true .... line one <1> line two <2> @@ -1786,7 +1786,7 @@ describe 'Asciidoctor::PDF::Converter - List' do <1> describe one <2> `describe two` <3> describe three - EOS + END mark_texts = [(pdf.find_text ?\u2460)[-1], (pdf.find_text ?\u2461)[-1], (pdf.find_text ?\u2462)[-1]] (expect mark_texts).to have_size 3 @@ -1797,7 +1797,7 @@ describe 'Asciidoctor::PDF::Converter - List' do it 'should only separate colist and listing or literal block by list_item_spacing value' do %w(---- ....).each do |block_delim| - input = <<~EOS + input = <<~END #{block_delim} line one <1> line two @@ -1805,7 +1805,7 @@ describe 'Asciidoctor::PDF::Converter - List' do #{block_delim} <1> First line <2> Last line - EOS + END pdf = to_pdf input, analyze: :line bottom_line_y = pdf.lines[2][:from][:y] @@ -1822,7 +1822,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow theme to control top margin of callout lists that immediately follows a code block', visual: true do - input = <<~'EOS' + input = <<~'END' ---- line one <1> line two @@ -1830,7 +1830,7 @@ describe 'Asciidoctor::PDF::Converter - List' do ---- <1> First line <2> Last line - EOS + END pdf_theme = { callout_list_margin_top_after_code: 0 } @@ -1854,17 +1854,17 @@ describe 'Asciidoctor::PDF::Converter - List' do sidebar_background_color: 'transparent', } - ref_input = <<~'EOS' + ref_input = <<~'END' **** . describe first line **** - EOS + END ref_top_line_y = (to_pdf ref_input, pdf_theme: pdf_theme, analyze: :line).lines.map {|it| it[:from][:y] }.max ref_text_top = (to_pdf ref_input, pdf_theme: pdf_theme, analyze: true).text[0].yield_self {|it| it[:y] + it[:font_size] } expected_top_padding = ref_top_line_y - ref_text_top - input = <<~'EOS' + input = <<~'END' ---- line 1 <1> line 2 <2> @@ -1878,7 +1878,7 @@ describe 'Asciidoctor::PDF::Converter - List' do code ---- **** - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -1897,7 +1897,7 @@ describe 'Asciidoctor::PDF::Converter - List' do conum_font_size: nil, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true ---- site: url: https://docs.example.org # <1> @@ -1905,7 +1905,7 @@ describe 'Asciidoctor::PDF::Converter - List' do ---- <1> The base URL where the site is published. <2> Allow search engines to crawl the site. - EOS + END conum_1_text = pdf.find_text ?\u2460 (expect conum_1_text).to have_size 2 @@ -1922,7 +1922,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should not move cursor if callout list appears at top of page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true key-value pair ---- @@ -1931,7 +1931,7 @@ describe 'Asciidoctor::PDF::Converter - List' do #{(['- item'] * 46).join ?\n} ---- <1> key-value pair - EOS + END key_val_texts = pdf.find_text 'key-value pair' (expect key_val_texts).to have_size 2 @@ -1941,7 +1941,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should not collapse top margin if previous block is not a verbatim block' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true before ---- @@ -1951,11 +1951,11 @@ describe 'Asciidoctor::PDF::Converter - List' do ''' key-value pair - EOS + END reference_y = (pdf.find_unique_text 'key-value pair')[:y] - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true before ---- @@ -1965,14 +1965,14 @@ describe 'Asciidoctor::PDF::Converter - List' do ''' <1> key-value pair - EOS + END actual_y = (pdf.find_unique_text 'key-value pair')[:y] (expect actual_y).to eql reference_y end it 'should allow conum font color to be customized by theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { conum_font_color: '0000ff' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { conum_font_color: '0000ff' }, analyze: true .... line one <1> line two @@ -1980,7 +1980,7 @@ describe 'Asciidoctor::PDF::Converter - List' do .... <1> First line <2> Last line - EOS + END one_text = pdf.find_text ?\u2460 (expect one_text).to have_size 2 @@ -1991,7 +1991,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow conum font size and line height in colist to be customized by theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { conum_font_size: 8, conum_line_height: 1.8 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { conum_font_size: 8, conum_line_height: 1.8 }, analyze: true .... line one <1> line two @@ -1999,7 +1999,7 @@ describe 'Asciidoctor::PDF::Converter - List' do .... <1> First line <2> Last line - EOS + END one_text = pdf.find_text ?\u2460 (expect one_text).to have_size 2 @@ -2011,7 +2011,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should support filled conum glyphs if specified in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { conum_glyphs: 'filled' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { conum_glyphs: 'filled' }, analyze: true .... line one <1> line two @@ -2019,7 +2019,7 @@ describe 'Asciidoctor::PDF::Converter - List' do .... <1> First line <2> Last line - EOS + END one_text = pdf.find_text ?\u2776 two_text = pdf.find_text ?\u2777 @@ -2032,7 +2032,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow conum glyphs to be specified explicitly using numeric range' do - pdf = to_pdf <<~'EOS', pdf_theme: { conum_glyphs: '1-20' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { conum_glyphs: '1-20' }, analyze: true .... line one <1> line two @@ -2040,14 +2040,14 @@ describe 'Asciidoctor::PDF::Converter - List' do .... <1> First line <2> Last line - EOS + END one_text = pdf.find_text '1' (expect one_text).to have_size 2 end it 'should allow conum glyphs to be specified explicitly using unicode range' do - pdf = to_pdf <<~'EOS', pdf_theme: { conum_glyphs: '\u0031-\u0039' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { conum_glyphs: '\u0031-\u0039' }, analyze: true .... line one <1> line two @@ -2055,7 +2055,7 @@ describe 'Asciidoctor::PDF::Converter - List' do .... <1> First line <2> Last line - EOS + END one_text = pdf.find_text '1' (expect one_text).to have_size 2 @@ -2066,7 +2066,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow conum glyphs to be specified explicitly using multiple unicode ranges' do - pdf = to_pdf <<~'EOS', pdf_theme: { conum_glyphs: '\u2776-\u277a, \u2465-\u2468' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { conum_glyphs: '\u2776-\u277a, \u2465-\u2468' }, analyze: true ---- 1 <1> 2 <2> @@ -2087,7 +2087,7 @@ describe 'Asciidoctor::PDF::Converter - List' do <7> 7 <8> 8 <9> 9 - EOS + END conum_lines = pdf.lines.map {|l| l.delete ' 1-9' } (expect conum_lines).to have_size 18 @@ -2095,14 +2095,14 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow conum glyphs to be specified as single unicode character' do - pdf = to_pdf <<~'EOS', pdf_theme: { conum_glyphs: '\u2776' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { conum_glyphs: '\u2776' }, analyze: true .... the one and only line <1> no conum here <2> .... <1> That's all we have time for <2> This conum is not supported - EOS + END one_text = pdf.find_text ?\u2776 (expect one_text).to have_size 2 @@ -2116,7 +2116,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should keep list marker with primary text' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :pdf-page-size: 52mm x 72.25mm :pdf-page-margin: 0 @@ -2126,7 +2126,7 @@ describe 'Asciidoctor::PDF::Converter - List' do .... <1> description - EOS + END marker_text = (pdf.find_text ?\u2460)[-1] (expect marker_text[:page_number]).to be 2 @@ -2135,37 +2135,37 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should allow text alignment to be set using role', visual: true do - to_file = to_pdf_file <<~EOS, 'colist-text-align-left-role.pdf' + to_file = to_pdf_file <<~END, 'colist-text-align-left-role.pdf' ---- data <1> ---- [.text-left] <1> #{lorem_ipsum '2-sentences-1-paragraph'} - EOS + END (expect to_file).to visually_match 'colist-text-align-left.pdf' end it 'should allow text alignment to be set using theme', visual: true do - to_file = to_pdf_file <<~EOS, 'colist-text-align-left-theme.pdf', pdf_theme: { list_text_align: 'left' } + to_file = to_pdf_file <<~END, 'colist-text-align-left-theme.pdf', pdf_theme: { list_text_align: 'left' } ---- data <1> ---- <1> #{lorem_ipsum '2-sentences-1-paragraph'} - EOS + END (expect to_file).to visually_match 'colist-text-align-left.pdf' end end context 'Bibliography' do it 'should reference bibliography entry using ID in square brackets by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true The recommended reading includes <<bar>>. [bibliography] == Bibliography * [[[bar]]] Bar, Foo. All The Things. 2010. - EOS + END lines = pdf.lines @@ -2174,14 +2174,14 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should reference bibliography entry using custom reftext square brackets' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true The recommended reading includes <<bar>>. [bibliography] == Bibliography * [[[bar,1]]] Bar, Foo. All The Things. 2010. - EOS + END lines = pdf.lines (expect lines).to include 'The recommended reading includes [1].' @@ -2189,7 +2189,7 @@ describe 'Asciidoctor::PDF::Converter - List' do end it 'should create bidirectional links between first bibref reference and entry' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' The recommended reading includes <<bar>>. Did you read <<bar>>? @@ -2201,7 +2201,7 @@ describe 'Asciidoctor::PDF::Converter - List' do * [[[bar]]] Bar, Foo. All The Things. 2010. * [[[baz]]] Baz. The Rest of the Story. 2020. - EOS + END forward_refs = get_annotations pdf, 1 (expect forward_refs).to have_size 2 diff --git a/spec/listing_spec.rb b/spec/listing_spec.rb index 13de4b23..1d59b7e9 100644 --- a/spec/listing_spec.rb +++ b/spec/listing_spec.rb @@ -10,10 +10,10 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_width: 1, code_border_radius: 0, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line ---- ---- - EOS + END lines = pdf.lines (expect lines).to have_size 4 @@ -21,14 +21,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should wrap text consistently regardless of whether the characters contain diacritics' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :pdf-page-size: A5 .... aàbècìdòeùf gáhéiíjókúlým nâoêpîqôrûs tñuõvãw xäyëzïaöbücÿd aabbccddeef gghhiijjkkllm nnooppqqrrs ttuuvvw xxyyzzaabbccd .... - EOS + END text = pdf.text (expect text).to have_size 4 @@ -37,14 +37,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should move unbreakable block shorter than page to next page to avoid splitting it' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['paragraph'] * 20).join (?\n * 2)} [%unbreakable] ---- #{(['listing'] * 20).join ?\n} ---- - EOS + END listing_page_numbers = (pdf.find_text 'listing').map {|it| it[:page_number] }.uniq (expect listing_page_numbers).to eql [2] @@ -52,14 +52,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do it 'should not split block that has less lines than breakable_min_lines value' do pdf = with_content_spacer 10, 700 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { code_border_color: 'FF0000', code_breakable_min_lines: 3 }, analyze: :line + to_pdf <<~END, pdf_theme: { code_border_color: 'FF0000', code_breakable_min_lines: 3 }, analyze: :line image::#{spacer_path}[] ---- not breakable ---- - EOS + END end lines = pdf.lines.select {|it| it[:color] == 'FF0000' } @@ -72,7 +72,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_color: 'FF0000', } pdf = with_content_spacer 10, 700 do |spacer_path| - input = <<~EOS + input = <<~END image::#{spacer_path}[] ---- @@ -82,7 +82,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do not break ---- - EOS + END (expect ((to_pdf input, analyze: true).find_unique_text 'this')[:page_number]).to eql 1 pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -95,14 +95,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should keep anchor together with block when block is moved to next page' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END #{(['paragraph'] * 20).join (?\n * 2)} [#listing-1%unbreakable] ---- #{(['listing'] * 20).join ?\n} ---- - EOS + END (expect (pdf.page 1).text).not_to include 'listing' (expect (pdf.page 2).text).to include 'listing' @@ -112,14 +112,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should place anchor directly at top of block' do - input = <<~'EOS' + input = <<~'END' paragraph [#listing-1] ---- listing ---- - EOS + END lines = (to_pdf input, analyze: :line).lines pdf = to_pdf input @@ -129,14 +129,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should offset anchor from top of block by value of block_anchor_top' do - input = <<~'EOS' + input = <<~'END' paragraph [#listing-1] ---- listing ---- - EOS + END pdf_theme = { block_anchor_top: -12 } @@ -148,14 +148,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should place anchor at top of block if advanced to next page' do - input = <<~EOS + input = <<~END paragraph [#listing-1%unbreakable] ---- #{(['filler'] * 25).join %(\n\n)} ---- - EOS + END lines = (to_pdf input, analyze: :line).lines pdf = to_pdf input @@ -165,13 +165,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should split block if it cannot fit on a whole page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['paragraph'] * 20).join (?\n * 2)} ---- #{(['listing'] * 60).join ?\n} ---- - EOS + END (expect pdf.pages).to have_size 2 listing_texts = pdf.find_text 'listing' @@ -180,7 +180,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should use dashed border to indicate where block is split across a page boundary', visual: true do - to_file = to_pdf_file <<~EOS, 'listing-page-split.pdf' + to_file = to_pdf_file <<~END, 'listing-page-split.pdf' ---- #{(['listing'] * 60).join ?\n} ---- @@ -188,7 +188,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do ---- #{(['more listing'] * 2).join ?\n} ---- - EOS + END (expect to_file).to visually_match 'listing-page-split.pdf' end @@ -201,14 +201,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_radius: 0, } pdf = with_content_spacer 10, 695 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] ---- $ gem install asciidoctor-pdf $ asciidoctor-pdf doc.adoc ---- - EOS + END end pages = pdf.pages @@ -219,14 +219,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do (expect last_text_y - pdf_theme[:code_padding]).to be > 48.24 pdf = with_content_spacer 10, 696 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] ---- $ gem install asciidoctor-pdf $ asciidoctor-pdf doc.adoc ---- - EOS + END end pages = pdf.pages @@ -249,7 +249,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do sidebar_border_color: '0000EE', sidebar_background_color: 'transparent', } - input = <<~EOS + input = <<~END **** before @@ -261,7 +261,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do after **** - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true (expect pdf.find_text %r/^ooo/).to have_size 3 @@ -275,48 +275,48 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should resize font to prevent wrapping if autofit option is set' do - pdf = to_pdf <<~'EOS', pdf_theme: { code_font_size: 12 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { code_font_size: 12 }, analyze: true [%autofit] ---- @themesdir = ::File.expand_path theme.__dir__ || (doc.attr 'pdf-themesdir') || ::Dir.pwd ---- - EOS + END (expect pdf.text).to have_size 1 (expect pdf.text[0][:font_size]).to be < 12 end it 'should not resize font if not necessary' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%autofit] ---- puts 'Hello, World!' ---- - EOS + END (expect pdf.text).to have_size 1 (expect pdf.text[0][:font_size]).to eql 11 end it 'should not resize font more than base minimum font size' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_font_size_min: 8 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_font_size_min: 8 }, analyze: true [%autofit] ---- play_symbol = (node.document.attr? 'icons', 'font') ? %(<font name="fas">#{(icon_font_data 'fas').unicode 'play'}</font>) : RightPointer ---- - EOS + END (expect pdf.text).to have_size 2 (expect pdf.text[0][:font_size]).to be 8 end it 'should not resize font more than code minimum font size' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_font_size_min: 0, code_font_size_min: 8 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_font_size_min: 0, code_font_size_min: 8 }, analyze: true [%autofit] ---- play_symbol = (node.document.attr? 'icons', 'font') ? %(<font name="fas">#{(icon_font_data 'fas').unicode 'play'}</font>) : RightPointer ---- - EOS + END (expect pdf.text).to have_size 2 (expect pdf.text[0][:font_size]).to be 8 @@ -324,14 +324,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do it 'should allow autofit to shrink text as much as it needs if the minimum font size is 0 or nil' do [0, nil].each do |size| - pdf = to_pdf <<~'EOS', pdf_theme: { base_font_size_min: size }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_font_size_min: size }, analyze: true [%autofit] ---- +--------------------------------------+----------------------------------------------------+-----------------------------------------------------+ | id | name | subnets | +--------------------------------------+----------------------------------------------------+-----------------------------------------------------+ ---- - EOS + END expected_line = '+--------------------------------------+----------------------------------------------------+-----------------------------------------------------+' lines = pdf.lines @@ -342,13 +342,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should use base font color if font color is not specified' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_font_color: 'AA0000', code_font_color: nil }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_font_color: 'AA0000', code_font_color: nil }, analyze: true before ---- in the mix ---- - EOS + END before_text = pdf.find_unique_text 'before' (expect before_text[:font_color]).to eql 'AA0000' @@ -364,13 +364,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_background_color: nil, } - input = <<~EOS + input = <<~END [%autofit] ---- downloading#{(%w(.) * 100).join} done ---- - EOS + END text = (to_pdf input, pdf_theme: pdf_theme, analyze: true).text lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -386,31 +386,31 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should guard indentation using no-break space character' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true ---- flush indented flush ---- - EOS + END (expect pdf.lines).to eql ['flush', %(\u00a0 indented), 'flush'] end it 'should guard indentation using no-break space character if string starts with indented line' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true ---- indented flush indented ---- - EOS + END (expect pdf.lines).to eql [%(\u00a0 indented), 'flush', %(\u00a0 indented)] end it 'should expand tabs if tabsize attribute is not specified' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true ---- flush lead space @@ -420,7 +420,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do flush\t\t\tcolumn tab ---- - EOS + END expected_lines = [ 'flush', @@ -439,7 +439,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should expand tabs if tabsize is specified as block attribute' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true [tabsize=4] ---- flush @@ -450,7 +450,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do flush\t\t\tcolumn tab ---- - EOS + END expected_lines = [ 'flush', @@ -469,7 +469,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should expand tabs if tabsize is specified as document attribute' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :tabsize: 4 ---- @@ -481,7 +481,7 @@ describe 'Asciidoctor::PDF::Converter - Listing' do flush\t\t\tcolumn tab ---- - EOS + END expected_lines = [ 'flush', @@ -500,14 +500,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should add numbered label to block title if listing-caption attribute is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :listing-caption: Listing .Title ---- content ---- - EOS + END title_text = pdf.find_unique_text font_name: 'NotoSerif-Italic' (expect title_text[:string]).to eql 'Listing 1. Title' @@ -519,12 +519,12 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_caption_font_style: 'bold', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Title ---- content ---- - EOS + END title_text = (pdf.find_text 'Title')[0] (expect title_text[:font_color]).to eql '0000FF' @@ -541,12 +541,12 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_radius: 0, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Caption with background color ---- content ---- - EOS + END title_text = pdf.find_unique_text 'Caption with background color' (expect title_text[:font_color]).to eql 'FFFFFF' @@ -567,14 +567,14 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_radius: 0, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true before .Caption with background color ---- content ---- - EOS + END title_text = pdf.find_unique_text 'Caption with background color' (expect title_text[:font_color]).to eql 'FFFFFF' @@ -594,12 +594,12 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_caption_margin_outside: 10, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Caption with background color that spans multiple lines because of the text transform ---- content ---- - EOS + END title_text = pdf.find_unique_text %r/^CAPTION WITH BACKGROUND COLOR/ (expect title_text[:font_color]).to eql 'FFFFFF' @@ -618,12 +618,12 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_caption_margin_outside: 10, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Caption with background color that contains _inline formatting_ but does not wrap ---- content ---- - EOS + END title_text = pdf.find_unique_text %r/^Caption with background color/ (expect title_text[:font_color]).to eql 'FFFFFF' @@ -638,12 +638,12 @@ describe 'Asciidoctor::PDF::Converter - Listing' do it 'should allow theme to place caption below block' do pdf_theme = { code_caption_end: 'bottom' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Look out below! ---- code ---- - EOS + END content_text = pdf.find_unique_text 'code' title_text = pdf.find_unique_text 'Look out below!' @@ -651,13 +651,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should apply inline formatting if quotes subs is enabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [subs=+quotes] ---- _1_ skipped *99* passing ---- - EOS + END italic_text = (pdf.find_text '1')[0] (expect italic_text[:font_name]).to eql 'mplus1mn-italic' @@ -666,13 +666,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should honor font family set on conum category in theme for conum in listing block' do - pdf = to_pdf <<~'EOS', pdf_theme: { code_font_family: 'Courier' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { code_font_family: 'Courier' }, analyze: true ---- fe <1> fi <2> fo <3> ---- - EOS + END lines = pdf.lines (expect lines[0]).to end_with ' ①' @@ -684,12 +684,12 @@ describe 'Asciidoctor::PDF::Converter - Listing' do it 'should allow theme to set conum color using CMYK value' do cmyk_color = [0, 100, 100, 60].extend Asciidoctor::PDF::ThemeLoader::CMYKColorValue - pdf = to_pdf <<~'EOS', pdf_theme: { conum_font_color: cmyk_color }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { conum_font_color: cmyk_color }, analyze: true ---- foo <1> ---- <1> the counterpart of bar - EOS + END conum_texts = pdf.find_text '①' (expect conum_texts).to have_size 2 @@ -703,13 +703,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_color: 'AA0000', code_border_width: [1, nil], } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line ---- foo bar baz ---- - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -722,13 +722,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_color: 'AA0000', code_border_width: [nil, 1], } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line ---- foo bar baz ---- - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -741,13 +741,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_color: 'AA0000', code_border_width: [2, 1], } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line ---- foo bar baz ---- - EOS + END lines = pdf.lines (expect lines).to have_size 4 @@ -762,13 +762,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_color: 'AA0000', code_border_width: [1, 0, 0, 0], } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line ---- foo bar baz ---- - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -781,13 +781,13 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_color: 'AA0000', code_border_width: [0.5, 0], } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line ---- foo bar baz ---- - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -803,11 +803,11 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_width: [1, 0], } - to_file = to_pdf_file <<~EOS, 'listing-page-split-border-ends.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'listing-page-split-border-ends.pdf', pdf_theme: pdf_theme ---- #{(['listing'] * 60).join ?\n} ---- - EOS + END (expect to_file).to visually_match 'listing-page-split-border-ends.pdf' end @@ -819,11 +819,11 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_background_color: nil, } - input = <<~EOS + input = <<~END ---- downloading#{(%w(.) * 100).join}done ---- - EOS + END text = (to_pdf input, pdf_theme: pdf_theme, analyze: true).text lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -843,11 +843,11 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_background_color: nil, } - input = <<~EOS + input = <<~END ---- source code here ---- - EOS + END text = (to_pdf input, pdf_theme: pdf_theme, analyze: true).text lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -868,11 +868,11 @@ describe 'Asciidoctor::PDF::Converter - Listing' do code_border_width: [1, 0], } - input = <<~EOS + input = <<~END ---- source code here ---- - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines text = (to_pdf input, pdf_theme: pdf_theme, analyze: true).text @@ -884,12 +884,12 @@ describe 'Asciidoctor::PDF::Converter - Listing' do end it 'should not substitute conums if callouts sub is absent' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [subs=-callouts] ---- not a conum <1> ---- - EOS + END (expect pdf.lines).to include 'not a conum <1>' (expect pdf.find_text '①').to be_empty diff --git a/spec/manpage_spec.rb b/spec/manpage_spec.rb index 3e449852..6510e762 100644 --- a/spec/manpage_spec.rb +++ b/spec/manpage_spec.rb @@ -4,7 +4,7 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Manpage' do it 'should generate name section automatically' do - pdf = to_pdf <<~'EOS', doctype: :manpage, analyze: true + pdf = to_pdf <<~'END', doctype: :manpage, analyze: true = cmd(1) Author Name v1.0.0 @@ -22,7 +22,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do == Options *-v*:: Prints the version. - EOS + END expected_name_title = 'Name' name_title_text = (pdf.find_text expected_name_title)[0] @@ -35,7 +35,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do end it 'should apply normal substitutions to manname section' do - pdf = to_pdf <<~'EOS', doctype: :manpage, analyze: true + pdf = to_pdf <<~'END', doctype: :manpage, analyze: true = cmd(1) == Name @@ -45,7 +45,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do == Synopsis *cmd* [_OPTION_]... _FILE_... - EOS + END lots_text = (pdf.find_text 'lots')[0] (expect lots_text).not_to be_nil @@ -53,7 +53,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do end it 'should uppercase title of auto-generated name section if other sections are uppercase' do - pdf = to_pdf <<~'EOS', doctype: :manpage, analyze: true + pdf = to_pdf <<~'END', doctype: :manpage, analyze: true = cmd(1) Author Name v1.0.0 @@ -69,7 +69,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do == OPTIONS *-v*:: Prints the version. - EOS + END name_title_text = pdf.find_unique_text 'NAME' (expect name_title_text).not_to be_nil @@ -78,7 +78,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do end it 'should not uppercase title of auto-generated name section if no other sections are found' do - pdf = to_pdf <<~'EOS', doctype: :manpage, analyze: true + pdf = to_pdf <<~'END', doctype: :manpage, analyze: true = cmd(1) Author Name v1.0.0 @@ -86,7 +86,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do :mansource: CMD :manname: cmd :manpurpose: does stuff - EOS + END name_title_text = pdf.find_unique_text 'Name' (expect name_title_text).not_to be_nil @@ -95,7 +95,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do end it 'should arrange body of manpage into columns if specified in theme' do - pdf = to_pdf <<~'EOS', doctype: :manpage, pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', doctype: :manpage, pdf_theme: { page_columns: 2 }, analyze: true = cmd(1) == Name @@ -112,7 +112,7 @@ describe 'Asciidoctor::PDF::Converter - Manpage' do == Options *-v*:: Prints the version. - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 name_text = pdf.find_unique_text 'Name' diff --git a/spec/media_spec.rb b/spec/media_spec.rb index ccc9fff8..45dbcb25 100644 --- a/spec/media_spec.rb +++ b/spec/media_spec.rb @@ -25,14 +25,14 @@ describe 'Asciidoctor::PDF::Converter - media' do end it 'should leave blank page after image cover page' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :doctype: book :media: prepress :front-cover-image: #{fixture_file 'cover.jpg', relative: true} == Chapter Title - EOS + END (expect pdf.pages).to have_size 5 (expect (pdf.page 3).text).to eql 'Document Title' @@ -43,14 +43,14 @@ describe 'Asciidoctor::PDF::Converter - media' do end it 'should leave blank page after PDF cover page' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :doctype: book :media: prepress :front-cover-image: #{fixture_file 'blue-letter.pdf', relative: true} == Chapter Title - EOS + END (expect pdf.pages).to have_size 5 (expect (pdf.page 1).text).to be_empty @@ -62,7 +62,7 @@ describe 'Asciidoctor::PDF::Converter - media' do end it 'should insert blank page after TOC' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :doctype: book :media: prepress @@ -74,7 +74,7 @@ describe 'Asciidoctor::PDF::Converter - media' do == Middle == End - EOS + END (expect pdf.pages).to have_size 11 (expect (pdf.find_text 'Document Title')[0][:page_number]).to be 3 @@ -88,7 +88,7 @@ describe 'Asciidoctor::PDF::Converter - media' do end it 'should not insert blank page at start of document if document has no cover' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :media: prepress @@ -98,7 +98,7 @@ describe 'Asciidoctor::PDF::Converter - media' do == Chapter Title Chapter content. - EOS + END (expect pdf.pages).to have_size 5 doctitle_text = (pdf.find_text 'Document Title')[0] @@ -110,7 +110,7 @@ describe 'Asciidoctor::PDF::Converter - media' do end it 'should not insert blank page at start of document with toc if title page is disabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :media: prepress @@ -120,7 +120,7 @@ describe 'Asciidoctor::PDF::Converter - media' do == Chapter Title Chapter content. - EOS + END (expect pdf.pages).to have_size 3 toc_text = (pdf.find_text 'Table of Contents')[0] @@ -132,7 +132,7 @@ describe 'Asciidoctor::PDF::Converter - media' do end it 'should not insert blank page before chapter that follows preamble if chapter has nonfacing option' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :media: prepress @@ -141,21 +141,21 @@ describe 'Asciidoctor::PDF::Converter - media' do [%nonfacing] == Chapter - EOS + END chapter_text = (pdf.find_text 'Chapter')[0] (expect chapter_text[:page_number]).to be 4 end it 'should not insert blank page before chapter that follows document title if chapter has nonfacing option' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :media: prepress [%nonfacing] == Chapter - EOS + END chapter_text = (pdf.find_text 'Chapter')[0] (expect chapter_text[:page_number]).to be 2 diff --git a/spec/open_spec.rb b/spec/open_spec.rb index 5003af96..dfa65f7a 100644 --- a/spec/open_spec.rb +++ b/spec/open_spec.rb @@ -5,7 +5,7 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Open' do it 'should be breakable by default' do with_content_spacer 10, 720 do |spacer_path| - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true image::#{spacer_path}[] -- @@ -13,7 +13,7 @@ describe 'Asciidoctor::PDF::Converter - Open' do second page -- - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.find_unique_text 'first page')[:page_number]).to be 1 (expect (pdf.find_unique_text 'second page')[:page_number]).to be 2 @@ -21,7 +21,7 @@ describe 'Asciidoctor::PDF::Converter - Open' do end it 'should keep block together when it has the unbreakable option', visual: true do - to_file = to_pdf_file <<~EOS, 'open-unbreakable-option-fit.pdf' + to_file = to_pdf_file <<~END, 'open-unbreakable-option-fit.pdf' Make it rain.footnote:[money] #{(['filler'] * 21).join %(\n\n)} @@ -40,13 +40,13 @@ describe 'Asciidoctor::PDF::Converter - Open' do -- Make it snow.footnote:[dollar bills] - EOS + END (expect to_file).to visually_match 'open-unbreakable-option-fit.pdf' end it 'should break an unbreakable block if it does not fit on one page', visual: true do - to_file = to_pdf_file <<~EOS, 'open-unbreakable-option-break.pdf' + to_file = to_pdf_file <<~END, 'open-unbreakable-option-break.pdf' Make it rain.footnote:[money] #{(['filler'] * 21).join %(\n\n)} @@ -67,18 +67,18 @@ describe 'Asciidoctor::PDF::Converter - Open' do -- Make it snow.footnote:[dollar bills] - EOS + END (expect to_file).to visually_match 'open-unbreakable-option-break.pdf' end it 'should include title if specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true .Title -- content -- - EOS + END title_texts = pdf.find_text 'Title' (expect title_texts).to have_size 1 @@ -89,7 +89,7 @@ describe 'Asciidoctor::PDF::Converter - Open' do it 'should keep title with content if content is advanced to new page' do pdf = with_content_spacer 10, 700 do |spacer_path| - to_pdf <<~EOS, analyze: true + to_pdf <<~END, analyze: true image::#{spacer_path}[] .Title @@ -99,7 +99,7 @@ describe 'Asciidoctor::PDF::Converter - Open' do more content -- - EOS + END end (expect pdf.pages).to have_size 2 (expect (pdf.find_unique_text 'content')[:page_number]).to be 2 @@ -134,7 +134,7 @@ describe 'Asciidoctor::PDF::Converter - Open' do %(before\n\n[#idname]) => true, %(before\n\n[%unbreakable]) => true, }.each do |before_block, dry_run| - input = <<~EOS.lstrip + input = <<~END.lstrip #{before_block} -- #{['block content'] * 4 * %(\n\n)} @@ -142,7 +142,7 @@ describe 'Asciidoctor::PDF::Converter - Open' do [spy] block content -- - EOS + END pdf = to_pdf input, extensions: extensions, analyze: true (expect pdf.pages).to have_size 1 (expect (pdf.find_text 'block content')[0][:page_number]).to be 1 diff --git a/spec/optimizer_spec.rb b/spec/optimizer_spec.rb index 734ddc65..2761ada0 100644 --- a/spec/optimizer_spec.rb +++ b/spec/optimizer_spec.rb @@ -56,7 +56,7 @@ describe 'Asciidoctor::PDF::Optimizer', if: (RSpec::ExampleGroupHelpers.gem_avai it 'should use existing pdfmark file if present when optimizing' do input_file = Pathname.new example_file 'basic-example.adoc' pdfmark_file = Pathname.new output_file 'optimizer-pdfmark.pdfmark' - pdfmark_file.write <<~'EOS' + pdfmark_file.write <<~'END' [ /Title (All Your PDF Are Belong To Us) /Author (CATS) /Subject (Zero Wing) @@ -64,7 +64,7 @@ describe 'Asciidoctor::PDF::Optimizer', if: (RSpec::ExampleGroupHelpers.gem_avai /CreationDate (D:19920101000000-00'00') /Creator (Genesis) /DOCINFO pdfmark - EOS + END to_file = to_pdf_file input_file, 'optimizer-pdfmark.pdf', attribute_overrides: { 'optimize' => '' } pdf = PDF::Reader.new to_file pdf_info = pdf.info diff --git a/spec/outline_spec.rb b/spec/outline_spec.rb index db529ce5..ace1107c 100644 --- a/spec/outline_spec.rb +++ b/spec/outline_spec.rb @@ -5,33 +5,33 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Outline' do context 'General' do it 'should set /PageMode /UseOutlines in PDF catalog to enable outline hierarchy' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title == First == Last - EOS + END (expect pdf.catalog[:PageMode]).to eql :UseOutlines end it 'should set /NonFullScreenPageMode /UseOutlines in PDF catalog if fullscreen mode is enabled' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :pdf-page-mode: fullscreen == First == Last - EOS + END (expect pdf.catalog[:PageMode]).not_to eql :UseOutlines (expect pdf.catalog[:NonFullScreenPageMode]).to eql :UseOutlines end it 'should not create outline if the outline document attribute is unset in document' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :!outline: @@ -43,14 +43,14 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Middle Chapter == Last Chapter - EOS + END outline = extract_outline pdf (expect outline).to be_empty end it 'should not create outline if the outline document attribute is unset via API' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'outline' => nil } + pdf = to_pdf <<~'END', attribute_overrides: { 'outline' => nil } = Document Title :doctype: book @@ -61,14 +61,14 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Middle Chapter == Last Chapter - EOS + END outline = extract_outline pdf (expect outline).to be_empty end it 'should create an outline to navigate the document structure' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book @@ -79,7 +79,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Middle Chapter == Last Chapter - EOS + END outline = extract_outline pdf (expect outline).to have_size 4 @@ -112,10 +112,10 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should generate outline for book that only consists of doctitle' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book - EOS + END outline = extract_outline pdf (expect outline).to have_size 1 @@ -126,10 +126,10 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should not generate outline for book that only consists of front cover' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :front-cover-image: image:cover.jpg[] :doctype: book - EOS + END (expect pdf.pages).to have_size 1 outline = extract_outline pdf @@ -137,9 +137,9 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should generate outline for article that only consists of doctitle' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title - EOS + END outline = extract_outline pdf (expect outline).to have_size 1 @@ -150,9 +150,9 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should not generate outline for article that only consists of front cover' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :front-cover-image: image:cover.jpg[] - EOS + END (expect pdf.pages).to have_size 1 outline = extract_outline pdf @@ -162,7 +162,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do context 'Depth' do it 'should limit outline depth according to value of toclevels attribute' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toclevels: 1 @@ -174,7 +174,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Middle Chapter == Last Chapter - EOS + END outline = extract_outline pdf (expect outline).to have_size 4 @@ -183,7 +183,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should allow outline depth to exceed toclevels if outlinelevels attribute is set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toclevels: 1 @@ -198,7 +198,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Middle Chapter == Last Chapter - EOS + END outline = extract_outline pdf (expect outline).to have_size 4 @@ -210,7 +210,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should limit outline depth if value of outlinelevels attribute is less than value of toclevels attribute' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toclevels: 2 @@ -225,7 +225,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Middle Chapter == Last Chapter - EOS + END outline = extract_outline pdf (expect outline).to have_size 4 @@ -234,7 +234,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should limit outline depth per section if value of outlinelevels attribute is specified on section' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book @@ -248,7 +248,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Middle Chapter == Last Chapter - EOS + END outline = extract_outline pdf (expect outline).to have_size 4 @@ -262,7 +262,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should not include parts in outline if outlinelevels is less than 0' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :outlinelevels: -1 @@ -274,7 +274,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do = Part B == Chapter B - EOS + END outline = extract_outline pdf (expect outline).to have_size 1 @@ -283,7 +283,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should not include chapters in outline if outlinelevels is 0' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :outlinelevels: 0 @@ -295,7 +295,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Chapter B === Topic B - EOS + END outline = extract_outline pdf (expect outline).to have_size 1 @@ -304,7 +304,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should use second argument of outlinelevels attribute to control depth at which outline is expanded' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :outlinelevels: 3:1 @@ -318,7 +318,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Another Chapter === Another Section - EOS + END outline = extract_outline pdf (expect outline).to have_size 3 @@ -335,7 +335,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should expand outline based on depth not level' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :outlinelevels: 3:1 @@ -345,7 +345,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Chapter === Section - EOS + END outline = extract_outline pdf (expect outline).to have_size 2 @@ -359,7 +359,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should use default toclevels for outline level if only expand levels is specified' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :outlinelevels: :1 @@ -371,7 +371,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do === Section ==== Subsection - EOS + END outline = extract_outline pdf (expect outline).to have_size 2 @@ -388,7 +388,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should use value of toclevels for outline level if only expand levels is specified' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toclevels: 3 @@ -401,7 +401,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do === Section ==== Subsection - EOS + END outline = extract_outline pdf (expect outline).to have_size 2 @@ -421,7 +421,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do context 'Doctitle' do it 'should include doctitle in outline for book even if notitle attribute is set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Book Title :doctype: book :notitle: @@ -429,7 +429,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Foo == Bar - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[0].text).to eql 'Foo' @@ -443,14 +443,14 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should include doctitle in outline for article when title-page attribute is set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Article Title :title-page: == Foo == Bar - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[0].text).to eql 'Article Title' @@ -466,13 +466,13 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should include doctitle in outline for article' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Article Title == Foo == Bar - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0].text).to include 'Article Title' @@ -488,14 +488,14 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should include doctitle in outline for article even if notitle attribute is set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Article Title :notitle: == Foo == Bar - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0].text).not_to include 'Article Title' @@ -511,14 +511,14 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should not include doctitle in outline if outline-title is unset' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Article Title :outline-title!: == Foo == Bar - EOS + END (expect pdf.pages).to have_size 1 outline = extract_outline pdf @@ -529,14 +529,14 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should allow title for document in outline to be customized using outline-title attribute' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Article Title :outline-title: Outline == Foo == Bar - EOS + END (expect pdf.pages).to have_size 1 outline = extract_outline pdf @@ -550,12 +550,12 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should link doctitle dest to second page of article with front cover' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :front-cover-image: #{fixture_file 'cover.jpg', relative: true} content page - EOS + END (expect pdf.pages).to have_size 2 outline = extract_outline pdf @@ -567,13 +567,13 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should link doctitle dest to second page of book with front cover' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :doctype: book :front-cover-image: #{fixture_file 'cover.jpg', relative: true} content page - EOS + END (expect pdf.pages).to have_size 3 outline = extract_outline pdf @@ -605,11 +605,11 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should set doctitle in outline to value of untitled-label attribute if document has no doctitle and has sections' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' == First Section == Last Section - EOS + END outline = extract_outline pdf (expect outline).to have_size 3 @@ -618,13 +618,13 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should not put doctitle in outline if document has no doctitle, has sections, and untitled-label attribute is unset' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :untitled-label!: == First Section == Last Section - EOS + END outline = extract_outline pdf (expect outline).to have_size 2 @@ -633,11 +633,11 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should not crash if doctitle is not set and untitled-label attribute is unset and document has no sections' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :untitled-label!: body only - EOS + END (expect extract_outline pdf).to be_empty end @@ -645,7 +645,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do context 'notitle section' do it 'should add entry for visible section with notitle option' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title == Section Present @@ -656,7 +656,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Title for Outline content - EOS + END outline = extract_outline pdf (expect outline[-1][:title]).to eql 'Title for Outline' @@ -664,7 +664,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should not add entry for section with no blocks' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title == Section Present @@ -673,14 +673,14 @@ describe 'Asciidoctor::PDF::Converter - Outline' do [%notitle] == Section Not Present - EOS + END outline = extract_outline pdf (expect outline[-1][:title]).to eql 'Section Present' end it 'should not add entry for section on page which has been deleted' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title == Section Present @@ -691,14 +691,14 @@ describe 'Asciidoctor::PDF::Converter - Outline' do [%notitle] == Section Not Present - EOS + END outline = extract_outline pdf (expect outline[-1][:title]).to eql 'Section Present' end it 'should not add entry for section with empty title' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :outlinelevels: 3 @@ -709,7 +709,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do === {empty} ==== Grandchild Section - EOS + END outline = extract_outline pdf (expect outline[-1][:title]).to eql 'Section' @@ -719,7 +719,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do context 'Labels' do it 'should label front matter pages using roman numerals' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Book Title :doctype: book :toc: @@ -727,13 +727,13 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Chapter 1 == Chapter 2 - EOS + END (expect get_page_labels pdf).to eql %w(i ii 1 2) end it 'should label title page using roman numeral ii if cover page is present' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Book Title :doctype: book :toc: @@ -742,7 +742,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do == Chapter 1 == Chapter 2 - EOS + END (expect get_page_labels pdf).to eql %w(i ii iii 1 2) outline = extract_outline pdf @@ -751,13 +751,13 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should label first page starting with 1 if no front matter is present' do - pdf = to_pdf <<~'EOS', doctype: :book + pdf = to_pdf <<~'END', doctype: :book no front matter <<< more content - EOS + END (expect get_page_labels pdf).to eql %w(1 2) end @@ -765,12 +765,12 @@ describe 'Asciidoctor::PDF::Converter - Outline' do context 'Sanitizer' do it 'should sanitize titles' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = _Document_ *Title* :doctype: book == _First_ *Chapter* - EOS + END outline = extract_outline pdf (expect outline).to have_size 2 @@ -779,12 +779,12 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should decode character references in entries' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = ACME(TM) Catalog <№ 1> :doctype: book == Paper Clips € 4 - EOS + END outline = extract_outline pdf (expect outline).to have_size 2 @@ -793,12 +793,12 @@ describe 'Asciidoctor::PDF::Converter - Outline' do end it 'should sanitize value of custom outline title' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Article Title :outline-title: Outline <№ 1> == Section - EOS + END (expect pdf.pages).to have_size 1 outline = extract_outline pdf diff --git a/spec/page_spec.rb b/spec/page_spec.rb index dc1c4d91..4a7f89ea 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -5,50 +5,50 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Page' do context 'Size' do it 'should set page size specified by theme by default' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size]).to eql PDF::Core::PageGeometry::SIZES['A4'] end it 'should set page size specified by page_size key in theme with predefined name' do ['LEGAL', 'legal', :LEGAL, :legal].each do |page_size| - pdf = to_pdf <<~'EOS', pdf_theme: { page_size: page_size }, analyze: :page + pdf = to_pdf <<~'END', pdf_theme: { page_size: page_size }, analyze: :page content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['LEGAL'] end end it 'should set page size specified by pdf-page-size attribute using predefined name' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page :pdf-page-size: Letter content - EOS + END (expect pdf.pages).to have_size 1 # NOTE: pdf-core 0.8 coerces whole number floats to integers (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['LETTER'] end it 'should ignore pdf-page-size attribute if value is unrecognized name' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page :pdf-page-size: Huge content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size]).to eql PDF::Core::PageGeometry::SIZES['A4'] end it 'should set page size specified by pdf-page-size attribute using dimension array in points' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page :pdf-page-size: [600, 800] content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size].map(&:to_f)).to eql [600.0, 800.0] end @@ -97,38 +97,38 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should use default page size if one of dimensions in page size array is 0' do [[800, 0], ['8.5in', '0in']].each do |page_size| - pdf = to_pdf <<~'EOS', pdf_theme: { page_size: page_size }, analyze: :page + pdf = to_pdf <<~'END', pdf_theme: { page_size: page_size }, analyze: :page content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['A4'] end end it 'should set page size specified by pdf-page-size attribute using dimension array in inches' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page :pdf-page-size: [8.5in, 11in] content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['LETTER'] end it 'should set page size specified by pdf-page-size attribute using dimension string in inches' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page :pdf-page-size: 8.5in x 11in content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['LETTER'] end it 'should set page size specified by page_size theme key using dimension array in inches' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_size: ['8.5in', '11in'] }, analyze: :page + pdf = to_pdf <<~'END', pdf_theme: { page_size: ['8.5in', '11in'] }, analyze: :page content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:size].map(&:to_f)).to eql PDF::Core::PageGeometry::SIZES['LETTER'] end @@ -136,19 +136,19 @@ describe 'Asciidoctor::PDF::Converter - Page' do context 'Layout' do it 'should use layout specified in theme by default' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0].orientation).to eql 'portrait' end it 'should use layout specified by pdf-page-layout attribute' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :pdf-page-layout: landscape content - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0].orientation).to eql 'landscape' end @@ -323,22 +323,22 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should use the margin specified by the pdf-page-margin attribute as array' do ['0.5in, 1in, 0.5in, 1in', '36pt, 72pt, 36pt, 72pt'].each do |val| - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :pdf-page-margin: [#{val}] content - EOS + END (expect pdf.text[0].values_at :string, :page_number, :x, :y).to eql ['content', 1, 72.0, 793.926] end end it 'should use the margin specified by the pdf-page-margin attribute as string' do %w(1in 72pt 25.4mm 2.54cm 96px).each do |val| - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :pdf-page-margin: #{val} content - EOS + END (expect pdf.text[0].values_at :string, :page_number, :x, :y).to eql ['content', 1, 72.0, 757.926] end end @@ -364,7 +364,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do page_margin: [18, 36, 36, 36], page_margin_rotated: [18, 18, 36, 18], } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true first page [page-layout=landscape] @@ -376,7 +376,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< last page - EOS + END (expect pdf.pages).to have_size 3 first_page_text = pdf.find_unique_text 'first page' @@ -388,7 +388,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should allow margins of rotated page to be configured independently using AsciiDoc attribute' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true :pdf-page-layout: landscape :pdf-page-margin: [18, 18, 36, 18] // NOTE: verify margin is expanded @@ -405,7 +405,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< last page - EOS + END (expect pdf.pages).to have_size 3 first_page_text = pdf.find_unique_text 'first page' @@ -417,7 +417,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should use same margin for all pages if rotated page margin is not specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :pdf-page-margin: [18, 36, 36, 36] first page @@ -431,7 +431,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< last page - EOS + END (expect pdf.pages).to have_size 3 first_page_text = pdf.find_unique_text 'first page' @@ -443,7 +443,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should use recto/verso margins when media=prepress', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-prepress-margins.pdf', enable_footer: true + to_file = to_pdf_file <<~'END', 'page-prepress-margins.pdf', enable_footer: true = Book Title :media: prepress :pdf-theme: default @@ -462,7 +462,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< === B Section - EOS + END (expect to_file).to visually_match 'page-prepress-margins.pdf' end @@ -472,7 +472,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do page_margin_inner: 72, page_margin_outer: 54, } - to_file = to_pdf_file <<~'EOS', 'page-prepress-custom-margins.pdf', pdf_theme: pdf_theme, enable_footer: true + to_file = to_pdf_file <<~'END', 'page-prepress-custom-margins.pdf', pdf_theme: pdf_theme, enable_footer: true = Book Title :media: prepress :doctype: book @@ -489,7 +489,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< === B Section - EOS + END (expect to_file).to visually_match 'page-prepress-custom-margins.pdf' end @@ -499,7 +499,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do page_margin_inner: nil, page_margin_outer: nil, } - to_file = to_pdf_file <<~'EOS', 'page-prepress-normal-margins.pdf', pdf_theme: pdf_theme, enable_footer: true + to_file = to_pdf_file <<~'END', 'page-prepress-normal-margins.pdf', pdf_theme: pdf_theme, enable_footer: true = Book Title :media: prepress :doctype: book @@ -516,7 +516,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< === B Section - EOS + END (expect to_file).to visually_match 'page-prepress-normal-margins.pdf' end @@ -526,7 +526,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do page_margin_inner: 72, page_margin_outer: 54, } - to_file = to_pdf_file <<~'EOS', 'page-prepress-margins-no-cover.pdf', pdf_theme: pdf_theme, enable_footer: true + to_file = to_pdf_file <<~'END', 'page-prepress-margins-no-cover.pdf', pdf_theme: pdf_theme, enable_footer: true = Book Title :media: prepress :doctype: book @@ -542,7 +542,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< === B Section - EOS + END (expect to_file).to visually_match 'page-prepress-margins-no-cover.pdf' end @@ -552,7 +552,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do page_margin_inner: 72, page_margin_outer: 54, } - to_file = to_pdf_file <<~'EOS', 'page-prepress-margins-body-only.pdf', pdf_theme: pdf_theme, enable_footer: true + to_file = to_pdf_file <<~'END', 'page-prepress-margins-body-only.pdf', pdf_theme: pdf_theme, enable_footer: true :media: prepress :doctype: book @@ -567,7 +567,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< === B Section - EOS + END (expect to_file).to visually_match 'page-prepress-margins-body-only.pdf' end @@ -582,7 +582,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do footer_verso_left_content: 'p{page-number}', footer_padding: [6, 0, 0, 0], } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Book Title :media: prepress :doctype: book @@ -599,7 +599,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do == Last Chapter content - EOS + END first_chapter_text = pdf.find_unique_text 'First Chapter' (expect first_chapter_text[:page_number]).to eql 3 @@ -624,7 +624,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do context 'Columns' do it 'should ignore columns for book doctype' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2 }, analyze: true = Document Title :doctype: book :notitle: @@ -636,7 +636,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< second page - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 (expect pdf.pages).to have_size 2 @@ -646,7 +646,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should ignore columns if less than 2' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 1 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 1 }, analyze: true = Document Title :notitle: @@ -656,7 +656,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< second page - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.find_unique_text 'first page')[:page_number]).to eql 1 @@ -664,7 +664,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should arrange article body into columns' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2 }, analyze: true first column [.column] @@ -677,7 +677,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do [.text-right] first column again - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 (expect pdf.pages).to have_size 2 @@ -689,14 +689,14 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should put footnotes at bottom of last column with content' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2 }, analyze: true first columnfootnote:[This page has two columns.] [.column] <<< second column - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 (expect pdf.pages).to have_size 1 @@ -708,7 +708,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should place document title outside of column box' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2 }, analyze: true = Article Title Goes Here first column @@ -717,7 +717,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< second column - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 (expect pdf.pages).to have_size 1 @@ -728,7 +728,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should place TOC outside of column box' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2 }, analyze: true = Article Title Goes Here :toc: @@ -738,7 +738,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< == Second Column - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 (expect pdf.pages).to have_size 1 @@ -756,7 +756,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should allow theme to control number of columns' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 4 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 4 }, analyze: true one [.column] @@ -773,7 +773,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<<< four - EOS + END midpoint = (get_page_size pdf)[0] * 0.5 (expect pdf.pages).to have_size 1 @@ -788,14 +788,14 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should allow theme to control column gap' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2, page_column_gap: 12 }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2, page_column_gap: 12 }, analyze: :image image::square.png[pdfwidth=100%] [.column] <<< image::square.png[pdfwidth=100%] - EOS + END images = pdf.images (expect images).to have_size 2 @@ -804,7 +804,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should restore columns following imported page' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2, page_column_gap: 12 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2, page_column_gap: 12 }, analyze: true = Document Title left column @@ -817,7 +817,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< right column - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 (expect pdf.pages).to have_size 3 @@ -836,7 +836,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should reset column index following imported page' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2, page_column_gap: 12 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2, page_column_gap: 12 }, analyze: true = Document Title left column @@ -854,7 +854,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< right column - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 (expect pdf.pages).to have_size 3 @@ -873,7 +873,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should restore column layout following missing imported page' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2, page_column_gap: 12 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2, page_column_gap: 12 }, analyze: true = Document Title left column @@ -891,7 +891,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< right column - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 (expect pdf.pages).to have_size 2 @@ -911,7 +911,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do # NOTE: assert current behavior it 'should stop column layout at page layout change' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_columns: 2 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_columns: 2 }, analyze: true left column [.column] @@ -936,7 +936,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< portrait - EOS + END (expect pdf.pages).to have_size 5 (expect (pdf.find_unique_text 'right column')[:x]).to be > 48.24 @@ -952,50 +952,50 @@ describe 'Asciidoctor::PDF::Converter - Page' do context 'Background' do it 'should set page background to white if value is not defined or transparent', visual: true do [nil, 'transparent'].each do |bg_color| - to_file = to_pdf_file <<~'EOS', %(page-background-color-#{bg_color || 'undefined'}.pdf), pdf_theme: { page_background_color: bg_color } + to_file = to_pdf_file <<~'END', %(page-background-color-#{bg_color || 'undefined'}.pdf), pdf_theme: { page_background_color: bg_color } = Document Title :doctype: book content - EOS + END (expect to_file).to visually_match 'page-background-color-default.pdf' end end it 'should set page background color specified by page_background_color key in theme', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-color.pdf', pdf_theme: { page_background_color: 'ECFBF4' } + to_file = to_pdf_file <<~'END', 'page-background-color.pdf', pdf_theme: { page_background_color: 'ECFBF4' } = Document Title :doctype: book content - EOS + END (expect to_file).to visually_match 'page-background-color.pdf' end it 'should not set page background if value of page-background-image is none or empty', visual: true do [' none', ''].each do |val| - to_file = to_pdf_file <<~EOS, %(page-background-image-#{val.empty? ? 'empty' : 'none'}.pdf) + to_file = to_pdf_file <<~END, %(page-background-image-#{val.empty? ? 'empty' : 'none'}.pdf) = Document Title :doctype: book :page-background-image:#{val} content - EOS + END (expect to_file).to visually_match 'page-background-color-default.pdf' end end it 'should set the background image using target of macro specified in page-background-image attribute', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-inline-macro.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-inline-macro.pdf' = Document Title :doctype: book :page-background-image: image:bg.png[] content - EOS + END (expect to_file).to visually_match 'page-background-image.pdf' end @@ -1004,13 +1004,13 @@ describe 'Asciidoctor::PDF::Converter - Page' do with_local_webserver do |base_url| [%(#{base_url}/bg.png), %(image:#{base_url}/bg.png[])].each_with_index do |image_url, idx| to_file = output_file %(page-background-image-remote-#{idx}.pdf) - doc = to_pdf <<~EOS, analyze: :document, to_file: to_file, attribute_overrides: { 'allow-uri-read' => '' } + doc = to_pdf <<~END, analyze: :document, to_file: to_file, attribute_overrides: { 'allow-uri-read' => '' } = Document Title :doctype: book :page-background-image: #{image_url} content - EOS + END (expect to_file).to visually_match 'page-background-image.pdf' # NOTE: we could assert no log messages instead, but that assumes the remove_tmp_files method is even called @@ -1022,12 +1022,12 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should use remote image specified in theme as page background', visual: true do with_local_webserver do |base_url| [%(#{base_url}/bg.png), %(image:#{base_url}/bg.png[])].each_with_index do |image_url, idx| - to_file = to_pdf_file <<~EOS, %(page-background-image-remote-#{idx}.pdf), attribute_overrides: { 'allow-uri-read' => '' }, pdf_theme: { page_background_image: image_url } + to_file = to_pdf_file <<~END, %(page-background-image-remote-#{idx}.pdf), attribute_overrides: { 'allow-uri-read' => '' }, pdf_theme: { page_background_image: image_url } = Document Title :doctype: book content - EOS + END (expect to_file).to visually_match 'page-background-image.pdf' end @@ -1037,12 +1037,12 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should use data URI specified by page-background-image attribute as page background', visual: true do image_data = File.binread fixture_file 'square.png' encoded_image_data = Base64.strict_encode64 image_data - to_file = to_pdf_file <<~EOS, %(page-background-image-attr-data-uri.pdf) + to_file = to_pdf_file <<~END, %(page-background-image-attr-data-uri.pdf) = Document Title :page-background-image: image:data:image/png;base64,#{encoded_image_data}[fit=fill] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-fill.pdf' end @@ -1051,11 +1051,11 @@ describe 'Asciidoctor::PDF::Converter - Page' do image_data = File.binread fixture_file 'square.png' encoded_image_data = Base64.strict_encode64 image_data pdf_theme = { page_background_image: %(image:data:image/png;base64,#{encoded_image_data}[fit=fill]) } - to_file = to_pdf_file <<~EOS, %(page-background-image-attr-data-uri.pdf), pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, %(page-background-image-attr-data-uri.pdf), pdf_theme: pdf_theme = Document Title This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-fill.pdf' end @@ -1066,12 +1066,12 @@ describe 'Asciidoctor::PDF::Converter - Page' do __dir__: fixtures_dir, page_background_image: (macro ? 'image:bg.png[]' : 'bg.png'), } - to_file = to_pdf_file <<~'EOS', %(page-background-image-#{macro ? 'macro' : 'bare'}.pdf), pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', %(page-background-image-#{macro ? 'macro' : 'bare'}.pdf), pdf_theme: pdf_theme = Document Title :doctype: book content - EOS + END (expect to_file).to visually_match 'page-background-image.pdf' end @@ -1079,12 +1079,12 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should resolve background image in theme relative to themesdir in classloader', if: RUBY_ENGINE == 'jruby' do require fixture_file 'pdf-themes.jar' - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => 'uri:classloader:/pdf-themes/page-background-image-theme.yml' } + pdf = to_pdf <<~'END', attribute_overrides: { 'pdf-theme' => 'uri:classloader:/pdf-themes/page-background-image-theme.yml' } = Document Title :doctype: book content - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -1092,12 +1092,12 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should resolve background image with absolute path for theme loaded from classloader', if: RUBY_ENGINE == 'jruby' do require fixture_file 'pdf-themes.jar' - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => 'uri:classloader:/pdf-themes/page-background-image-from-fixturesdir-theme.yml', 'fixturesdir' => fixtures_dir } + pdf = to_pdf <<~'END', attribute_overrides: { 'pdf-theme' => 'uri:classloader:/pdf-themes/page-background-image-from-fixturesdir-theme.yml', 'fixturesdir' => fixtures_dir } = Document Title :doctype: book content - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -1108,12 +1108,12 @@ describe 'Asciidoctor::PDF::Converter - Page' do 'pdf-theme' => 'page-background-image', 'pdf-themesdir' => fixtures_dir, } - to_file = to_pdf_file <<~'EOS', 'page-background-image-bare-in-theme-file.pdf', attribute_overrides: attribute_overrides + to_file = to_pdf_file <<~'END', 'page-background-image-bare-in-theme-file.pdf', attribute_overrides: attribute_overrides = Document Title :doctype: book content - EOS + END (expect to_file).to visually_match 'page-background-image.pdf' end @@ -1159,225 +1159,225 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should recognize attribute value that use block macro syntax', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-block-macro.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-block-macro.pdf' = Document Title :doctype: book :page-background-image: image:bg.png[] content - EOS + END (expect to_file).to visually_match 'page-background-image.pdf' end it 'should not crash if background image is a URI and the allow-uri-read attribute is not set' do (expect do - to_pdf <<~'EOS' + to_pdf <<~'END' = Document Title :page-background-image: image:https://example.org/bg.svg[] content - EOS + END end).to not_raise_exception & (log_message severity: :WARN, message: '~allow-uri-read attribute not enabled') end it 'should set the background image using path specified in page-background-image attribute', visual: true do - to_file = to_pdf_file <<~EOS, 'page-background-image-path.pdf' + to_file = to_pdf_file <<~END, 'page-background-image-path.pdf' = Document Title :doctype: book :page-background-image: #{fixture_file 'bg.png', relative: true} content - EOS + END (expect to_file).to visually_match 'page-background-image.pdf' end it 'should scale background image until it reaches shortest side', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-max-height.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-max-height.pdf' = Document Title :pdf-page-layout: landscape :page-background-image: image:square.png[] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-max-height.pdf' end it 'should set width of background image according to width attribute when fit=none', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-width.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-width.pdf' = Document Title :page-background-image: image:square.png[bg,200,fit=none] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-width.pdf' end it 'should scale down background PNG to fit boundaries of page if fit is scale-down and width slightly exceeds available width', visual: true do - reference_file = to_pdf_file <<~'EOS', 'page-background-image-fit-scale-down-reference.pdf' + reference_file = to_pdf_file <<~'END', 'page-background-image-fit-scale-down-reference.pdf' = Document Title :page-background-image: image:wide.png[fit=contain] content - EOS + END - to_file = to_pdf_file <<~'EOS', 'page-background-image-fit-scale-down-slightly.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-fit-scale-down-slightly.pdf' = Document Title :page-background-image: image:wide.png[fit=scale-down] content - EOS + END (expect to_file).to visually_match reference_file end it 'should scale up background SVG to fit boundaries of page if value is path', visual: true do - to_file = to_pdf_file <<~EOS, 'page-background-image-svg-scale-up-from-path.pdf' + to_file = to_pdf_file <<~END, 'page-background-image-svg-scale-up-from-path.pdf' = Document Title :page-background-image: #{fixture_file 'square.svg', relative: true} This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-up.pdf' end it 'should scale up background SVG to fit boundaries of page if value is macro', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-scale-up-from-macro.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-scale-up-from-macro.pdf' = Document Title :page-background-image: image:square.svg[] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-up.pdf' end it 'should scale up background SVG to fit boundaries of page if fit is contain', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-fit-contain.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-fit-contain.pdf' = Document Title :page-background-image: image:square.svg[fit=contain] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-up.pdf' end it 'should scale up background SVG to fit boundaries of page if fit is fill', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-fit-fill.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-fit-fill.pdf' = Document Title :page-background-image: image:square.svg[fit=fill] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-up.pdf' end it 'should scale up background SVG to fit boundaries of page if pdfwidth is 100% and fit=none', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-pdfwidth.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-pdfwidth.pdf' = Document Title :pdf-page-layout: landscape :page-background-image: image:square.svg[fit=none,pdfwidth=100%] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-contain.pdf' end it 'should scale down background SVG to fit boundaries of page if value is path', visual: true do - to_file = to_pdf_file <<~EOS, 'page-background-image-svg-scale-down-from-path.pdf' + to_file = to_pdf_file <<~END, 'page-background-image-svg-scale-down-from-path.pdf' = Document Title :page-background-image: #{fixture_file 'example-stamp.svg', relative: true} This page has a background image. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-down.pdf' end it 'should scale down background SVG to fit boundaries of page if value is macro', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-scale-down-from-macro.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-scale-down-from-macro.pdf' = Document Title :page-background-image: image:example-stamp.svg[] This page has a background image. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-down.pdf' end it 'should scale down background SVG to fit boundaries of page if fit is scale-down', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-fit-scale-down.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-fit-scale-down.pdf' = Document Title :page-background-image: image:example-stamp.svg[fit=scale-down] This page has a background image. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-down.pdf' end it 'should scale down background SVG to fit boundaries of page if fit is scale-down and width slightly exceeds available width', visual: true do - reference_file = to_pdf_file <<~'EOS', 'page-background-image-svg-fit-scale-down-reference.pdf' + reference_file = to_pdf_file <<~'END', 'page-background-image-svg-fit-scale-down-reference.pdf' = Document Title :page-background-image: image:wide.svg[fit=contain] content - EOS + END - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-fit-scale-down-slightly.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-fit-scale-down-slightly.pdf' = Document Title :page-background-image: image:wide.svg[fit=scale-down] content - EOS + END (expect to_file).to visually_match reference_file end it 'should scale down background SVG to fit boundaries of page if computed height is greater than page height', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-fit-scale-down-computed-height.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-fit-scale-down-computed-height.pdf' :pdf-page-size: A6 :page-background-image: image:tall.svg[pdfwidth=200,fit=scale-down] - EOS + END (expect to_file).to visually_match 'page-background-image-svg-fit-scale-down-height.pdf' end it 'should scale down background SVG to fit boundaries of page if intrinsic height is greater than page height', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-fit-scale-down-intrinsic-height.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-fit-scale-down-intrinsic-height.pdf' :pdf-page-size: A6 :page-background-image: image:tall.svg[fit=scale-down] - EOS + END (expect to_file).to visually_match 'page-background-image-svg-fit-scale-down-height.pdf' end it 'should not scale background SVG with explicit width to fit boundaries of page if fit is scale-down and image fits', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-prescaled.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-prescaled.pdf' = Document Title :pdf-page-layout: landscape :page-background-image: image:green-bar.svg[pdfwidth=50%,fit=scale-down] This page has a background image. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-prescaled.pdf' end it 'should not scale background image without explicit width to fit boundaries of page if fit is scale-down and image fits' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :page-background-image: image:square.png[fit=scale-down] This page has a background image. - EOS + END (expect pdf.images).to have_size 1 bg_image = pdf.images[0] @@ -1386,45 +1386,45 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should not scale background SVG to fit boundaries of page if fit is none', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-fit-none.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-fit-none.pdf' = Document Title :page-background-image: image:example-stamp.svg[fit=none] This page has a background image. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-unscaled.pdf' end it 'should scale up background SVG until it covers page if fit=cover', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-cover.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-cover.pdf' = Document Title :page-background-image: image:square.svg[fit=cover] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-cover.pdf' end it 'should scale background PNG to fill page if fit=fill', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-fill.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-fill.pdf' = Document Title :page-background-image: image:square.png[fit=fill] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-fill.pdf' end it 'should allow remote image in SVG to be read if allow-uri-read attribute is set', network: true, visual: true do with_svg_with_remote_image do |image_path| - to_file = to_pdf_file <<~EOS, 'page-background-image-svg-with-remote-image.pdf', attribute_overrides: { 'allow-uri-read' => '' } + to_file = to_pdf_file <<~END, 'page-background-image-svg-with-remote-image.pdf', attribute_overrides: { 'allow-uri-read' => '' } :page-background-image: image:#{image_path}[fit=none,position=top] Asciidoctor - EOS + END (expect to_file).to visually_match 'page-background-image-svg-with-image.pdf' end @@ -1433,11 +1433,11 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should not allow remote image in SVG to be read if allow-uri-read attribute is not set', visual: true do with_svg_with_remote_image do |image_path| (expect do - to_file = to_pdf_file <<~EOS, 'page-background-image-svg-with-remote-image-disabled.pdf' + to_file = to_pdf_file <<~END, 'page-background-image-svg-with-remote-image-disabled.pdf' :page-background-image: image:#{image_path}[fit=none,position=top] Asciidoctor - EOS + END (expect to_file).to visually_match 'page-background-image-svg-with-image-disabled.pdf' end).to log_message severity: :WARN, message: '~No handler available for this URL scheme' @@ -1446,55 +1446,55 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should not warn if background SVG has warnings', visual: true do (expect do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-faulty.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-faulty.pdf' = Document Title :page-background-image: image:faulty.svg[] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-up.pdf' end).to log_message severity: :WARN, message: %(~problem encountered in image: #{fixture_file 'faulty.svg'}; Unknown tag 'foobar') end it 'should read local image relative to SVG', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-with-local-image.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-svg-with-local-image.pdf' :page-background-image: image:svg-with-local-image.svg[fit=none,pdfwidth=1cm,position=top] Asciidoctor - EOS + END (expect to_file).to visually_match 'page-background-image-svg-with-image.pdf' end it 'should position background image according to value of position attribute on macro', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-position.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-position.pdf' = Document Title :page-background-image: image:example-stamp.svg[fit=none,pdfwidth=50%,position=bottom center] content - EOS + END (expect to_file).to visually_match 'page-background-image-position.pdf' end it 'should position page background in center if position value is unrecognized' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :page-background-image: image:tux.png[fit=none,pdfwidth=4in,position=center] content - EOS + END bg_image = pdf.images[0] center_coords = [bg_image[:x], bg_image[:y]] ['droit', 'haut droit'].each do |position| - pdf = to_pdf <<~EOS, analyze: :image + pdf = to_pdf <<~END, analyze: :image = Document Title :page-background-image: image:tux.png[fit=none,pdfwidth=4in,position=#{position}] content - EOS + END bg_image = pdf.images[0] actual_coords = [bg_image[:x], bg_image[:y]] @@ -1503,7 +1503,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should alternate page background if both verso and recto background images are specified', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-alt.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-alt.pdf' = Document Title :doctype: book :page-background-image-recto: image:recto-bg.png[] @@ -1518,13 +1518,13 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< the end - EOS + END (expect to_file).to visually_match 'page-background-image-alt.pdf' end it 'should swap recto and verso background images when pdf-folio-placement is inverted', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-alt.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-alt.pdf' = Document Title :doctype: book :page-background-image-recto: image:verso-bg.png[] @@ -1540,13 +1540,13 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< the end - EOS + END (expect to_file).to visually_match 'page-background-image-alt.pdf' end it 'should alternate page background in landscape if both verso and recto background images are specified', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-alt-landscape.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-alt-landscape.pdf' = Document Title :doctype: book :pdf-page-layout: landscape @@ -1562,13 +1562,13 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< the end - EOS + END (expect to_file).to visually_match 'page-background-image-alt-landscape.pdf' end it 'should use background image as fallback if background image for side not specified', visual: true do - to_file = to_pdf_file <<~'EOS', 'page-background-image-alt.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-alt.pdf' = Document Title :doctype: book :page-background-image: image:recto-bg.png[] @@ -1583,7 +1583,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< the end - EOS + END (expect to_file).to visually_match 'page-background-image-alt.pdf' end @@ -1594,7 +1594,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do { 'page-background-image' => 'image:recto-bg.png[]', 'page-background-image-verso' => '' }, { 'page-background-image-recto' => 'image:recto-bg.png[]' }, ].each do |attribute_overrides| - to_file = to_pdf_file <<~'EOS', 'page-background-image-recto-only.pdf', attribute_overrides: attribute_overrides + to_file = to_pdf_file <<~'END', 'page-background-image-recto-only.pdf', attribute_overrides: attribute_overrides = Document Title :doctype: book @@ -1607,7 +1607,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< the end - EOS + END (expect to_file).to visually_match 'page-background-image-recto-only.pdf' end @@ -1618,7 +1618,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do { 'page-background-image' => 'image:verso-bg.png[]', 'page-background-image-recto' => 'none' }, { 'page-background-image-verso' => 'image:verso-bg.png[]' }, ].each do |attribute_overrides| - to_file = to_pdf_file <<~'EOS', 'page-background-image-verso-only.pdf', attribute_overrides: attribute_overrides + to_file = to_pdf_file <<~'END', 'page-background-image-verso-only.pdf', attribute_overrides: attribute_overrides = Document Title :doctype: book @@ -1631,7 +1631,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< the end - EOS + END (expect to_file).to visually_match 'page-background-image-verso-only.pdf' end @@ -1639,14 +1639,14 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should allow page background image in theme to be specified per layout using page-layout attribute reference in path' do pdf_theme = { __dir__: fixtures_dir, page_background_image: 'image:square-{page-layout}.svg[fit=fill]' } - rects = (to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :rect).rects + rects = (to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :rect).rects portrait page [page-layout=landscape] <<< landscape page - EOS + END (expect rects).to have_size 2 (expect rects[0][:fill_color]).to eql 'FF0000' (expect rects[0][:point][0]).to eql 0.0 @@ -1654,7 +1654,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do end it 'should allow page background image in doc to be specified per layout using page-layout attribute reference in path' do - rects = (to_pdf <<~'EOS', analyze: :rect).rects + rects = (to_pdf <<~'END', analyze: :rect).rects :page-background-image: image:square-\{page-layout}.svg[fit=fill] portrait page @@ -1662,7 +1662,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< landscape page - EOS + END (expect rects).to have_size 2 (expect rects[0][:fill_color]).to eql 'FF0000' (expect rects[0][:point][0]).to eql 0.0 @@ -1672,12 +1672,12 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should use the specified image format', visual: true do source_file = (dest_file = fixture_file 'square') + '.svg' FileUtils.cp source_file, dest_file - to_file = to_pdf_file <<~'EOS', 'page-background-image-format.pdf' + to_file = to_pdf_file <<~'END', 'page-background-image-format.pdf' = Document Title :page-background-image: image:square[format=svg] This page has a background image that is rather loud. - EOS + END (expect to_file).to visually_match 'page-background-image-svg-scale-up.pdf' ensure @@ -1686,43 +1686,43 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should warn instead of crash if image is unreadable' do (expect do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :page-background-image: image:does-not-exist.png[fit=cover] content - EOS + END (expect pdf.images).to be_empty end).to log_message severity: :WARN, message: '~page background image not found or readable' end it 'should warn instead of crash if background image is invalid' do (expect do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :page-background-image: image:corrupt.png[fit=cover] content - EOS + END (expect pdf.images).to be_empty end).to log_message severity: :WARN, message: '~image file is an unrecognised format' end it 'should warn instead of crash if background image cannot be parsed' do (expect do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :page-background-image: image:broken.svg[fit=cover] content - EOS + END (expect pdf.images).to be_empty end).to log_message severity: :WARN, message: %(~Missing end tag for 'rect') end it 'should only warn once if background image cannot be loaded' do (expect do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :page-background-image: image:corrupt.png[fit=cover] @@ -1735,14 +1735,14 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< even more content - EOS + END (expect pdf.images).to be_empty end).to log_message severity: :WARN, message: '~image file is an unrecognised format' end it 'should still render different facing background image when background image cannot be loaded' do (expect do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :page-background-image: image:corrupt.png[fit=cover] :page-background-image-verso: image:bg.png[] @@ -1756,7 +1756,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< even more content - EOS + END (expect pdf.images).to have_size 1 (expect pdf.images[0][:page_number]).to be 2 end).to log_message severity: :WARN, message: '~image file is an unrecognised format' @@ -1764,7 +1764,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do it 'should support PDF as background image', visual: true do # NOTE: the running content is automatically disabled since this becomes an imported page - to_file = to_pdf_file <<~'EOS', 'page-background-image-pdf.pdf', enable_footer: true + to_file = to_pdf_file <<~'END', 'page-background-image-pdf.pdf', enable_footer: true :page-background-image-recto: image:tux-bg.pdf[] Tux has left his mark on this page. @@ -1772,14 +1772,14 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< But not on this page. - EOS + END (expect to_file).to visually_match 'page-background-image-pdf.pdf' end it 'should only warn once if PDF for background image cannot be found' do (expect do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :page-background-image: image:no-such-file.pdf[] @@ -1792,7 +1792,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do <<< even more content - EOS + END (expect pdf.images).to be_empty end).to log_message severity: :WARN, message: '~page background image not found or readable' end @@ -1800,7 +1800,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do context 'Watermark' do it 'should stamp watermark image on the top of all pages if page-foreground-image is specified', visual: true do - to_file = to_pdf_file <<~EOS, 'page-watermark.pdf' + to_file = to_pdf_file <<~END, 'page-watermark.pdf' = Document Title :doctype: book :page-foreground-image: image:watermark.svg[] @@ -1812,13 +1812,13 @@ describe 'Asciidoctor::PDF::Converter - Page' do [.text-left] #{['lots of rambling'] * 150 * ?\n} - EOS + END (expect to_file).to visually_match 'page-watermark.pdf' end it 'should no apply watermark image to front cover, back cover, or imported page', visual: true do - to_file = to_pdf_file <<~EOS, 'page-watermark-content-only.pdf' + to_file = to_pdf_file <<~END, 'page-watermark-content-only.pdf' = Document Title :doctype: book :front-cover-image: image:cover.jpg[] @@ -1833,7 +1833,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do [.text-left] #{['lots of rambling'] * 150 * ?\n} - EOS + END (expect to_file).to visually_match 'page-watermark-content-only.pdf' end diff --git a/spec/paragraph_spec.rb b/spec/paragraph_spec.rb index b8697fc2..0f941087 100644 --- a/spec/paragraph_spec.rb +++ b/spec/paragraph_spec.rb @@ -4,11 +4,11 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Paragraph' do it 'should normalize newlines and whitespace' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true He's a real nowhere man, Sitting in his nowhere land, Making all his nowhere plans\tfor nobody. - EOS + END (expect pdf.text).to have_size 1 text = pdf.text[0][:string] (expect text).not_to include ' ' @@ -23,14 +23,14 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do role_outline_border_color: '0000EE', } with_content_spacer 50, 675 do |spacer_path| - input = <<~EOS + input = <<~END [.outline]#top# image::#{spacer_path}[] #{(lorem_ipsum '2-sentences-1-paragraph').sub 'non', '[.outline]#non#'} #{(['fillmefillme'] * 380).join ' '} [.outline]#fin# - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true (expect pdf.pages).to have_size 3 @@ -67,10 +67,10 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should not indent first line of paragraph if text alignment is center' do - input = <<~'EOS' + input = <<~'END' [.text-center] x - EOS + END expected_x = (to_pdf input, analyze: true).text[0][:x] actual_x = (to_pdf input, pdf_theme: { prose_text_indent: 18 }, analyze: true).text[0][:x] @@ -79,10 +79,10 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should not indent first line of paragraph if text alignment is right' do - input = <<~'EOS' + input = <<~'END' [.text-right] x - EOS + END expected_x = (to_pdf input, analyze: true).text[0][:x] actual_x = (to_pdf input, pdf_theme: { prose_text_indent: 18 }, analyze: true).text[0][:x] @@ -115,11 +115,11 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should use prose_margin_inner between paragraphs when prose_text_indent key is set in theme' do - pdf = to_pdf <<~EOS, pdf_theme: { prose_text_indent: 18, prose_margin_inner: 0 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { prose_text_indent: 18, prose_margin_inner: 0 }, analyze: true #{lorem_ipsum '2-sentences-2-paragraphs'} * list item - EOS + END line_spacing = 1.upto(3).map {|i| (pdf.text[i - 1][:y] - pdf.text[i][:y]).round 2 }.uniq (expect line_spacing).to have_size 1 @@ -131,11 +131,11 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should use prose_margin_inner between paragraphs even when prose_text_indent key in theme is set to 0' do - pdf = to_pdf <<~EOS, pdf_theme: { prose_text_indent: 0, prose_margin_inner: 0 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { prose_text_indent: 0, prose_margin_inner: 0 }, analyze: true #{lorem_ipsum '2-sentences-2-paragraphs'} * list item - EOS + END line_spacing = 1.upto(3).map {|i| (pdf.text[i - 1][:y] - pdf.text[i][:y]).round 2 }.uniq (expect line_spacing).to have_size 1 @@ -152,7 +152,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do prose_text_indent_inner: 10.5, prose_margin_inner: 0, } - pdf = to_pdf <<~EOS, analyze: true, pdf_theme: pdf_theme + pdf = to_pdf <<~END, analyze: true, pdf_theme: pdf_theme #{lorem_ipsum '2-sentences-1-paragraph'} #{lorem_ipsum '2-sentences-1-paragraph'} @@ -162,7 +162,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do #{lorem_ipsum '2-sentences-1-paragraph'} #{lorem_ipsum '2-sentences-1-paragraph'} - EOS + END lorem_texts = pdf.find_text %r/^Lorem/ (expect lorem_texts).to have_size 4 @@ -173,12 +173,12 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should allow text alignment to be controlled using text-align document attribute' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :text-align: right right-aligned - EOS + END center_x = (pdf.page 1)[:size][1] / 2 paragraph_text = (pdf.find_text 'right-aligned')[0] @@ -186,10 +186,10 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should output block title for paragraph if specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true .Disclaimer All views expressed are my own. - EOS + END (expect pdf.lines).to eql ['Disclaimer', 'All views expressed are my own.'] disclaimer_text = (pdf.find_text 'Disclaimer')[0] @@ -197,10 +197,10 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should use base text align if caption align is set to inherit' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_text_align: 'right', caption_align: 'inherit' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_text_align: 'right', caption_align: 'inherit' }, analyze: true .Title Text - EOS + END center_x = (pdf.page 1)[:size][1] * 0.5 title_text = pdf.find_unique_text 'Title' @@ -210,10 +210,10 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should use value of align on caption to align text if caption_text_align key not specified' do - pdf = to_pdf <<~'EOS', pdf_theme: { caption_align: 'right' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { caption_align: 'right' }, analyze: true .Title Text - EOS + END center_x = (pdf.page 1)[:size][1] * 0.5 title_text = pdf.find_unique_text 'Title' @@ -223,7 +223,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should apply the lead style to a paragraph with the lead role' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title preamble content @@ -234,7 +234,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do == First Section section content - EOS + END preamble_text = pdf.find_text 'preamble content' (expect preamble_text).to have_size 1 @@ -245,10 +245,10 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should allow the theme to control the line height of a lead paragraph' do - input = <<~EOS + input = <<~END [.lead] #{lorem_ipsum '2-sentences-1-paragraph'} - EOS + END reference_texts = (to_pdf input, analyze: true).text default_spacing = reference_texts[0][:y] - reference_texts[1][:y] @@ -268,12 +268,12 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do role_custom_text_transform: 'lowercase', } - input = <<~EOS + input = <<~END reference [.custom] This is a special paragraph. - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true left_margin = pdf.text[0][:x] @@ -286,10 +286,10 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do end it 'should allow the theme to control the line height of a paragraph with a custom role' do - input = <<~EOS + input = <<~END [.spaced-out] #{lorem_ipsum '2-sentences-1-paragraph'} - EOS + END reference_texts = (to_pdf input, analyze: true).text default_spacing = reference_texts[0][:y] - reference_texts[1][:y] diff --git a/spec/pass_spec.rb b/spec/pass_spec.rb index 5e3a8416..0371efe2 100644 --- a/spec/pass_spec.rb +++ b/spec/pass_spec.rb @@ -4,7 +4,7 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Pass' do 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 + pdf = to_pdf <<~'END', pdf_theme: { base_font_color: '222222', code_font_color: '0000EE' }, analyze: true ++++ <p> stay @@ -14,7 +14,7 @@ describe 'Asciidoctor::PDF::Converter - Pass' do through </p> ++++ - EOS + END all_text = pdf.text (expect all_text.size).to be > 1 @@ -27,13 +27,13 @@ describe 'Asciidoctor::PDF::Converter - Pass' do end it 'should add bottom margin to pass block' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true ++++ This is a pass block. ++++ This is a paragraph. - EOS + END pass_text = pdf.find_unique_text 'This is a pass block.' para_text = pdf.find_unique_text 'This is a paragraph.' diff --git a/spec/pdf_info_spec.rb b/spec/pdf_info_spec.rb index 44d85250..1dce4273 100644 --- a/spec/pdf_info_spec.rb +++ b/spec/pdf_info_spec.rb @@ -33,12 +33,12 @@ describe 'Asciidoctor::PDF::Converter - PDF Info' do it 'should set Author and Producer field to value of author attribute if set' do ['Author Name', ':author: Author Name'].each do |author_line| - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title #{author_line} content - EOS + END (expect pdf.info[:Producer]).to eql pdf.info[:Author] (expect pdf.info[:Author]).to eql 'Author Name' end @@ -46,14 +46,14 @@ describe 'Asciidoctor::PDF::Converter - PDF Info' do it 'should set Author and Producer field to value of author attribute if set to multiple authors' do ['Author Name; Assistant Name', ':authors: Author Name; Assistant Name'].each do |author_line| - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title #{author_line} [%hardbreaks] First Author: {author_1} Second Author: {author_2} - EOS + END lines = ((pdf.page 1).text.split ?\n).map(&:strip) (expect pdf.info[:Producer]).to eql pdf.info[:Author] (expect pdf.info[:Author]).to eql 'Author Name, Assistant Name' @@ -64,14 +64,14 @@ describe 'Asciidoctor::PDF::Converter - PDF Info' do it 'should set Author and Producer field using authors attribute with non-Latin characters' do ['Doc Writer; Antonín Dvořák', ':authors: Doc Writer; Antonín Dvořák'].each do |author_line| - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title #{author_line} [%hardbreaks] First Author: {author_1} Second Author: {author_2} - EOS + END lines = ((pdf.page 1).text.split ?\n).map(&:strip) (expect pdf.info[:Producer]).to eql pdf.info[:Author] (expect pdf.info[:Author]).to eql 'Doc Writer, Antonín Dvořák' @@ -81,91 +81,91 @@ describe 'Asciidoctor::PDF::Converter - PDF Info' do end it 'should set Author field to value of author attribute if locked by the API' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'author' => 'Doc Writer' } + pdf = to_pdf <<~'END', attribute_overrides: { 'author' => 'Doc Writer' } = Document Title Author Name content - EOS + END (expect pdf.info[:Author]).to eql 'Doc Writer' end it 'should set Author field to value of authors attribute if locked by the API' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'authors' => 'Doc Writer' } + pdf = to_pdf <<~'END', attribute_overrides: { 'authors' => 'Doc Writer' } = Document Title Author Name content - EOS + END (expect pdf.info[:Author]).to eql 'Doc Writer' end it 'should set Author field to value of authors attribute if both author and authors attributes are locked by the API' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'authors' => 'Doc Writer', 'author' => 'Anonymous' } + pdf = to_pdf <<~'END', attribute_overrides: { 'authors' => 'Doc Writer', 'author' => 'Anonymous' } = Document Title Author Name content - EOS + END (expect pdf.info[:Author]).to eql 'Doc Writer' end it 'should set Author field to value of author attribute if document has no doctitle' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :author: Author Name == Section Title content - EOS + END (expect pdf.info[:Author]).to eql 'Author Name' end it 'should set Author field to value of authors attribute if document has no doctitle' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :authors: Author Name == Section Title content - EOS + END (expect pdf.info[:Author]).to eql 'Author Name' end it 'should set Producer field to value of publisher attribute if set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title Author Name :publisher: Big Cheese content - EOS + END (expect pdf.info[:Author]).to eql 'Author Name' (expect pdf.info[:Producer]).to eql 'Big Cheese' end it 'should set Subject field to value of subject attribute if set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :subject: Cooking content - EOS + END (expect pdf.info[:Subject]).to eql 'Cooking' end it 'should set Keywords field to value of subject attribute if set' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :keywords: cooking, diet, plants content - EOS + END (expect pdf.info[:Keywords]).to eql 'cooking, diet, plants' end it 'should sanitize values of Author, Subject, Keywords, and Producer fields' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title D_J Allen :subject: Science & Math @@ -173,7 +173,7 @@ describe 'Asciidoctor::PDF::Converter - PDF Info' do :publisher: Schrödinger’s Cat content - EOS + END pdf_info = pdf.info (expect pdf_info[:Author]).to eql 'D_J Allen' @@ -220,24 +220,24 @@ describe 'Asciidoctor::PDF::Converter - PDF Info' do end it 'should not add dates to document if reproducible attribute is set' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'reproducible' => '' } + pdf = to_pdf <<~'END', attribute_overrides: { 'reproducible' => '' } = Document Title Author Name content - EOS + END (expect pdf.info[:ModDate]).to be_nil (expect pdf.info[:CreationDate]).to be_nil end it 'should not add software versions to document if reproducible attribute is set' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'reproducible' => '' } + pdf = to_pdf <<~'END', attribute_overrides: { 'reproducible' => '' } = Document Title Author Name content - EOS + END (expect pdf.info[:Creator]).to eql 'Asciidoctor PDF, based on Prawn' end @@ -312,13 +312,13 @@ describe 'Asciidoctor::PDF::Converter - PDF Info' do end it 'should not compress streams when compress attribute is set on document and page is imported' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'compress' => '' } + pdf = to_pdf <<~'END', attribute_overrides: { 'compress' => '' } before image::red-green-blue.pdf[page=1] after - EOS + END objects = pdf.objects pages = pdf.objects.values.find {|it| Hash === it && it[:Type] == :Pages } objects[pages[:Kids][1]][:Contents].map {|it| objects[it] }.each do |stream| diff --git a/spec/pdfmark_spec.rb b/spec/pdfmark_spec.rb index 0fa12f91..a879c10c 100644 --- a/spec/pdfmark_spec.rb +++ b/spec/pdfmark_spec.rb @@ -7,7 +7,7 @@ describe Asciidoctor::PDF::Pdfmark do context 'generator' do it 'should generate pdfmark info from document' do - doc = Asciidoctor.load <<~'EOS', safe: :safe + doc = Asciidoctor.load <<~'END', safe: :safe = Materials Science and Engineering: An Introduction William D. Callister :doctype: book @@ -15,7 +15,7 @@ describe Asciidoctor::PDF::Pdfmark do :localdatetime: 2018-01-17 :subject: Materials Science :keywords: semiconductors, band gap - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Title (Materials Science and Engineering: An Introduction)' @@ -29,11 +29,11 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should use value of untitled-label as title if document has no header' do - doc = Asciidoctor.load <<~'EOS', safe: :safe + doc = Asciidoctor.load <<~'END', safe: :safe == Section content - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Title (Untitled)' @@ -41,7 +41,7 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should sanitize values of Author, Subject, Keywords, and Producer fields' do - doc = Asciidoctor.load <<~'EOS', safe: :safe + doc = Asciidoctor.load <<~'END', safe: :safe = Document Title D_J Allen :subject: Science & Math @@ -49,7 +49,7 @@ describe Asciidoctor::PDF::Pdfmark do :publisher: Schrödinger’s Cat content - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Author (D_J Allen)' @@ -60,12 +60,12 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should set Author field to value of author attribute if locked by the API' do - doc = Asciidoctor.load <<~'EOS', safe: :safe, attributes: { 'author' => 'Doc Writer' } + doc = Asciidoctor.load <<~'END', safe: :safe, attributes: { 'author' => 'Doc Writer' } = Document Title Author Name content - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Author (Doc Writer)' @@ -73,12 +73,12 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should set Author field to value of authors attribute if locked by the API' do - doc = Asciidoctor.load <<~'EOS', safe: :safe, attributes: { 'authors' => 'Doc Writer' } + doc = Asciidoctor.load <<~'END', safe: :safe, attributes: { 'authors' => 'Doc Writer' } = Document Title Author Name content - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Author (Doc Writer)' @@ -86,12 +86,12 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should set Author field to value of authors attribute if both author and authors attribute locked by the API' do - doc = Asciidoctor.load <<~'EOS', safe: :safe, attributes: { 'authors' => 'Doc Writer', 'author' => 'Anonymous' } + doc = Asciidoctor.load <<~'END', safe: :safe, attributes: { 'authors' => 'Doc Writer', 'author' => 'Anonymous' } = Document Title Author Name content - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Author (Doc Writer)' @@ -99,13 +99,13 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should set Author field to value of author attribute if document has no doctitle' do - doc = Asciidoctor.load <<~'EOS', safe: :safe + doc = Asciidoctor.load <<~'END', safe: :safe :author: Author Name == Section Title content - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Author (Author Name)' @@ -113,13 +113,13 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should set Author field to value of authors attribute if document has no doctitle' do - doc = Asciidoctor.load <<~'EOS', safe: :safe + doc = Asciidoctor.load <<~'END', safe: :safe :authors: Author Name == Section Title content - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Author (Author Name)' @@ -127,13 +127,13 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should set date to Unix epoch in UTC if reproducible attribute is set' do - doc = Asciidoctor.load <<~'EOS', safe: :safe + doc = Asciidoctor.load <<~'END', safe: :safe = Document Title Author Name :reproducible: body - EOS + END contents = (subject.new doc).generate (expect contents).to include '/Title (Document Title)' @@ -143,14 +143,14 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should fallback to current date if dates are not parsable' do - doc = Asciidoctor.load <<~'EOS', safe: :safe + doc = Asciidoctor.load <<~'END', safe: :safe = Document Title Author Name :docdatetime: garbage :localdatetime: garbage body - EOS + END expected_date = Time.now.to_pdf_object.slice 0, 11 contents = (subject.new doc).generate @@ -161,13 +161,13 @@ describe Asciidoctor::PDF::Pdfmark do end it 'should fallback to current date if only localdatetime is not parsable' do - doc = Asciidoctor.load <<~'EOS', safe: :safe + doc = Asciidoctor.load <<~'END', safe: :safe = Document Title Author Name :localdatetime: garbage body - EOS + END expected_date = Time.now.to_pdf_object.slice 0, 11 contents = (subject.new doc).generate diff --git a/spec/preamble_spec.rb b/spec/preamble_spec.rb index 5a8d3fa4..58193f50 100644 --- a/spec/preamble_spec.rb +++ b/spec/preamble_spec.rb @@ -5,11 +5,11 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Preamble' do context 'article' do it 'should not style first paragraph of preamble as lead in untitled article with no sections' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true first paragraph second paragraph - EOS + END first_paragraph_text = pdf.find_text 'first paragraph' (expect first_paragraph_text).to have_size 1 @@ -20,7 +20,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should not crash if preamble has no blocks' do - doc = Asciidoctor.load <<~'EOS', backend: :pdf, standalone: true + doc = Asciidoctor.load <<~'END', backend: :pdf, standalone: true = Document Title :nofooter: @@ -30,7 +30,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do == Section content - EOS + END doc.blocks[0].blocks.clear doc.convert.render (pdf_io = StringIO.new) @@ -40,13 +40,13 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should not style first paragraph of preamble as lead in article with no sections' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title first paragraph second paragraph - EOS + END first_paragraph_text = pdf.find_text 'first paragraph' (expect first_paragraph_text).to have_size 1 @@ -57,7 +57,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should style first paragraph of preamble as lead' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title preamble content @@ -67,7 +67,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do == First Section section content - EOS + END preamble_text = pdf.find_text 'preamble content' (expect preamble_text).to have_size 1 @@ -81,7 +81,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should not style first paragraph of preamble as lead if it already has a role' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title [.nolead] @@ -92,7 +92,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do == First Section section content - EOS + END preamble_text = pdf.find_text 'preamble content' (expect preamble_text).to have_size 1 @@ -105,13 +105,13 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do context 'book' do it 'should not style first paragraph of preamble in untitled book with no sections' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :doctype: book first paragraph second paragraph - EOS + END first_paragraph_text = pdf.find_text 'first paragraph' (expect first_paragraph_text).to have_size 1 @@ -122,14 +122,14 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should not style first paragraph of preamble as lead in book with no sections' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book first paragraph second paragraph - EOS + END first_paragraph_text = pdf.find_text 'first paragraph' (expect first_paragraph_text).to have_size 1 @@ -140,7 +140,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should style first paragraph of preamble as lead in book with at least one chapter' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book @@ -151,7 +151,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do == First Chapter chapter content - EOS + END preamble_text = pdf.find_text 'preamble content' (expect preamble_text).to have_size 1 @@ -165,7 +165,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should not style paragraph after abstract as lead in book with an abstract' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book @@ -179,7 +179,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do == First Chapter chapter content - EOS + END after_abstract_text = pdf.find_text 'This is the paragraph after the abstract.' (expect after_abstract_text).to have_size 1 @@ -190,7 +190,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should ignore abstract with no blocks' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book @@ -205,7 +205,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do == Second Chapter content - EOS + END (expect pdf.pages).to have_size 3 first_chapter_text = pdf.find_unique_text 'First Chapter' @@ -214,7 +214,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do end it 'should promote preamble to preface if preface-title is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :preface-title: Preface @@ -224,7 +224,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do == First Chapter chapter content - EOS + END (expect pdf.find_text 'Preface', page_number: 2, font_size: 22).to have_size 1 preamble_text = pdf.find_text 'preamble content' @@ -242,7 +242,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do role_lead_font_size: 14, role_lead_font_color: '000000', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title preamble content @@ -252,7 +252,7 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do == First Section section content - EOS + END preamble_text = pdf.find_text 'preamble content' (expect preamble_text).to have_size 1 diff --git a/spec/quote_spec.rb b/spec/quote_spec.rb index 0b212ada..0d1098c7 100644 --- a/spec/quote_spec.rb +++ b/spec/quote_spec.rb @@ -4,12 +4,12 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Quote' do it 'should show caption above block if title is specified' do - input = <<~'EOS' + input = <<~'END' .Words of wisdom ____ Let it be. ____ - EOS + END pdf = to_pdf input, analyze: :line lines = pdf.lines @@ -27,12 +27,12 @@ describe 'Asciidoctor::PDF::Converter - Quote' do end it 'should show attribution line below text of quote' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [,Alice Walker,Speech] ____ The most common way people give up their power is by thinking they don't have any. ____ - EOS + END last_quote_text = pdf.text[-2] attribution_text = (pdf.find_text %r/Alice Walker/)[0] @@ -46,10 +46,10 @@ describe 'Asciidoctor::PDF::Converter - Quote' do it 'should escape bare ampersand in attribution' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [quote, J. Helliwell & B. McMahon] The richer the metadata available to the scientist, the greater the potential for new discoveries. - EOS + END (expect pdf.lines[-1]).to eql %(\u2014 J. Helliwell & B. McMahon) end).to not_log_message @@ -57,10 +57,10 @@ describe 'Asciidoctor::PDF::Converter - Quote' do it 'should escape bare ampersand in citetitle' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [quote, J. Helliwell & B. McMahon, Melbourne Congress & General Assembly of the IUCr] The richer the metadata available to the scientist, the greater the potential for new discoveries. - EOS + END (expect pdf.lines[-1]).to eql %(\u2014 J. Helliwell & B. McMahon, Melbourne Congress & General Assembly of the IUCr) end).to not_log_message @@ -68,22 +68,22 @@ describe 'Asciidoctor::PDF::Converter - Quote' do it 'should render character reference in attribution' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [quote, J. Helliwell & B. McMahon © IUCr] The richer the metadata available to the scientist, the greater the potential for new discoveries. - EOS + END (expect pdf.lines[-1]).to eql %(\u2014 J. Helliwell & B. McMahon \u00a9 IUCr) end).to not_log_message end it 'should apply substitutions to attribution and citetitle if enclosed in single quotes' do - input = <<~'EOS' + input = <<~'END' [, 'Author--aka Alias', 'https://asciidoctor.org[Source]'] ____ Use the attribution and citetitle attributes to credit the author and identify the source of the quote, respectively. ____ - EOS + END pdf = to_pdf input, analyze: true attribution_text, citetitle_text = (pdf.find_text font_size: 9) @@ -102,60 +102,60 @@ describe 'Asciidoctor::PDF::Converter - Quote' do end it 'should honor text alignment role on styled paragraph' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [quote.text-right] Yep. - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 (expect (pdf.find_unique_text 'Yep.')[:x]).to be > midpoint end it 'should not draw left border if border_left_width is 0' do - pdf = to_pdf <<~'EOS', pdf_theme: { quote_border_left_width: 0 }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { quote_border_left_width: 0 }, analyze: :line ____ Let it be. ____ - EOS + END (expect pdf.lines).to be_empty end it 'should not draw left border if border_left_width is nil' do - pdf = to_pdf <<~'EOS', pdf_theme: { quote_border_left_width: nil, quote_border_width: nil }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { quote_border_left_width: nil, quote_border_width: nil }, analyze: :line ____ Let it be. ____ - EOS + END (expect pdf.lines).to be_empty end it 'should not draw left border if color is transparent' do - lines = (to_pdf <<~'EOS', pdf_theme: { quote_border_color: 'transparent' }, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: { quote_border_color: 'transparent' }, analyze: :line).lines ____ Let it be. ____ - EOS + END (expect lines).to be_empty end it 'should not draw left border if color is nil and base border color is nil' do - lines = (to_pdf <<~'EOS', pdf_theme: { base_border_color: nil, quote_border_color: nil }, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: { base_border_color: nil, quote_border_color: nil }, analyze: :line).lines before ____ Let it be. ____ - EOS + END (expect lines).to be_empty end it 'should not draw left border on next page if block falls at bottom of page' do pdf = with_content_spacer 10, 689.5 do |spacer_path| - to_pdf <<~EOS, analyze: :line + to_pdf <<~END, analyze: :line image::#{spacer_path}[] ____ @@ -165,7 +165,7 @@ describe 'Asciidoctor::PDF::Converter - Quote' do ____ Words of wisdom were spoken. - EOS + END end quote_borders = pdf.lines.select {|it| it[:color] == 'EEEEEE' } @@ -178,12 +178,12 @@ describe 'Asciidoctor::PDF::Converter - Quote' do quote_background_color: 'dddddd', quote_border_color: 'aa0000', } - to_file = to_pdf_file <<~'EOS', 'quote-background-color.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'quote-background-color.pdf', pdf_theme: pdf_theme ____ Let it be. + Let it be. ____ - EOS + END (expect to_file).to visually_match 'quote-background-color.pdf' end @@ -196,25 +196,25 @@ describe 'Asciidoctor::PDF::Converter - Quote' do quote_background_color: 'dddddd', quote_padding: [12, 15], } - to_file = to_pdf_file <<~'EOS', 'quote-border-and-background-color.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'quote-border-and-background-color.pdf', pdf_theme: pdf_theme [,Paul McCartney] ____ Let it be. + Let it be. ____ - EOS + END (expect to_file).to visually_match 'quote-border-and-background-color.pdf' end it 'should apply correct padding around content' do - input = <<~'EOS' + input = <<~'END' ____ first last ____ - EOS + END pdf = to_pdf input, analyze: true lines = (to_pdf input, analyze: :line).lines @@ -231,13 +231,13 @@ describe 'Asciidoctor::PDF::Converter - Quote' do end it 'should apply correct padding around content when using base theme' do - input = <<~'EOS' + input = <<~'END' ____ first last ____ - EOS + END pdf = to_pdf input, attribute_overrides: { 'pdf-theme' => 'base' }, analyze: true lines = (to_pdf input, attribute_overrides: { 'pdf-theme' => 'base' }, analyze: :line).lines @@ -261,11 +261,11 @@ describe 'Asciidoctor::PDF::Converter - Quote' do quote_background_color: 'EEEEEE', quote_padding: [6, 10, 12, 10], } - to_file = to_pdf_file <<~EOS, 'quote-page-split.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'quote-page-split.pdf', pdf_theme: pdf_theme ____ #{(['Let it be.'] * 30).join %(\n\n)} ____ - EOS + END (expect to_file).to visually_match 'quote-page-split.pdf' end @@ -273,7 +273,7 @@ describe 'Asciidoctor::PDF::Converter - Quote' do it 'should advance to next page if block is split and caption does not fit' do quote = ['Power concedes nothing without a demand.', 'It never did and it never will.'].join %( +\n) with_content_spacer 10, 705 do |spacer_path| - input = <<~EOS + input = <<~END before image::#{spacer_path}[] @@ -282,7 +282,7 @@ describe 'Asciidoctor::PDF::Converter - Quote' do ____ #{([quote] * 18).join %(\n\n)} ____ - EOS + END pdf = to_pdf input, analyze: true advice_text = pdf.find_unique_text 'Sage advice by Frederick Douglass' @@ -295,7 +295,7 @@ describe 'Asciidoctor::PDF::Converter - Quote' do block_content = ['text of quote'] * 15 * %(\n\n) pdf_theme = { prose_margin_bottom: 12, quote_padding: [0, 0, 0, 15] } with_content_spacer 10, 690 do |spacer_path| - input = <<~EOS + input = <<~END before image::#{spacer_path}[] @@ -304,7 +304,7 @@ describe 'Asciidoctor::PDF::Converter - Quote' do ____ #{block_content} ____ - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -332,14 +332,14 @@ describe 'Asciidoctor::PDF::Converter - Quote' do quote_border_left_width: 0, } pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] ____ content + that wraps ____ - EOS + END end pages = pdf.pages @@ -350,14 +350,14 @@ describe 'Asciidoctor::PDF::Converter - Quote' do (expect last_text_y - pdf_theme[:quote_padding]).to be > 48.24 pdf = with_content_spacer 10, 692 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] ____ content + that wraps ____ - EOS + END end pages = pdf.pages diff --git a/spec/running_content_spec.rb b/spec/running_content_spec.rb index 92660f7c..fa4db14d 100644 --- a/spec/running_content_spec.rb +++ b/spec/running_content_spec.rb @@ -5,10 +5,10 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Running Content' do context 'Activation' do it 'should not attempt to add running content if document has no body' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true = Document Title :doctype: book - EOS + END text = pdf.text (expect text).to have_size 1 @@ -23,11 +23,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start adding running content to page after imported page' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true image::blue-letter.pdf[] first non-imported page - EOS + END pages = pdf.pages (expect pages).to have_size 2 @@ -41,13 +41,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should not add running content if all pages are imported' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true image::red-green-blue.pdf[page=1] image::red-green-blue.pdf[page=2] image::red-green-blue.pdf[page=3] - EOS + END pages = pdf.pages (expect pages).to have_size 3 @@ -57,7 +57,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do context 'Footer' do it 'should add running footer showing virtual page number starting at body by default' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true = Document Title :doctype: book @@ -74,7 +74,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< fourth page - EOS + END expected_page_numbers = %w(1 2 3 4) expected_x_positions = [541.009, 49.24] @@ -91,7 +91,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should add running footer by default when using base theme' do - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book @@ -104,7 +104,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< third page - EOS + END pdf = to_pdf input, pdf_theme: { extends: 'base' }, enable_footer: true, analyze: true expected_page_numbers = %w(1 2 3) @@ -163,7 +163,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should hide page number if pagenums attribute is unset in document' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true = Document Title :doctype: book :!pagenums: @@ -173,14 +173,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< second page - EOS + END (expect pdf.find_text '1').to be_empty (expect pdf.find_text '2').to be_empty end it 'should hide page number if pagenums attribute is unset via API' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pagenums' => nil }, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'pagenums' => nil }, enable_footer: true, analyze: true = Document Title :doctype: book @@ -189,7 +189,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< second page - EOS + END (expect pdf.find_text '1').to be_empty (expect pdf.find_text '2').to be_empty @@ -200,7 +200,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: %({page-number} hide me +\nrecto right), footer_verso_left_content: %({page-number} hide me +\nverso left), } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :!pagenums: @@ -210,7 +210,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< second page - EOS + END (expect pdf.find_text %r/\d+ hide me/).to be_empty (expect pdf.find_text %r/recto right/, page_number: 2).to have_size 1 @@ -218,24 +218,24 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should not add running footer if nofooter attribute is set' do - pdf = to_pdf <<~'EOS', enable_footer: false, analyze: true + pdf = to_pdf <<~'END', enable_footer: false, analyze: true = Document Title :nofooter: :doctype: book body - EOS + END (expect pdf.find_text %r/^\d+$/).to be_empty end it 'should not add running footer if height is nil' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { footer_height: nil }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { footer_height: nil }, analyze: true = Document Title :doctype: book body - EOS + END (expect pdf.find_text %r/^\d+$/).to be_empty end @@ -245,14 +245,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do extends: 'base', footer_height: 36, } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book == Beginning == End - EOS + END pagenum1_text = (pdf.find_text '1')[0] pagenum2_text = (pdf.find_text '2')[0] @@ -275,7 +275,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do header_verso_right_content: '({document-title})', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book @@ -284,7 +284,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< second page - EOS + END expected_page_numbers = %w(1 2) @@ -309,12 +309,12 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do header_verso_right_content: '({document-title})', } - pdf = to_pdf <<~'EOS', enable_footer: true, attribute_overrides: { 'noheader' => '' }, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, attribute_overrides: { 'noheader' => '' }, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book body - EOS + END (expect pdf.find_text '(Document Title)').to be_empty end @@ -322,7 +322,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do context 'Start at' do it 'should start running content at body by default' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true = Document Title :doctype: book :toc: @@ -332,7 +332,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END (expect pdf.pages).to have_size 5 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -342,7 +342,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at body when start at is after-toc and toc is not enabled' do - pdf = to_pdf <<~'EOS', pdf_theme: { running_content_start_at: 'after-toc' }, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { running_content_start_at: 'after-toc' }, enable_footer: true, analyze: true = Document Title :doctype: book @@ -351,7 +351,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END (expect pdf.pages).to have_size 4 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -361,7 +361,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at body when start at is after-toc and toc is enabled with default placement' do - pdf = to_pdf <<~'EOS', pdf_theme: { running_content_start_at: 'after-toc' }, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { running_content_start_at: 'after-toc' }, enable_footer: true, analyze: true = Document Title :doctype: book :toc: @@ -371,7 +371,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END (expect pdf.pages).to have_size 5 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -382,7 +382,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start running content after toc in body of book when start at is after-toc and macro toc is used' do filler = (1..20).map {|it| %(== #{['Filler'] * 20 * ' '} #{it}\n\ncontent) }.join %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: { running_content_start_at: 'after-toc' }, enable_footer: true, analyze: true + pdf = to_pdf <<~END, pdf_theme: { running_content_start_at: 'after-toc' }, enable_footer: true, analyze: true = Document Title :doctype: book :toc: macro @@ -396,7 +396,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Third Chapter #{filler} - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -406,7 +406,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start running content after toc in body of article with title page when start at is after-toc and macro toc is used' do filler = (1..20).map {|it| %(== #{['Filler'] * 20 * ' '} #{it}\n\ncontent) }.join %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: { running_content_start_at: 'after-toc' }, enable_footer: true, analyze: true + pdf = to_pdf <<~END, pdf_theme: { running_content_start_at: 'after-toc' }, enable_footer: true, analyze: true = Document Title :title-page: :toc: macro @@ -420,7 +420,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Third Section #{filler} - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -430,7 +430,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start running content and page numbering after toc in body when both start at keys are after-toc and macro toc is used' do filler = (1..20).map {|it| %(== #{['Filler'] * 20 * ' '} #{it}\n\ncontent) }.join %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: { running_content_start_at: 'after-toc', page_numbering_start_at: 'after-toc' }, enable_footer: true, analyze: true + pdf = to_pdf <<~END, pdf_theme: { running_content_start_at: 'after-toc', page_numbering_start_at: 'after-toc' }, enable_footer: true, analyze: true = Document Title :doctype: book :toc: macro @@ -444,7 +444,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Third Chapter #{filler} - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -453,7 +453,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at title page if running_content_start_at key is title' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'title' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'title' }, analyze: true = Document Title :doctype: book :toc: @@ -463,7 +463,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -472,7 +472,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at title page if running_content_start_at key is title and document has front cover' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'title' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'title' }, analyze: true = Document Title :doctype: book :toc: @@ -483,7 +483,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END (expect pdf.find_text page_number: 1).to be_empty pgnum_labels = (2.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -493,7 +493,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at toc page if running_content_start_at key is title and title page is disabled' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'title' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'title' }, analyze: true = Document Title :doctype: book :notitle: @@ -504,7 +504,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -513,7 +513,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at body if running_content_start_at key is title and title page and toc are disabled' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'title' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'title' }, analyze: true = Document Title :doctype: book :notitle: @@ -523,7 +523,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -532,7 +532,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at toc page if running_content_start_at key is toc' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'toc' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'toc' }, analyze: true = Document Title :doctype: book :toc: @@ -542,7 +542,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -551,7 +551,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at toc page if running_content_start_at key is toc and title page is disabled' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'toc' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'toc' }, analyze: true = Document Title :doctype: book :notitle: @@ -562,7 +562,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -571,7 +571,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at body if running_content_start_at key is toc and toc is disabled' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'toc' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'toc' }, analyze: true = Document Title :doctype: book @@ -580,7 +580,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -589,7 +589,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at body if running_content_start_at key is after-toc and toc is disabled' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'after-toc' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'after-toc' }, analyze: true = Document Title :doctype: book @@ -598,7 +598,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -607,7 +607,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start running content at specified page of body of book if running_content_start_at is an integer' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 3 }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 3 }, analyze: true = Book Title :doctype: book :toc: @@ -623,7 +623,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter One content - EOS + END (expect pdf.pages).to have_size 5 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -637,7 +637,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do running_content_start_at: 3, footer_font_color: '0000FF', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Article Title page one @@ -649,7 +649,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< page three - EOS + END (expect pdf.pages).to have_size 3 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -659,7 +659,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start page numbering at body by default' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true = Book Title :doctype: book :toc: @@ -675,7 +675,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter One content - EOS + END (expect pdf.pages).to have_size 5 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -685,7 +685,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start page numbering at body when start at is after-toc and toc is enabled' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: 'after-toc' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: 'after-toc' }, analyze: true = Book Title :doctype: book :toc: @@ -701,7 +701,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter One content - EOS + END (expect pdf.pages).to have_size 5 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -711,7 +711,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start page numbering at body when start at is after-toc and toc is not enabled' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: 'after-toc' }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: 'after-toc' }, analyze: true = Book Title :doctype: book @@ -726,7 +726,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter One content - EOS + END (expect pdf.pages).to have_size 4 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -737,7 +737,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering after toc in body of book when start at is after-toc and toc macro is used' do filler = (1..20).map {|it| %(== #{['Filler'] * 20 * ' '} #{it}\n\ncontent) }.join %(\n\n) - pdf = to_pdf <<~EOS, enable_footer: true, pdf_theme: { page_numbering_start_at: 'after-toc' }, analyze: true + pdf = to_pdf <<~END, enable_footer: true, pdf_theme: { page_numbering_start_at: 'after-toc' }, analyze: true = Book Title :doctype: book :toc: macro @@ -757,7 +757,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do content #{filler} - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -767,7 +767,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering after toc in body of article with title page when start at is after-toc and toc macro is used' do filler = (1..20).map {|it| %(== #{['Filler'] * 20 * ' '} #{it}\n\ncontent) }.join %(\n\n) - pdf = to_pdf <<~EOS, enable_footer: true, pdf_theme: { page_numbering_start_at: 'after-toc' }, analyze: true + pdf = to_pdf <<~END, enable_footer: true, pdf_theme: { page_numbering_start_at: 'after-toc' }, analyze: true = Document Title :title-page: :toc: macro @@ -787,7 +787,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do content #{filler} - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << ((pdf.find_text page_number: page_number, y: 14.263)[-1] || {})[:string] @@ -797,7 +797,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering and running content at first page of article body if start-at value is body or 1' do [1, 'body'].each do |start_at| - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: start_at, running_content_start_at: start_at }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: start_at, running_content_start_at: start_at }, analyze: true = Article Title page one @@ -809,7 +809,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< page three - EOS + END (expect pdf.pages).to have_size 3 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -821,7 +821,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering and running content at first page of book body if start-at value is body or 1' do [1, 'body'].each do |start_at| - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: start_at, running_content_start_at: start_at }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: start_at, running_content_start_at: start_at }, analyze: true = Book Title :doctype: book @@ -836,7 +836,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter One content - EOS + END (expect pdf.pages).to have_size 4 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -847,7 +847,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start page numbering and running content on page before first chapter in prepress book if start-at is 0' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: 0, running_content_start_at: 0 }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: 0, running_content_start_at: 0 }, analyze: true = Book Title :doctype: book :media: prepress @@ -855,7 +855,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter One content - EOS + END (expect pdf.pages).to have_size 3 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -865,7 +865,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start page numbering and running content at specified page of body' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: 3, running_content_start_at: 3 }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: 3, running_content_start_at: 3 }, analyze: true = Book Title :doctype: book :toc: @@ -881,7 +881,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter One content - EOS + END (expect pdf.pages).to have_size 5 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -896,7 +896,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do page_numbering_start_at: 3, footer_font_color: '0000FF', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Article Title page one @@ -908,7 +908,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< page three - EOS + END (expect pdf.pages).to have_size 3 pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| @@ -920,7 +920,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do context 'Page numbering' do it 'should start page numbering at body if title page and toc are disabled' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true = Document Title :doctype: book :notitle: @@ -930,7 +930,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -940,7 +940,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering at body if title page is disabled and toc is enabled' do pdf_theme = { running_content_start_at: 'toc' } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :notitle: @@ -951,7 +951,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -960,7 +960,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start page numbering at cover page of article if page_numbering_start_at is cover' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: 'cover' } + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: 'cover' } = Document Title :front-cover-image: image:tux.png[] @@ -969,14 +969,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Section == Third Section - EOS + END page_labels = get_page_labels pdf (expect page_labels).to eql %w(1 2) end it 'should start page numbering at cover page of book if page_numbering_start_at is cover' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: 'cover' } + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: 'cover' } = Document Title :doctype: book :front-cover-image: image:tux.png[] @@ -987,14 +987,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END page_labels = get_page_labels pdf (expect page_labels).to eql %w(1 2 3 4 5 6) end it 'should start page numbering at title page of book if page_numbering_start_at is cover and document has no cover' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: 'cover' } + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: 'cover' } = Document Title :doctype: book :toc: @@ -1004,14 +1004,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END page_labels = get_page_labels pdf (expect page_labels).to eql %w(1 2 3 4 5) end it 'should start page numbering at body of article if page_numbering_start_at is cover and document has no cover' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { page_numbering_start_at: 'cover' } + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { page_numbering_start_at: 'cover' } = Document Title == First Section @@ -1019,7 +1019,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Section == Third Section - EOS + END page_labels = get_page_labels pdf (expect page_labels).to eql %w(1) @@ -1028,7 +1028,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering at title page if page_numbering_start_at is title' do pdf_theme = { page_numbering_start_at: 'title', running_content_start_at: 'title' } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :toc: @@ -1038,7 +1038,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -1049,7 +1049,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering at toc page if page_numbering_start_at is title and title page is disabled' do pdf_theme = { page_numbering_start_at: 'title', running_content_start_at: 'title' } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :notitle: @@ -1060,7 +1060,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -1071,7 +1071,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering at body if page_numbering_start_at is title and title page and toc are disabled' do pdf_theme = { page_numbering_start_at: 'title', running_content_start_at: 'title' } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :notitle: @@ -1081,7 +1081,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -1092,7 +1092,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering at toc page if page_numbering_start_at is toc' do pdf_theme = { page_numbering_start_at: 'toc', running_content_start_at: 'title' } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :toc: @@ -1102,7 +1102,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -1113,7 +1113,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering at body if page_numbering_start_at is toc and toc is disabled' do pdf_theme = { page_numbering_start_at: 'toc', running_content_start_at: 'title' } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book @@ -1122,7 +1122,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -1133,7 +1133,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should start page numbering at toc page if page_numbering_start_at is toc and title page is disabled' do pdf_theme = { page_numbering_start_at: 'toc', running_content_start_at: 'title' } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :notitle: @@ -1144,7 +1144,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Second Chapter == Third Chapter - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -1153,7 +1153,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should start page numbering at specified page of body of book if page_numbering_start_at is an integer' do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: { running_content_start_at: 'title', page_numbering_start_at: 3 }, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: { running_content_start_at: 'title', page_numbering_start_at: 3 }, analyze: true = Book Title :doctype: book :toc: @@ -1172,7 +1172,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do [index] == Index - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, y: 14.263)[-1][:string] @@ -1189,7 +1189,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_font_color: '0000FF', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Article Title page one @@ -1201,7 +1201,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< page three - EOS + END pgnum_labels = (1.upto pdf.pages.size).each_with_object [] do |page_number, accum| accum << (pdf.find_text page_number: page_number, font_color: '0000FF')[0][:string] @@ -1218,7 +1218,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_font_color: 'AA0000', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :toc: @@ -1226,7 +1226,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Beginning == End - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 2 @@ -1245,7 +1245,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_font_color: 'AA0000', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :toc: @@ -1253,7 +1253,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Beginning == End - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 3 @@ -1281,7 +1281,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_text_transform: 'uppercase', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title Preamble text. @@ -1297,7 +1297,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< == End - EOS + END (expect pdf.find_text font_size: 7.5, page_number: 1, string: '1', font_color: '00FF00').to have_size 1 (expect pdf.find_text font_size: 7.5, page_number: 2, string: 'BEGINNING', font_color: 'FF0000').to have_size 1 @@ -1309,7 +1309,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should expand footer padding from single value' do - pdf = to_pdf <<~'EOS', enable_footer: true, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, analyze: true = Document Title first page @@ -1317,7 +1317,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< second page - EOS + END p2_text = pdf.find_text page_number: 2 (expect p2_text[1][:x]).to be > p2_text[0][:x] @@ -1334,7 +1334,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do header_verso_left_content: '{page-number}', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title first page @@ -1342,7 +1342,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< second page - EOS + END p2_text = pdf.find_text page_number: 2 (expect p2_text[1][:x]).to be > p2_text[0][:x] @@ -1358,13 +1358,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_center_content: '{page-number}', footer_verso_center_content: '{page-number}', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true first page <<< second page - EOS + END footer_texts = pdf.find_text font_color: 'FF0000' (expect footer_texts).to have_size 2 @@ -1384,7 +1384,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do header_verso_left_content: 99, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title first page @@ -1392,7 +1392,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< second page - EOS + END p2_text = pdf.find_text page_number: 2 (expect p2_text[1][:x]).to be > p2_text[0][:x] @@ -1408,12 +1408,12 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_vertical_align: 'middle', } - to_file = to_pdf_file <<~'EOS', 'running-content-negative-padding.pdf', pdf_theme: pdf_theme, enable_footer: true + to_file = to_pdf_file <<~'END', 'running-content-negative-padding.pdf', pdf_theme: pdf_theme, enable_footer: true text left [.text-right] text right - EOS + END (expect to_file).to visually_match 'running-content-negative-padding.pdf' end @@ -1506,13 +1506,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'footer: *bold* _italic_ `mono`', footer_verso_left_content: 'https://asciidoctor.org[Asciidoctor] AsciiDoc -> PDF', } - input = <<~'EOS' + input = <<~'END' page 1 <<< page 2 - EOS + END pdf = to_pdf input, enable_footer: true, pdf_theme: pdf_theme, analyze: true @@ -1543,13 +1543,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: 'offset:{page-number}[2]', } - input = <<~'EOS' + input = <<~'END' first <<< last - EOS + END extension_registry = Asciidoctor::Extensions.create do inline_macro :offset do @@ -1663,11 +1663,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_vertical_align: 'middle', } - to_file = to_pdf_file <<~'EOS', 'running-content-background-image.pdf', enable_footer: true, pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'running-content-background-image.pdf', enable_footer: true, pdf_theme: pdf_theme :pdf-page-size: Letter Hello, World! - EOS + END (expect to_file).to visually_match 'running-content-background-image.pdf' end @@ -1690,11 +1690,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_vertical_align: 'middle', } - to_file = to_pdf_file <<~'EOS', 'running-content-background-image-full.pdf', enable_footer: true, pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'running-content-background-image-full.pdf', enable_footer: true, pdf_theme: pdf_theme :pdf-page-size: Letter Hello, World! - EOS + END (expect to_file).to visually_match 'running-content-background-image-full.pdf' end @@ -1709,10 +1709,10 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do } (expect do - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme Hello, World! - EOS + END images = get_images pdf, 1 (expect images).to be_empty @@ -1731,13 +1731,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_center_content: '', } - to_file = to_pdf_file <<~'EOS', 'running-content-background-image-per-side.pdf', pdf_theme: pdf_theme, enable_footer: true + to_file = to_pdf_file <<~'END', 'running-content-background-image-per-side.pdf', pdf_theme: pdf_theme, enable_footer: true recto <<< verso - EOS + END (expect to_file).to visually_match 'running-content-background-image-per-side.pdf' end @@ -1745,7 +1745,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do it 'should be able to reference page layout in background image path', visual: true do pdf_theme = { __dir__: fixtures_dir, footer_background_image: 'image:square-{page-layout}.svg[]' } - to_file = to_pdf_file <<~'EOS', 'running-content-background-image-per-layout.pdf', pdf_theme: pdf_theme, enable_footer: true + to_file = to_pdf_file <<~'END', 'running-content-background-image-per-layout.pdf', pdf_theme: pdf_theme, enable_footer: true page 1 [.landscape] @@ -1757,7 +1757,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< page 3 - EOS + END (expect to_file).to visually_match 'running-content-background-image-per-layout.pdf' end @@ -1780,13 +1780,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_content: 'F', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true page one <<< page two - EOS + END page_width = (get_page_size pdf)[0] p1_header_text = (pdf.find_text 'H', page_number: 1)[0] @@ -1814,13 +1814,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_content: 'F', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true page one <<< page two - EOS + END page_width = (get_page_size pdf)[0] p1_header_text = (pdf.find_text 'H', page_number: 1)[0] @@ -1852,13 +1852,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_content: 'F', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true page one <<< page two - EOS + END page_width = (get_page_size pdf)[0] p1_header_text = (pdf.find_text 'H', page_number: 1)[0] @@ -1890,13 +1890,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_content: 'F', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true page one <<< page two - EOS + END page_width = (get_page_size pdf)[0] p1_header_text = (pdf.find_text 'H', page_number: 1)[0] @@ -1927,13 +1927,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_margin: [0, 0, 6], } - to_file = to_pdf_file <<~'EOS', 'running-content-end-margin.pdf', enable_footer: true, pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'running-content-end-margin.pdf', enable_footer: true, pdf_theme: pdf_theme page one <<< page two - EOS + END (expect to_file).to visually_match 'running-content-end-margin.pdf' end @@ -1954,13 +1954,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do header_verso_right_content: %(image:#{fixture_file 'square.png'}[fit=contain]), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :image page one <<< page two - EOS + END recto_image, verso_image = pdf.images (expect recto_image[:width]).to eql 36.0 @@ -1993,11 +1993,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'right', } - to_file = to_pdf_file <<~'EOS', 'running-content-column-rule.pdf', enable_footer: true, pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'running-content-column-rule.pdf', enable_footer: true, pdf_theme: pdf_theme = Document Title content - EOS + END (expect to_file).to visually_match 'running-content-column-rule.pdf' end @@ -2016,11 +2016,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'right', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: :line = Document Title content - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -2042,11 +2042,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'right', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: :line = Document Title content - EOS + END (expect pdf.lines).to have_size 0 end @@ -2063,11 +2063,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'right', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: :line = Document Title content - EOS + END (expect pdf.lines).to have_size 0 end @@ -2090,11 +2090,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'right', } - to_file = to_pdf_file <<~'EOS', 'running-content-no-column-rule.pdf', enable_footer: true, pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'running-content-no-column-rule.pdf', enable_footer: true, pdf_theme: pdf_theme = Document Title content - EOS + END (expect to_file).to visually_match 'running-content-no-column-rule.pdf' end @@ -2109,11 +2109,11 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'recto', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true :pdf-folio-placement: virtual-inverted content - EOS + END footer_text = pdf.find_text font_size: 9 (expect footer_text).to have_size 2 @@ -2129,14 +2129,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'recto', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :pdf-folio-placement: physical-inverted :media: print :doctype: book content - EOS + END footer_text = pdf.find_text font_size: 9 (expect footer_text).to have_size 2 @@ -2153,7 +2153,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do } { 'physical' => 'verso', 'physical-inverted' => 'recto' }.each do |placement, side| - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :pdf-folio-placement: #{placement} :doctype: book @@ -2162,7 +2162,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter #{40.times.map {|it| %(=== Section #{it + 1}) }.join %(\n\n)} - EOS + END (expect pdf.find_text page_number: 4, string: 'Chapter').to have_size 1 body_start_footer_text = pdf.find_text font_size: 9, page_number: 4 @@ -2179,13 +2179,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'recto', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :media: prepress :doctype: book content - EOS + END footer_text = pdf.find_text font_size: 9 (expect footer_text).to have_size 2 @@ -2201,14 +2201,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'recto', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :media: prepress :pdf-folio-placement: physical-inverted :doctype: book content - EOS + END footer_text = pdf.find_text font_size: 9 (expect footer_text).to have_size 2 @@ -2227,7 +2227,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: nil, } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true portrait [.landscape] @@ -2238,7 +2238,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do [.portrait] portrait - EOS + END (expect pdf.text.size).to be 5 pdf.text.each do |text| @@ -2255,7 +2255,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_content: '{section-title}', } - to_file = to_pdf_file <<~EOS, 'running-content-alt-layouts.pdf', enable_footer: true, pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'running-content-alt-layouts.pdf', enable_footer: true, pdf_theme: pdf_theme = Alternating Page Layouts This document demonstrates that the running content is adjusted to fit the page layout as the page layout alternates. @@ -2275,7 +2275,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Portrait Page #{filler} - EOS + END (expect to_file).to visually_match 'running-content-alt-layouts.pdf' end @@ -2289,13 +2289,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do } (expect do - pdf = to_pdf <<~'EOS', enable_footer: true, attribute_overrides: { 'doctitle' => 'The Chronicles of <Foo> & ¦' }, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, attribute_overrides: { 'doctitle' => 'The Chronicles of <Foo> & ¦' }, pdf_theme: pdf_theme, analyze: true :doctype: book == Chapter 1 content - EOS + END running_text = pdf.find_text %(The Chronicles of <Foo> & \u00a6) (expect running_text).to have_size 1 @@ -2310,14 +2310,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_content: '[{document-subtitle}]', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title: Subtitle :doctype: book == Beginning == End - EOS + END [2, 3].each do |pgnum| main_title_text = (pdf.find_text page_number: pgnum, string: '(Document Title)')[0] @@ -2334,13 +2334,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: '({document-title})', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true :doctype: book == Beginning == End - EOS + END [1, 2].each do |pgnum| doctitle_text = pdf.find_unique_text page_number: pgnum, font_color: 'CCCCCC', string: '(Untitled)' @@ -2357,7 +2357,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_content: '[{part-title}|{chapter-title}|{section-title}]', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book @@ -2376,7 +2376,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do = Part II == Chapter C - EOS + END footer_y = (pdf.find_text 'FOOTER')[0][:y] titles_by_page = (pdf.find_text y: footer_y).each_with_object({}) do |it, accum| @@ -2397,7 +2397,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: '{part-title} ({page-number})', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :doctype: book @@ -2413,7 +2413,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do = Installation Describe installation procedure. - EOS + END footer_texts = pdf.find_text page_number: 5, font_color: '0000FF' (expect footer_texts).to have_size 1 @@ -2431,7 +2431,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: %(({chapter-numeral})\n{chapter-title} | {page-number}), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :doctype: book :sectnums: @@ -2449,7 +2449,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == B content - EOS + END footer_texts = pdf.find_text font_color: '0000FF' (expect footer_texts).to have_size 4 @@ -2465,7 +2465,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: %(({chapter-numeral})\n{chapter-title} | {page-number}), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :doctype: book @@ -2482,7 +2482,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == B content - EOS + END footer_texts = pdf.find_text font_color: '0000FF' (expect footer_texts).to have_size 4 @@ -2498,7 +2498,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: %(P{part-numeral} |\n{page-number}), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :doctype: book :partnums: @@ -2516,7 +2516,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Moar Chapter content - EOS + END footer_texts = pdf.find_text font_color: '0000FF' (expect footer_texts).to have_size 5 @@ -2532,7 +2532,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: %(P{part-numeral} |\n{page-number}), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :doctype: book @@ -2541,7 +2541,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter content - EOS + END footer_texts = pdf.find_text font_color: '0000FF' (expect footer_texts).to have_size 2 @@ -2555,7 +2555,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: '[{section-title}]', footer_verso_left_content: '[{section-title}]', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title First page of preamble. @@ -2565,7 +2565,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do Second page of preamble. == Section Title - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 2 @@ -2579,13 +2579,13 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: '[{section-title}]', footer_verso_left_content: '[{section-title}]', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true first page <<< last page - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 2 @@ -2599,7 +2599,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: '{chapter-title}', footer_verso_left_content: '{chapter-title}', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :preface-title: PREFACE @@ -2611,7 +2611,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do Second page of preface. == First Chapter - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 3 @@ -2629,7 +2629,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: '{chapter-title}', footer_verso_left_content: '{chapter-title}', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :notitle: @@ -2641,7 +2641,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do Second page of preface. == First Chapter - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 3 @@ -2660,7 +2660,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: '{page-number} | {chapter-title}', footer_verso_left_content: '{chapter-title} | {page-number}', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :toc: @@ -2669,7 +2669,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Beginning == End - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 3 @@ -2685,7 +2685,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: '{page-number} | {chapter-title}', footer_verso_left_content: '{chapter-title} | {page-number}', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :toc: macro @@ -2696,7 +2696,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do toc::[] == End - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 3 @@ -2714,7 +2714,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: '{page-number} | {section-title}', footer_verso_left_content: '{section-title} | {page-number}', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :toc: macro :toc-title: Contents @@ -2728,7 +2728,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< == End - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 3 @@ -2746,7 +2746,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: '{page-number} | {section-title}', footer_verso_left_content: '{section-title} | {page-number}', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :toc: macro :toc-title: Contents @@ -2758,7 +2758,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< == End - EOS + END footer_texts = pdf.find_text font_color: 'AA0000' (expect footer_texts).to have_size 2 @@ -2769,7 +2769,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should assign section titles down to sectlevels defined in theme' do - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book @@ -2788,7 +2788,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do ===== Level 4 == B - EOS + END { nil => ['A', 'Level 2', 'Level 2', 'Level 2', 'B'], @@ -2816,7 +2816,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: '{chapter-title}', } - pdf = to_pdf <<~'EOS', enable_footer: true, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', enable_footer: true, pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :toc: @@ -2826,7 +2826,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do == Chapter 1 content - EOS + END expected_running_content_by_page = { 1 => 'Document Title', 2 => 'Table of Contents', 3 => 'Preface', 4 => 'Chapter 1' } running_content_by_page = (pdf.find_text y: 14.263).each_with_object({}) {|text, accum| accum[text[:page_number]] = text[:string] } @@ -2834,14 +2834,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do end it 'should allow style of title-related attributes to be customized using the title-style key' do - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book :sectnums: :notitle: == Beginning - EOS + END pdf_theme = { footer_recto_left_content: '[{chapter-title}]', @@ -2981,14 +2981,14 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_left_content: nil, } - input = <<~'EOS' + input = <<~'END' portrait [page-layout=landscape] <<< landscape - EOS + END rects = (to_pdf input, pdf_theme: pdf_theme, enable_footer: true, analyze: :rect).rectangles (expect rects).to have_size 2 (expect rects[0][:page_number]).to eql 1 @@ -3154,7 +3154,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_verso_right_content: %(image:#{fixture_file 'tux.png'}[pdfwidth=100px]), } - to_file = to_pdf_file <<~'EOS', 'running-content-image-overrun.pdf', enable_footer: true, pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'running-content-image-overrun.pdf', enable_footer: true, pdf_theme: pdf_theme = Article Title content @@ -3162,7 +3162,7 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do <<< content - EOS + END (expect to_file).to visually_match 'running-content-image-overrun.pdf' end @@ -3178,20 +3178,20 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do 'pdf-themesdir' => (File.dirname fixtures_dir), }, ].each_with_index do |attribute_overrides, idx| - to_file = to_pdf_file <<~'EOS', %(running-content-image-from-themesdir-#{idx}.pdf), attribute_overrides: attribute_overrides + to_file = to_pdf_file <<~'END', %(running-content-image-from-themesdir-#{idx}.pdf), attribute_overrides: attribute_overrides [.text-center] content - EOS + END (expect to_file).to visually_match 'running-content-image.pdf' end end it 'should resolve image target relative to theme file when themesdir is not set', visual: true do attribute_overrides = { 'pdf-theme' => (fixture_file 'running-header-theme.yml', relative: true) } - to_file = to_pdf_file <<~'EOS', 'running-content-image-from-theme.pdf', attribute_overrides: attribute_overrides + to_file = to_pdf_file <<~'END', 'running-content-image-from-theme.pdf', attribute_overrides: attribute_overrides [.text-center] content - EOS + END (expect to_file).to visually_match 'running-content-image.pdf' end @@ -3394,9 +3394,9 @@ describe 'Asciidoctor::PDF::Converter - Running Content' do footer_recto_right_content: 'image:svg-with-local-image.svg[fit=contain]', footer_verso_left_content: 'image:svg-with-local-image.svg[fit=contain]', } - to_file = to_pdf_file <<~'EOS', 'running-content-svg-with-local-image.pdf', enable_footer: true, pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'running-content-svg-with-local-image.pdf', enable_footer: true, pdf_theme: pdf_theme body - EOS + END (expect to_file).to visually_match 'running-content-svg-with-local-image.pdf' end diff --git a/spec/section_spec.rb b/spec/section_spec.rb index 6df058f8..d26d0319 100644 --- a/spec/section_spec.rb +++ b/spec/section_spec.rb @@ -4,7 +4,7 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Section' do it 'should apply font size according to section level' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title == Level 1 @@ -14,7 +14,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do section content == Back To Level 1 - EOS + END expected_text = [ ['Document Title', 27], @@ -27,7 +27,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should render section titles in bold by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title == Level 1 @@ -37,7 +37,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do section content == Back To Level 1 - EOS + END expected_text = [ ['Document Title', 'NotoSerif-Bold'], @@ -50,11 +50,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should apply text formatting in section title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true == Section Title with Some _Oomph_ text - EOS + END (expect pdf.lines[0]).to eql 'Section Title with Some Oomph' text_with_emphasis = pdf.find_unique_text 'Oomph' @@ -63,7 +63,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should ignore hard line break at end of section title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true == Reference Title reference text @@ -71,7 +71,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Section Title + section text - EOS + END expected_gap = ((pdf.find_unique_text 'Reference Title')[:y] - (pdf.find_unique_text 'reference text')[:y]).round 4 actual_gap = ((pdf.find_unique_text 'Section Title')[:y] - (pdf.find_unique_text 'section text')[:y]).round 4 @@ -82,13 +82,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do pdf_theme = { heading_font_family: 'Helvetica', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title == Helvetica-Bold Noto Serif - EOS + END heading_text = pdf.find_unique_text 'Helvetica-Bold' (expect heading_text[:font_name]).to eql 'Helvetica-Bold' @@ -101,13 +101,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_font_family: 'Helvetica', heading_h3_font_family: 'Times-Roman', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title == Helvetica-Bold === Times-Bold - EOS + END h2_text = pdf.find_unique_text 'Helvetica-Bold' (expect h2_text[:font_name]).to eql 'Helvetica-Bold' @@ -116,11 +116,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should allow theme to set font kerning for headings' do - input = <<~'EOS' + input = <<~'END' == Wave__|__ content - EOS + END pdf_theme = { heading_text_transform: 'uppercase' } pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -140,11 +140,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_h3_font_size: 22, heading_h3_font_kerning: 'none', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true == Wave__|__ === Wave__|__ - EOS + END kerning_positions = (pdf.find_text '|').map {|it| it[:x] } @@ -152,9 +152,9 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should add text formatting styles to styles defined in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_font_style: 'bold' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_font_style: 'bold' }, analyze: true == Get Started _Quickly_ - EOS + END text = pdf.text (expect text).to have_size 2 @@ -163,9 +163,9 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should add text formatting styles to styles defined in theme for specific level' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_font_style: nil, heading_h2_font_style: 'bold' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_font_style: nil, heading_h2_font_style: 'bold' }, analyze: true == Get Started _Quickly_ - EOS + END text = pdf.text (expect text).to have_size 2 @@ -174,7 +174,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should allow theme to align all section titles' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_text_align: 'center' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_text_align: 'center' }, analyze: true == Drill content @@ -184,7 +184,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do content ==== Deep - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 content_left_margin = (pdf.find_text 'content')[0][:x] @@ -200,7 +200,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should allow theme to align section title for specific level' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_h1_text_align: 'center' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_h1_text_align: 'center' }, analyze: true = Document Title :notitle: :doctype: book @@ -216,7 +216,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Last Chapter content - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 left_content_margin = (pdf.find_text 'content')[0][:x] @@ -234,7 +234,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_h2_font_size: 20, heading_h3_font_size: 20, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true before == Drill @@ -244,7 +244,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do === Down content - EOS + END drill_title_text = pdf.find_unique_text 'Drill' down_title_text = pdf.find_unique_text 'Down' @@ -261,7 +261,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_h3_border_color: 'DDDDDD', } - input = <<~'EOS' + input = <<~'END' = Document Title == Section Level 1 @@ -271,7 +271,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do === Section Level 2 content - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -300,11 +300,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_h2_border_color: 'EEEEEE', } - input = <<~'EOS' + input = <<~'END' == Section Title content - EOS + END pdf_a_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines pdf_b_lines = (to_pdf input, pdf_theme: (pdf_theme.merge heading_h2_padding: [0, 0, 5, 10]), analyze: :line).lines @@ -321,11 +321,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_h2_border_width: [1, 0, 0, 0], heading_h2_border_color: 'EEEEEE', } - input = <<~'EOS' + input = <<~'END' == Section Title content - EOS + END pdf_a_lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines pdf_a = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -344,13 +344,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_h2_border_color: '0000FF', } pdf = with_content_spacer 10, 700 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: :line + to_pdf <<~END, pdf_theme: pdf_theme, analyze: :line image::#{spacer_path}[] == Pushed to Next Page content - EOS + END end heading_lines = pdf.lines.select {|it| it[:color] == '0000FF' } @@ -360,9 +360,9 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not partition section title by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true == Title: Subtitle - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -370,11 +370,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should partition section title if title-separator document attribute is set and present in title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :title-separator: : == The Title: The Subtitle - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -387,10 +387,10 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should partition section title if separator block attribute is set and present in title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [separator=:] == The Title: The Subtitle - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -403,11 +403,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should partition title on last occurrence of separator' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :title-separator: : == Foo: Bar: Baz - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -415,10 +415,10 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not partition section title if separator is not followed by space' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [separator=:] == Title:Subtitle - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -426,12 +426,12 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not partition section title if separator block attribute is empty' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :title-separator: : [separator=] == Title: Subtitle - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -460,7 +460,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_h1_margin_page_top: 100, heading_h2_font_size: 20, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book @@ -475,7 +475,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Last Chapter content - EOS + END part_a_text = pdf.find_unique_text 'Part A' first_chapter_text = pdf.find_unique_text 'First Chapter' @@ -491,7 +491,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do heading_h3_margin_top: 5, heading_h3_margin_bottom: 5, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true preamble == Level 1 @@ -501,7 +501,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do === Level 2 content for level 2 - EOS + END l1_title_text = pdf.find_unique_text 'Level 1' l1_content_text = pdf.find_unique_text 'content for level 1' @@ -513,7 +513,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should uppercase section titles if text_transform key in theme is set to uppercase' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true = Document Title == Beginning @@ -521,7 +521,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Middle == End - EOS + END pdf.text.each do |text| (expect text[:string]).to eql text[:string].upcase @@ -529,9 +529,9 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not alter character references when text transform is uppercase' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true == <Tom & Jerry> - EOS + END (expect pdf.text[0][:string]).to eql '<TOM & JERRY>' end @@ -571,11 +571,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should be able to set text decoration properties per heading level' do pdf_theme = { heading_h3_text_decoration: 'underline', heading_h3_text_decoration_color: 'cccccc', heading_h3_text_decoration_width: 0.5 } - input = <<~'EOS' + input = <<~'END' == Plain Title === Decorated Title - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :line lines = pdf.lines (expect lines).to have_size 1 @@ -590,86 +590,86 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should support hexadecimal character reference in section title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true == µServices - EOS + END (expect pdf.text[0][:string]).to eql %(\u00b5Services) end it 'should not alter HTML tags when text transform is uppercase' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true == _Quick_ Start - EOS + END (expect pdf.text[0][:string]).to eql 'QUICK' end it 'should transform non-ASCII letters when text transform is uppercase' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true == über étudier - EOS + END (expect pdf.lines[0]).to eql 'ÜBER ÉTUDIER' end it 'should ignore letters in hexadecimal character reference in section title when transforming to uppercase' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true == µServices - EOS + END (expect pdf.text[0][:string]).to eql %(\u00b5SERVICES) end it 'should not apply text transform if value of text_transform key is none' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_text_transform: 'uppercase', heading_h3_text_transform: 'none' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_text_transform: 'uppercase', heading_h3_text_transform: 'none' }, analyze: true == Uppercase === Title Case - EOS + END (expect pdf.find_text 'UPPERCASE').to have_size 1 (expect pdf.find_text 'Title Case').to have_size 1 end it 'should not crash if menu macro is used in section title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :experimental: == The menu:File[] menu Describe the file menu. - EOS + END (expect pdf.lines[0]).to eql 'The File menu' end it 'should not crash if kbd macro is used in section title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :experimental: == The magic of kbd:[Ctrl,p] Describe the magic of paste. - EOS + END (expect pdf.lines[0]).to eql %(The magic of Ctrl \u202f+\u202f p) end it 'should not crash if btn macro is used in section title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :experimental: == The btn:[Save] button Describe the save button. - EOS + END (expect pdf.lines[0]).to eql %(The [\u2009Save\u2009] button) end it 'should add part signifier and part number to part if part numbering is enabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Book Title :doctype: book :sectnums: @@ -682,14 +682,14 @@ describe 'Asciidoctor::PDF::Converter - Section' do = B == Bar - EOS + END titles = (pdf.find_text font_size: 27).map {|it| it[:string] }.reject {|it| it == 'Book Title' } (expect titles).to eql ['Part I: A', 'Part II: B'] end it 'should use specified part signifier if part numbering is enabled and part-signifier attribute is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Book Title :doctype: book :sectnums: @@ -703,7 +703,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do = B == Bar - EOS + END titles = (pdf.find_text font_size: 27).map {|it| it[:string] }.reject {|it| it == 'Book Title' } (expect titles).to eql ['P I: A', 'P II: B'] @@ -711,7 +711,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should not add part signifier to part title if partnums is enabled and part-signifier attribute is unset or empty' do %w(!part-signifier part-signifier).each do |attr_name| - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Book Title :doctype: book :sectnums: @@ -725,7 +725,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do = Z == The End - EOS + END part_titles = (pdf.find_text font_size: 27).map {|it| it[:string] }.reject {|it| it == 'Book Title' } (expect part_titles).to eql ['I: A', 'II: Z'] @@ -733,7 +733,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should add default chapter signifier to chapter title if section numbering is enabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Book Title :doctype: book :sectnums: @@ -741,7 +741,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == The Beginning == The End - EOS + END chapter_titles = (pdf.find_text font_size: 22).map {|it| it[:string] } (expect chapter_titles).to eql ['Chapter 1. The Beginning', 'Chapter 2. The End'] @@ -749,7 +749,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should add chapter signifier to chapter title if section numbering is enabled and chapter-signifier attribute is set' do { 'chapter-signifier' => 'Ch' }.each do |attr_name, attr_val| - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Book Title :doctype: book :sectnums: @@ -758,7 +758,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == The Beginning == The End - EOS + END chapter_titles = (pdf.find_text font_size: 22).map {|it| it[:string] } (expect chapter_titles).to eql ['Ch 1. The Beginning', 'Ch 2. The End'] @@ -767,7 +767,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should add chapter signifier to chapter title if section numbering and toc are enabled and chapter-signifier attribute is set' do { 'chapter-signifier' => 'Ch' }.each do |attr_name, attr_val| - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Book Title :doctype: book :sectnums: @@ -777,7 +777,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == The Beginning == The End - EOS + END chapter_titles = (pdf.find_text font_size: 22).select {|it| it[:page_number] >= 3 }.map {|it| it[:string] } (expect chapter_titles).to eql ['Ch 1. The Beginning', 'Ch 2. The End'] @@ -786,7 +786,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should not add chapter signifier to chapter title if sectnums is enabled and chapter-signifier attribute is unset or empty' do %w(!chapter-signifier chapter-signifier).each do |attr_name| - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Book Title :doctype: book :sectnums: @@ -795,7 +795,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == The Beginning == The End - EOS + END chapter_titles = (pdf.find_text font_size: 22).map {|it| it[:string] } (expect chapter_titles).to eql ['1. The Beginning', '2. The End'] @@ -803,7 +803,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should number sections in article when sectnums attribute is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :sectnums: @@ -816,14 +816,14 @@ describe 'Asciidoctor::PDF::Converter - Section' do === More Detail == End - EOS + END (expect pdf.find_unique_text '1. Beginning', font_size: 22).not_to be_nil (expect pdf.find_unique_text '2.1. Detail', font_size: 18).not_to be_nil end it 'should number subsection of appendix based on appendix letter' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Book Title :doctype: book :sectnums: @@ -840,13 +840,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do === Appendix Subsection content - EOS + END (expect pdf.lines).to include 'A.1. Appendix Subsection' end it 'should treat level-0 special section as chapter in multipart book' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_h2_font_color: 'AA0000' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_h2_font_color: 'AA0000' }, analyze: true = Document Title :doctype: book @@ -860,7 +860,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do = Details We let you know. - EOS + END chapter_texts = pdf.find_text font_color: 'AA0000' (expect chapter_texts).to have_size 2 @@ -873,7 +873,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not output section title for section marked with notitle option' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book @@ -889,7 +889,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Conclusion Wrapping it up. - EOS + END middle_chapter_text = pdf.find_text page_number: 3 (expect middle_chapter_text).to have_size 1 @@ -897,7 +897,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should add entry to toc for section with notitle option' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :toc: @@ -914,7 +914,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Conclusion Wrapping it up. - EOS + END toc_lines = pdf.lines pdf.find_text page_number: 2 middle_entry = toc_lines.find {|it| it.start_with? 'Middle' } @@ -923,7 +923,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not output section title for special section marked with notitle option' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_h2_font_color: 'AA0000' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_h2_font_color: 'AA0000' }, analyze: true = Document Title :doctype: book @@ -942,7 +942,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do = Details We let you know. - EOS + END colophon_page_text = pdf.find_text page_number: 2 (expect colophon_page_text).to have_size 1 @@ -958,7 +958,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not leave behind dest for empty section marked with notitle option' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book @@ -968,7 +968,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do [colophon%notitle] == Hidden - EOS + END (expect pdf.pages).to have_size 2 all_text = pdf.pages.map(&:text).join ?\n @@ -977,7 +977,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not add entry to toc for section marked with notitle option when no content follows it' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toc: @@ -988,7 +988,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do [colophon%notitle] == Hidden - EOS + END (expect pdf.pages).to have_size 3 all_text = pdf.pages.map(&:text).join ?\n @@ -996,7 +996,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not promote anonymous preface in book doctype to preface section if preface-title attribute is not set' do - input = <<~'EOS' + input = <<~'END' = Book Title :doctype: book @@ -1005,7 +1005,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == First Chapter chapter content - EOS + END pdf = to_pdf input names = get_names pdf @@ -1018,7 +1018,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do # QUESTION: is this the right behavior? should the value default to Preface instead? it 'should not promote anonymous preface in book doctype to preface section if preface-title attribute is empty' do - input = <<~'EOS' + input = <<~'END' = Book Title :doctype: book :preface-title: @@ -1028,7 +1028,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == First Chapter chapter content - EOS + END pdf = to_pdf input names = get_names pdf @@ -1040,7 +1040,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should promote anonymous preface in book doctype to preface section if preface-title attribute is non-empty' do - input = <<~'EOS' + input = <<~'END' = Book Title :doctype: book :preface-title: Prelude @@ -1050,7 +1050,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == First Chapter chapter content - EOS + END pdf = to_pdf input (expect (preface_dest = get_dest pdf, '_prelude')).not_to be_nil @@ -1065,7 +1065,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should only show preface title in TOC if notitle option is set on first child block of anonymous preface' do - input = <<~'EOS' + input = <<~'END' = Book Title :doctype: book :preface-title: Preface @@ -1077,7 +1077,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == First Chapter chapter content - EOS + END pdf = to_pdf input (expect (preface_dest = get_dest pdf, '_preface')).not_to be_nil @@ -1092,21 +1092,21 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not force title of empty section to next page if it fits on page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true == Section A [%hardbreaks] #{(['filler'] * 41).join ?\n} == Section B - EOS + END section_b_text = (pdf.find_text 'Section B')[0] (expect section_b_text[:page_number]).to be 1 end it 'should force section title to next page to keep with first line of section content' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true == Section A [%hardbreaks] @@ -1115,7 +1115,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Section B content - EOS + END section_b_text = (pdf.find_text 'Section B')[0] (expect section_b_text[:page_number]).to be 2 @@ -1125,13 +1125,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should force section title of non-empty section to next page if wrapped line does not fit on current page' do pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { heading_min_height_after: nil, heading_font_color: 'AA0000' }, analyze: true + to_pdf <<~END, pdf_theme: { heading_min_height_after: nil, heading_font_color: 'AA0000' }, analyze: true image::#{spacer_path}[] == This is a long heading that wraps to a second line content - EOS + END end heading_texts = pdf.find_text font_color: 'AA0000' @@ -1141,11 +1141,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should force section title of empty section to next page if wrapped line does not fit on current page' do pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { heading_font_color: 'AA0000' }, analyze: true + to_pdf <<~END, pdf_theme: { heading_font_color: 'AA0000' }, analyze: true image::#{spacer_path}[] == This is a long heading that wraps to a second line - EOS + END end heading_texts = pdf.find_text font_color: 'AA0000' @@ -1155,13 +1155,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should not require space for bottom margin between section title and bottom of page if min-height-after is 0' do pdf = with_content_spacer 10, 710 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { heading_min_height_after: 0, heading_font_color: 'AA0000' }, analyze: true + to_pdf <<~END, pdf_theme: { heading_min_height_after: 0, heading_font_color: 'AA0000' }, analyze: true image::#{spacer_path}[] == Heading Fits content - EOS + END end heading_text = pdf.find_unique_text font_color: 'AA0000' @@ -1170,11 +1170,11 @@ describe 'Asciidoctor::PDF::Converter - Section' do it 'should ignore heading-min-height-after if section is empty' do pdf = with_content_spacer 10, 650 do |spacer_path| - to_pdf <<~EOS, pdf_theme: { heading_min_height_after: 100, heading_font_color: 'AA0000' }, analyze: true + to_pdf <<~END, pdf_theme: { heading_min_height_after: 100, heading_font_color: 'AA0000' }, analyze: true image::#{spacer_path}[] == Heading Fits - EOS + END end (expect pdf.pages).to have_size 1 @@ -1183,13 +1183,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should force section title with text transform to next page to keep with first line of section content' do - pdf = to_pdf <<~EOS, pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true image::tall.svg[pdfwidth=80mm] == A long heading with uppercase characters content - EOS + END section_text = pdf.find_unique_text %r/^A LONG HEADING/ (expect section_text[:page_number]).to be 2 @@ -1198,13 +1198,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not force section title with inline formatting to next page if text formatting does not affect height' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true image::tall.svg[pdfwidth=80mm] == A long heading with some inline #markup# content - EOS + END section_text = pdf.find_unique_text %r/^A long heading/ (expect section_text[:page_number]).to be 1 @@ -1213,7 +1213,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not force section title to next page to keep with content if heading-min-height-after theme key is zero' do - pdf = to_pdf <<~EOS, pdf_theme: { heading_min_height_after: 0 }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { heading_min_height_after: 0 }, analyze: true == Section A [%hardbreaks] @@ -1222,7 +1222,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Section B content - EOS + END section_b_text = (pdf.find_text 'Section B')[0] (expect section_b_text[:page_number]).to be 1 @@ -1237,7 +1237,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do backend = %(pdf#{ext_class.object_id}) source_lines[0] = %( register_for '#{backend}'\n) ext_class.class_eval source_lines.join, source_file - pdf = to_pdf <<~EOS, backend: backend, analyze: true + pdf = to_pdf <<~END, backend: backend, analyze: true == Section A image::tall.svg[pdfwidth=70mm] @@ -1252,7 +1252,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do together -- - EOS + END section_b_text = pdf.find_unique_text 'Section B' (expect section_b_text[:page_number]).to be 2 @@ -1261,7 +1261,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should keep section with first block of content if breakable option is set on section' do - pdf = to_pdf <<~EOS, pdf_theme: { heading_min_height_after: nil }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { heading_min_height_after: nil }, analyze: true == Section A image::tall.svg[pdfwidth=70mm] @@ -1277,7 +1277,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do together -- - EOS + END section_b_text = pdf.find_unique_text 'Section B' (expect section_b_text[:page_number]).to be 2 @@ -1286,7 +1286,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should keep section with first block of content if heading-min-height-after theme key is auto' do - pdf = to_pdf <<~EOS, pdf_theme: { heading_min_height_after: 'auto' }, analyze: true + pdf = to_pdf <<~END, pdf_theme: { heading_min_height_after: 'auto' }, analyze: true == Section A image::tall.svg[pdfwidth=70mm] @@ -1301,7 +1301,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do together -- - EOS + END section_b_text = pdf.find_unique_text 'Section B' (expect section_b_text[:page_number]).to be 2 @@ -1310,7 +1310,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not alter document state when arranging heading' do - input = <<~'EOS' + input = <<~'END' == Section A image::tall.svg[pdfwidth=75mm] @@ -1321,7 +1321,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do This is the first paragraph of Section B.footnote:[This paragraph falls on the first page.] This paragraph falls on the second page. - EOS + END pdf = to_pdf input, analyze: true (expect (pdf.find_unique_text 'This is the first paragraph of Section B.')[:page_number]).to eql 1 @@ -1341,14 +1341,14 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not add break before chapter if heading-chapter-break-before key in theme is auto' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_chapter_break_before: 'auto' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_chapter_break_before: 'auto' }, analyze: true = Document Title :doctype: book == Chapter A == Chapter B - EOS + END chapter_a_text = (pdf.find_text 'Chapter A')[0] chapter_b_text = (pdf.find_text 'Chapter B')[0] @@ -1357,7 +1357,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not add break before part if heading-part-break-before key in theme is auto' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_part_break_before: 'auto', heading_chapter_break_before: 'auto' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_part_break_before: 'auto', heading_chapter_break_before: 'auto' }, analyze: true = Document Title :doctype: book @@ -1368,7 +1368,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do = Part II == Chapter in Part II - EOS + END part1_text = (pdf.find_text 'Part I')[0] part2_text = (pdf.find_text 'Part II')[0] @@ -1377,7 +1377,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should add break after part if heading-part-break-after key in theme is always' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_part_break_after: 'always', heading_chapter_break_before: 'auto' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_part_break_after: 'always', heading_chapter_break_before: 'auto' }, analyze: true = Document Title :doctype: book @@ -1390,7 +1390,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do = Part II == Chapter in Part II - EOS + END part1_text = (pdf.find_text 'Part I')[0] part2_text = (pdf.find_text 'Part II')[0] @@ -1403,14 +1403,14 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not add page break after part if heading-part-break-after key in theme is avoid' do - pdf = to_pdf <<~'EOS', pdf_theme: { heading_part_break_after: 'avoid' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { heading_part_break_after: 'avoid' }, analyze: true = Document Title :doctype: book = Part I == Chapter in Part I - EOS + END (expect pdf.pages).to have_size 2 part1_text = (pdf.find_text 'Part I')[0] @@ -1421,7 +1421,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should support abstract defined as special section' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :toc: @@ -1433,7 +1433,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Body What came to pass. - EOS + END abstract_title_text = (pdf.find_text 'Abstract')[0] (expect abstract_title_text[:x]).to be > 48.24 @@ -1447,7 +1447,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do context 'Section indent' do it 'should indent section body if section_indent is set to single value in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true = Document Title == Section Title @@ -1456,7 +1456,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do [.text-right] paragraph - EOS + END section_text = (pdf.find_text 'Section Title')[0] paragraph_text = pdf.find_text 'paragraph' @@ -1467,7 +1467,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should indent section body if section_indent is set to array in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: [36, 0] }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: [36, 0] }, analyze: true = Document Title == Section Title @@ -1476,7 +1476,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do [.text-right] paragraph - EOS + END section_text = (pdf.find_text 'Section Title')[0] paragraph_text = pdf.find_text 'paragraph' @@ -1487,7 +1487,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should indent toc entries if section_indent is set in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true = Document Title :doctype: book :toc: @@ -1495,7 +1495,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Chapter == Another Chapter - EOS + END toc_texts = pdf.find_text page_number: 2 toc_title_text = toc_texts.find {|it| it[:string] == 'Table of Contents' } @@ -1505,7 +1505,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should indent preamble if section_indent is set in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true = Document Title preamble @@ -1513,7 +1513,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do == Section content - EOS + END preamble_text = (pdf.find_text 'preamble')[0] (expect preamble_text[:x]).to eql 84.24 @@ -1522,7 +1522,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not reapply section indent to nested sections' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true = Document Title :doctype: book :notitle: @@ -1534,7 +1534,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do === Section section body - EOS + END chapter_title_text = (pdf.find_text 'Chapter')[0] section_title_text = (pdf.find_text 'Section')[0] @@ -1548,13 +1548,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should outdent footnotes in article' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true = Document Title == Section paragraph{blank}footnote:[About this paragraph] - EOS + END paragraph_text = (pdf.find_text 'paragraph')[0] footnote_text_fragments = pdf.text.select {|it| it[:y] < paragraph_text[:y] } @@ -1563,14 +1563,14 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should outdent footnotes in book' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true = Document Title :doctype: book == Chapter paragraph{blank}footnote:[About this paragraph] - EOS + END paragraph_text = (pdf.find_text 'paragraph')[0] footnote_text_fragments = (pdf.find_text page_number: 2).select {|it| it[:y] < paragraph_text[:y] } @@ -1579,7 +1579,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do end it 'should not indent body of index section' do - pdf = to_pdf <<~'EOS', pdf_theme: { section_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { section_indent: 36 }, analyze: true = Document Title :doctype: book @@ -1589,7 +1589,7 @@ describe 'Asciidoctor::PDF::Converter - Section' do [index] == Index - EOS + END index_page_texts = pdf.find_text page_number: 3 index_title_text = index_page_texts.find {|it| it[:string] == 'Index' } diff --git a/spec/sidebar_spec.rb b/spec/sidebar_spec.rb index caa3cd30..e6983238 100644 --- a/spec/sidebar_spec.rb +++ b/spec/sidebar_spec.rb @@ -4,11 +4,11 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Sidebar' do it 'should draw line around sidebar block' do - pdf = to_pdf <<~'EOS', analyze: :line, pdf_theme: { sidebar_background_color: 'transparent' } + pdf = to_pdf <<~'END', analyze: :line, pdf_theme: { sidebar_background_color: 'transparent' } **** sidebar **** - EOS + END (expect pdf.lines).to have_size 4 (expect pdf.lines.map {|it| it[:color] }.uniq).to eql ['E1E1E1'] @@ -21,11 +21,11 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do sidebar_border_style: 'dashed', sidebar_border_color: 'cccccc', } - to_file = to_pdf_file <<~'EOS', 'sidebar-border-style-dashed.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'sidebar-border-style-dashed.pdf', pdf_theme: pdf_theme **** sidebar **** - EOS + END (expect to_file).to visually_match 'sidebar-border-style-dashed.pdf' end @@ -36,23 +36,23 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do sidebar_border_style: 'dotted', sidebar_border_color: 'cccccc', } - to_file = to_pdf_file <<~'EOS', 'sidebar-border-style-dotted.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'sidebar-border-style-dotted.pdf', pdf_theme: pdf_theme **** sidebar **** - EOS + END (expect to_file).to visually_match 'sidebar-border-style-dotted.pdf' end it 'should add correct padding around content when using default theme' do - input = <<~'EOS' + input = <<~'END' **** first last **** - EOS + END pdf = to_pdf input, analyze: true lines = (to_pdf input, analyze: :line).lines @@ -71,13 +71,13 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do end it 'should add equal padding around content when using base theme' do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => 'base' }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'pdf-theme' => 'base' }, analyze: true **** first last **** - EOS + END boundaries = (pdf.extract_graphic_states pdf.pages[0][:raw_content])[0] .select {|l| l.end_with? 'l' } @@ -94,12 +94,12 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do end it 'should use block title as heading of sidebar block' do - input = <<~'EOS' + input = <<~'END' .Sidebar Title **** Sidebar content. **** - EOS + END pdf = to_pdf input, analyze: :line sidebar_border_top = pdf.lines.find {|it| it[:color] == 'E1E1E1' }[:from][:y] @@ -121,7 +121,7 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do end it 'should render adjacent sidebars without overlapping', visual: true do - to_file = to_pdf_file <<~'EOS', 'sidebar-adjacent.pdf' + to_file = to_pdf_file <<~'END', 'sidebar-adjacent.pdf' **** this @@ -137,13 +137,13 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do sidebar **** - EOS + END (expect to_file).to visually_match 'sidebar-adjacent.pdf' end it 'should keep sidebar together if it can fit on one page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['filler'] * 15).join %(\n\n)} .Sidebar @@ -151,7 +151,7 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do **** #{(['content'] * 15).join %(\n\n)} **** - EOS + END sidebar_text = (pdf.find_text 'Sidebar')[0] (expect sidebar_text[:page_number]).to be 2 @@ -164,7 +164,7 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do sidebar_background_color: 'DFDFDF', } pdf = with_content_spacer 10, 680 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] .Sidebar Title @@ -172,7 +172,7 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do First block of content. **** - EOS + END end pages = pdf.pages @@ -189,12 +189,12 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do end it 'should split block if it cannot fit on one page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true .Sidebar Title **** #{(['content'] * 30).join %(\n\n)} **** - EOS + END title_text = (pdf.find_text 'Sidebar Title')[0] content_text = (pdf.find_text 'content') @@ -204,12 +204,12 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do end it 'should split border when block is split across pages', visual: true do - to_file = to_pdf_file <<~EOS, 'sidebar-page-split.pdf' + to_file = to_pdf_file <<~END, 'sidebar-page-split.pdf' .Sidebar Title **** #{(['content'] * 30).join %(\n\n)} **** - EOS + END (expect to_file).to visually_match 'sidebar-page-split.pdf' end @@ -224,11 +224,11 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do [%(****\ncontent +\nthat wraps\n****), %([sidebar%hardbreaks]\ncontent\nthat wraps)].each do |content| pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] #{content} - EOS + END end pages = pdf.pages @@ -239,11 +239,11 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do (expect last_text_y - pdf_theme[:sidebar_padding]).to be > 48.24 pdf = with_content_spacer 10, 692 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] #{content} - EOS + END end pages = pdf.pages @@ -257,7 +257,7 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do end it 'should extend block to bottom of page but not beyond if content ends with page break', visual: true do - to_file = to_pdf_file <<~'EOS', 'sidebar-with-trailing-page-break.pdf' + to_file = to_pdf_file <<~'END', 'sidebar-with-trailing-page-break.pdf' .Sidebar Title **** Sidebar @@ -268,27 +268,27 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do **** after - EOS + END (expect to_file).to visually_match 'sidebar-with-trailing-page-break.pdf' end it 'should not add border if border width is not set in theme or value is nil' do - pdf = to_pdf <<~'EOS', pdf_theme: { sidebar_border_color: 'AA0000', sidebar_border_width: nil }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { sidebar_border_color: 'AA0000', sidebar_border_width: nil }, analyze: :line **** Sidebar **** - EOS + END (expect pdf.lines).to have_size 0 end it 'should not add border if border color is transaprent' do - pdf = to_pdf <<~'EOS', pdf_theme: { sidebar_border_color: 'transparent' }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { sidebar_border_color: 'transparent' }, analyze: :line **** Sidebar **** - EOS + END (expect pdf.lines).to have_size 0 end @@ -298,12 +298,12 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do sidebar_border_width: 0, sidebar_border_radius: 5, } - to_file = to_pdf_file <<~EOS, 'sidebar-page-split-no-border.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'sidebar-page-split-no-border.pdf', pdf_theme: pdf_theme .Sidebar Title **** #{(['content'] * 30).join %(\n\n)} **** - EOS + END (expect to_file).to visually_match 'sidebar-page-split-no-border.pdf' end @@ -314,40 +314,40 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do sidebar_border_color: 'transparent', sidebar_border_radius: 5, } - to_file = to_pdf_file <<~EOS, 'sidebar-page-split-transparent-border.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'sidebar-page-split-transparent-border.pdf', pdf_theme: pdf_theme .Sidebar Title **** #{(['content'] * 30).join %(\n\n)} **** - EOS + END (expect to_file).to visually_match 'sidebar-page-split-transparent-border.pdf' end it 'should allow font size of sidebar to be specified using absolute units' do - pdf = to_pdf <<~'EOS', pdf_theme: { sidebar_font_size: 9 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { sidebar_font_size: 9 }, analyze: true **** sidebar **** - EOS + END sidebar_text = pdf.find_unique_text 'sidebar' (expect sidebar_text[:font_size]).to eql 9 end it 'should allow font size of sidebar to be specified using relative units' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_font_size: 12, sidebar_font_size: '0.75em' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_font_size: 12, sidebar_font_size: '0.75em' }, analyze: true **** sidebar **** - EOS + END sidebar_text = pdf.find_unique_text 'sidebar' (expect sidebar_text[:font_size]).to eql 9 end it 'should allow font size of code block in sidebar to be specified using relative units' do - pdf = to_pdf <<~'EOS', pdf_theme: { sidebar_font_size: 12, code_font_size: '0.75em' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { sidebar_font_size: 12, code_font_size: '0.75em' }, analyze: true **** sidebar @@ -355,7 +355,7 @@ describe 'Asciidoctor::PDF::Converter - Sidebar' do code block ---- **** - EOS + END sidebar_text = pdf.find_unique_text 'sidebar' (expect sidebar_text[:font_size]).to eql 12 diff --git a/spec/source_spec.rb b/spec/source_spec.rb index 9fbce6b5..cdc78597 100644 --- a/spec/source_spec.rb +++ b/spec/source_spec.rb @@ -5,14 +5,14 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Source' do context 'Rouge' do it 'should use plain text lexer if language is not recognized' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,foobar] ---- puts "Hello, World!" ---- - EOS + END puts_text = (pdf.find_text 'puts')[0] (expect puts_text).to be_nil @@ -21,7 +21,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should expand tabs to preserve indentation' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :source-highlighter: rouge [source,c] @@ -31,7 +31,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do \treturn 0; } ---- - EOS + END lines = pdf.lines (expect lines).to have_size 4 (expect lines[1]).to eql %(\u00a0 event_loop();) @@ -39,7 +39,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should expand tabs used for column alignment' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :source-highlighter: rouge [source,sql] @@ -51,7 +51,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do WHERE \tusername\t=\t'foobar' ---- - EOS + END lines = pdf.lines (expect lines).to have_size 6 (expect lines).to include %(\u00a0 name, firstname, lastname) @@ -59,14 +59,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should enable start_inline option for PHP by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,php] ---- echo "<?php"; ---- - EOS + END echo_text = (pdf.find_text 'echo')[0] (expect echo_text).not_to be_nil @@ -75,14 +75,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should not enable the start_inline option for PHP if the mixed option is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source%mixed,php] ---- echo "<?php"; ---- - EOS + END echo_text = (pdf.find_text 'echo')[0] # NOTE: the echo keyword should not be highlighted @@ -90,7 +90,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should preserve cgi-style options when setting start_inline option for PHP' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,php?funcnamehighlighting=1] @@ -102,7 +102,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- cal_days_in_month(CAL_GREGORIAN, 6, 2019) ---- - EOS + END if (Gem::Version.new Rouge.version) >= (Gem::Version.new '2.1.0') ref_funcname_text = (pdf.find_text 'cal_days_in_month')[0] @@ -130,14 +130,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should enable start_inline option for PHP if enabled by cgi-style option' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,php?start_inline=1] ---- echo "<?php"; ---- - EOS + END if (Gem::Version.new Rouge.version) >= (Gem::Version.new '2.1.0') echo_text = pdf.find_unique_text 'echo' @@ -148,14 +148,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should not enable the start_inline option for PHP if the mixed option is set and other cgi-style options specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source%mixed,php?foo=bar] ---- echo "<?php"; ---- - EOS + END echo_text = pdf.find_unique_text 'echo' # NOTE: the echo keyword should not be highlighted @@ -163,14 +163,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should not enable start_inline option for PHP if disabled by cgi-style option' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,php?start_inline=0] ---- cal_days_in_month(CAL_GREGORIAN, 6, 2019) ---- - EOS + END text = pdf.text (expect text).to have_size 1 @@ -179,14 +179,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should respect cgi-style options for languages other than PHP' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,console?prompt=%] ---- % bundle ---- - EOS + END if (Gem::Version.new Rouge.version) >= (Gem::Version.new '2.1.0') prompt_text = pdf.find_unique_text '%' @@ -196,14 +196,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should use plain text lexer if language is not recognized and cgi-style options are present' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,foobar?start_inline=1] ---- puts "Hello, World!" ---- - EOS + END puts_text = (pdf.find_text 'puts')[0] (expect puts_text).to be_nil @@ -212,7 +212,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should use rouge style specified by rouge-style attribute', visual: true do - input = <<~'EOS' + input = <<~'END' :source-highlighter: rouge :rouge-style: molokai @@ -223,7 +223,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do const TAG_ALL_RX = /<[^>]+>/g module.exports = (html) => html && html.replace(TAG_ALL_RX, '') ---- - EOS + END to_file = to_pdf_file input, 'source-rouge-style.pdf' (expect to_file).to visually_match 'source-rouge-style.pdf' @@ -237,14 +237,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should disable highlighting instead of crashing if lexer fails to lex source' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,console] ---- $ cd application-name\bin\ ---- - EOS + END source_lines = pdf.lines pdf.text {|it| it.font_name.start_with? 'mplus1mn-' } (expect source_lines).not_to be_empty @@ -254,7 +254,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should not crash if source-highlighter attribute is defined outside of document header' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :source-highlighter: rouge @@ -263,7 +263,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- puts 'yo, world!' ---- - EOS + END source_text = pdf.find_unique_text font_name: 'mplus1mn-regular' (expect source_text).not_to be_nil @@ -272,7 +272,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should apply bw style if specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge :rouge-style: bw @@ -282,7 +282,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do attr_reader :style end ---- - EOS + END beer_text = (pdf.find_text 'Beer')[0] (expect beer_text).not_to be_nil @@ -295,7 +295,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should allow token to be formatted in bold and italic' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge :rouge-style: github @@ -304,7 +304,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do int #line 6 "pkg/mod.d" x; // this is now line 6 of file pkg/mod.d ---- - EOS + END line_text = pdf.find_unique_text %r/^#line 6 / (expect line_text).not_to be_empty @@ -312,7 +312,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should allow token to add underline style to token', visual: true do - input = <<~'EOS' + input = <<~'END' :source-highlighter: rouge [source,ruby] @@ -325,7 +325,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end end ---- - EOS + END # NOTE: convert to load Rouge to_pdf input @@ -341,7 +341,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should allow token to extend to width of block', visual: true do - input = <<~'EOS' + input = <<~'END' :source-highlighter: rouge :rouge-style: github @@ -349,7 +349,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- puts 'string' ---- - EOS + END # NOTE: convert to load Rouge to_pdf input @@ -366,14 +366,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should not crash if theme does not define style for Text token' do - input = <<~'EOS' + input = <<~'END' :source-highlighter: rouge [source,ruby] ---- puts "Hello, World!" ---- - EOS + END # NOTE: convert to load Rouge to_pdf input @@ -389,7 +389,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should expand color value for token' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge :rouge-style: colorful @@ -397,7 +397,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- class Type; end ---- - EOS + END pdf.text.each do |text| (expect text[:font_color].length).to be 6 @@ -410,7 +410,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should draw background color around token', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-rouge-bg.pdf' + to_file = to_pdf_file <<~'END', 'source-rouge-bg.pdf' :source-highlighter: rouge :rouge-style: pastie @@ -424,13 +424,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do puts 'See ya, ' + name + '!' end ---- - EOS + END (expect to_file).to visually_match 'source-rouge-bg.pdf' if (Gem::Version.new Rouge.version) >= (Gem::Version.new '2.1.0') end it 'should draw background color across whole line for line-oriented tokens', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-rouge-bg-line.pdf' + to_file = to_pdf_file <<~'END', 'source-rouge-bg-line.pdf' :source-highlighter: rouge [source,diff] @@ -444,13 +444,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do carrots +grapefruits ---- - EOS + END (expect to_file).to visually_match 'source-rouge-bg-line.pdf' if (Gem::Version.new Rouge.version) >= (Gem::Version.new '2.1.0') end it 'should not draw background color across whole line for line-oriented tokens if disabled in theme' do - input = <<~'EOS' + input = <<~'END' :source-highlighter: rouge [source,diff] @@ -458,7 +458,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do -oranges +grapefruits ---- - EOS + END # NOTE: convert to load Rouge to_pdf input @@ -478,7 +478,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should fall back to default line gap if line gap is not specified in theme', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-rouge-bg-line-no-gap.pdf', pdf_theme: { code_line_gap: nil } + to_file = to_pdf_file <<~'END', 'source-rouge-bg-line-no-gap.pdf', pdf_theme: { code_line_gap: nil } :source-highlighter: rouge [source,diff] @@ -492,13 +492,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do carrots +grapefruits ---- - EOS + END (expect to_file).to visually_match 'source-rouge-bg-line-no-gap.pdf' if (Gem::Version.new Rouge.version) >= (Gem::Version.new '2.1.0') end it 'should add line numbers to start of line if linenums option is enabled' do - expected_lines = <<~'EOS'.split ?\n + expected_lines = <<~'END'.split ?\n 1 <?xml version="1.0" encoding="UTF-8"?> 2 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 3 <url> @@ -510,9 +510,9 @@ describe 'Asciidoctor::PDF::Converter - Source' do 9 <lastmod>2019-01-01T00:00:00.000Z</lastmod> 10 </url> 11 </urlset> - EOS + END - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,xml,linenums] @@ -529,7 +529,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do </url> </urlset> ---- - EOS + END (expect pdf.lines).to eql expected_lines linenum_text = (pdf.find_text %r/^11 *$/)[0] @@ -539,14 +539,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should continue to add line numbers after page split' do source_lines = (1..55).map {|it| %(puts "Please come forward if your number is #{it}.") } - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :source-highlighter: rouge [source%linenums,ruby] ---- #{source_lines.join ?\n} ---- - EOS + END lines_after_split = pdf.lines pdf.find_text page_number: 2 (expect lines_after_split).not_to be_empty @@ -554,54 +554,54 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should honor start value for line numbering' do - expected_lines = <<~'EOS'.split ?\n + expected_lines = <<~'END'.split ?\n 5 puts 'Hello, World!' - EOS + END - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,xml,linenums,start=5] ---- puts 'Hello, World!' ---- - EOS + END (expect pdf.lines).to eql expected_lines end it 'should coerce start value for line numbering to 1 if less than 1' do - expected_lines = <<~'EOS'.split ?\n + expected_lines = <<~'END'.split ?\n 1 puts 'Hello, World!' - EOS + END - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,xml,linenums,start=0] ---- puts 'Hello, World!' ---- - EOS + END (expect pdf.lines).to eql expected_lines end it 'should not add line number to first line if source is empty' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source%linenums] ---- ---- - EOS + END (expect pdf.text).to be_empty end it 'should not emit error if linenums are enabled and language is not set' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source%linenums] @@ -611,14 +611,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do fo fum ---- - EOS + END (expect pdf.lines).to eql ['1 fee', '2 fi', '3 fo', '4 fum'] end).to not_log_message end it 'should preserve orphan callout on last line' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,yaml] @@ -628,14 +628,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do <1> ---- <1> End the file with a trailing newline - EOS + END conum_texts = pdf.find_text '①' (expect conum_texts).to have_size 2 end it 'should use font color from style' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge :rouge-style: monokai @@ -645,7 +645,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do bar baz ---- - EOS + END pdf.text.each do |text| (expect text[:font_color]).to eql 'F8F8F2' @@ -653,7 +653,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should highlight lines specified by highlight attribute on block', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-rouge-line-highlighting.pdf' + to_file = to_pdf_file <<~'END', 'source-rouge-line-highlighting.pdf' :source-highlighter: rouge [source,c,highlight=4;7-8] @@ -668,13 +668,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do return 0; } ---- - EOS + END (expect to_file).to visually_match 'source-rouge-line-highlighting.pdf' end it 'should highlight lines specified by highlight attribute on block when linenums are enabled', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-rouge-line-highlighting-with-linenums.pdf' + to_file = to_pdf_file <<~'END', 'source-rouge-line-highlighting-with-linenums.pdf' :source-highlighter: rouge [source,c,linenums,highlight=4;7-8] @@ -689,13 +689,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do return 0; } ---- - EOS + END (expect to_file).to visually_match 'source-rouge-line-highlighting-with-linenums.pdf' end it 'should interpret highlight lines relative to start value', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-rouge-line-highlighting-with-linenums-start.pdf' + to_file = to_pdf_file <<~'END', 'source-rouge-line-highlighting-with-linenums-start.pdf' :source-highlighter: rouge [source,c,linenums,start=4,highlight=4;7-8] @@ -707,13 +707,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do return 0; } ---- - EOS + END (expect to_file).to visually_match 'source-rouge-line-highlighting-with-linenums-start.pdf' end it 'should preserve indentation when highlighting lines without linenums enabled', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-rouge-line-highlighting-indent.pdf' + to_file = to_pdf_file <<~'END', 'source-rouge-line-highlighting-indent.pdf' :source-highlighter: rouge [source,groovy,highlight=4-5] @@ -727,33 +727,33 @@ describe 'Asciidoctor::PDF::Converter - Source' do } } ---- - EOS + END (expect to_file).to visually_match 'source-rouge-line-highlighting-indent.pdf' end it 'should ignore highlight attribute if empty' do - pdf = to_pdf <<~'EOS', analyze: :rect + pdf = to_pdf <<~'END', analyze: :rect :source-highlighter: rouge [source,ruby,linenums,highlight=] ---- puts "Hello, World!" ---- - EOS + END (expect pdf.rectangles).to be_empty end it 'should preserve indentation of highlighted line' do - input = <<~'EOS' + input = <<~'END' :source-highlighter: rouge [source,text,highlight=1] ---- indented line ---- - EOS + END pdf = to_pdf input, analyze: true (expect pdf.lines).to eql [%(\u00a0 indented line)] @@ -763,7 +763,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should highlight lines using custom color specified in theme', visual: true do pdf_theme = { code_highlight_background_color: 'FFFF00' } - to_file = to_pdf_file <<~'EOS', 'source-rouge-highlight-background-color.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'source-rouge-highlight-background-color.pdf', pdf_theme: pdf_theme :source-highlighter: rouge [source,c,highlight=4] @@ -778,20 +778,20 @@ describe 'Asciidoctor::PDF::Converter - Source' do return 0; } ---- - EOS + END (expect to_file).to visually_match 'source-rouge-highlight-background-color.pdf' end it 'should indent wrapped line if line numbers are enabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,text,linenums] ---- Here we go again here we go again here we go again here we go again here we go again Here we go again ---- - EOS + END linenum_text = (pdf.find_text '1 ')[0] (expect linenum_text[:x]).not_to be_nil @@ -806,7 +806,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should indent wrapped line if line numbers are enabled and block has an AFM font' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge :pdf-theme: base @@ -814,7 +814,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- Here we go again here we go again here we go again here we go again here we go again Here we go again ---- - EOS + END linenum_text = (pdf.find_text '1 ')[0] (expect linenum_text[:x]).not_to be_nil @@ -829,7 +829,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should highlight and indent wrapped line', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-rouge-highlight-wrapped-line.pdf' + to_file = to_pdf_file <<~'END', 'source-rouge-highlight-wrapped-line.pdf' :source-highlighter: rouge [source,xml,linenums,highlight=1;3] @@ -838,7 +838,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do <modelVersion>4.0.0</modelVersion> </project> ---- - EOS + END (expect to_file).to visually_match 'source-rouge-highlight-wrapped-line.pdf' end @@ -853,7 +853,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end opts = { extension_registry: Asciidoctor::Extensions.create { postprocessor(&postprocessor_impl) } } - main_pdf = to_pdf <<~'EOS', (opts.merge analyze: true) + main_pdf = to_pdf <<~'END', (opts.merge analyze: true) :source-highlighter: rouge filler @@ -865,7 +865,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do puts "Hello, World!" ---- -- - EOS + END main_pdf_text = main_pdf.text.reject {|it| it[:string] == 'filler' } (expect main_pdf_text[0][:string]).to eql 'puts' @@ -889,7 +889,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end end source_file = fixture_file 'TicTacToeGame.java' - pdf = to_pdf <<~EOS, extensions: extensions, enable_footer: true, analyze: true + pdf = to_pdf <<~END, extensions: extensions, enable_footer: true, analyze: true :source-highlighter: rouge before block @@ -898,7 +898,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- include::#{source_file}[] ---- - EOS + END (expect (pdf.find_unique_text 'before block')[:page_number]).to be 1 (expect (pdf.find_unique_text 'package')[:page_number]).to be 1 (expect (pdf.find_unique_text 'package')[:font_color]).not_to be '333333' @@ -907,14 +907,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should break and wrap numbered line if text does not fit on a single line' do - input = <<~EOS + input = <<~END :source-highlighter: rouge [%linenums,text] ---- y#{'o' * 100} ---- - EOS + END pdf = to_pdf input, analyze: true (expect pdf.pages).to have_size 1 @@ -932,7 +932,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should break and wrap numbered line if indented text does not fit on a single line' do - input = <<~EOS + input = <<~END :source-highlighter: rouge [%linenums,text] @@ -941,24 +941,24 @@ describe 'Asciidoctor::PDF::Converter - Source' do #{' ' * 2}y#{'o' * 100} after ---- - EOS + END pdf = to_pdf input, analyze: true (expect pdf.pages).to have_size 1 text_lines = pdf.lines pdf.text # FIXME: we lose the indentation on the second line, but that's true of plain listing blocks too - expected_lines = <<~EOS.chomp.split ?\n + expected_lines = <<~END.chomp.split ?\n 1 before 2 \u00a0 yooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo \u00a0 ooooooooooooooooo 3 after - EOS + END (expect text_lines).to eql expected_lines end it 'should break and wrap numbered line if text wraps but still does not fit on a single line' do - input = <<~EOS + input = <<~END :source-highlighter: rouge [%linenums,text] @@ -967,30 +967,30 @@ describe 'Asciidoctor::PDF::Converter - Source' do two and then s#{'o' * 100}me three ---- - EOS + END pdf = to_pdf input, analyze: true (expect pdf.pages).to have_size 1 text_lines = pdf.lines pdf.text - expected_lines = <<~EOS.chomp.split ?\n + expected_lines = <<~END.chomp.split ?\n 1 one 2 two and then \u00a0 sooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo \u00a0 ooooooooooooooooome 3 three - EOS + END (expect text_lines).to eql expected_lines end it 'should not apply syntax highlighting if specialchars sub is disabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,ruby,subs=-specialchars] ---- puts "Hello, World!" ---- - EOS + END text = pdf.text (expect text).to have_size 1 @@ -1008,7 +1008,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end opts = { extension_registry: Asciidoctor::Extensions.create { postprocessor(&postprocessor_impl) } } - pdf = to_pdf <<~'EOS', (opts.merge analyze: true) + pdf = to_pdf <<~'END', (opts.merge analyze: true) :source-highlighter: rouge [%unbreakable] @@ -1018,7 +1018,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do puts "Hello, World!" ---- -- - EOS + END [pdf.text, (TextInspector.analyze scratch_pdf.render).text].each do |text| (expect text[0][:string]).to eql 'puts "Hello, World!"' @@ -1027,7 +1027,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should remove bare HTML tags added by substitutions' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [,ruby,subs="+quotes,+macros"] @@ -1036,7 +1036,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do Asciidoctor._convert_file_ 'README.adoc', *safe: :safe* ---- - EOS + END lines = pdf.lines pdf.text (expect lines).to eql ['require %(asciidoctor)', %(Asciidoctor.convert_file 'README.adoc', safe: :safe)] @@ -1045,7 +1045,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should substitute attribute references if attributes substitution is enabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge :converter-library: asciidoctor-pdf :backend-value: :pdf @@ -1056,7 +1056,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do Asciidoctor.convert_file 'README.adoc', safe: :safe, backend: {backend-value} ---- - EOS + END lines = pdf.lines pdf.text (expect lines).to eql [%(require 'asciidoctor-pdf'), %(Asciidoctor.convert_file 'README.adoc', safe: :safe, backend: :pdf)] @@ -1067,14 +1067,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do context 'CodeRay' do it 'should highlight source using CodeRay if source-highlighter is coderay' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: coderay [source,ruby] ---- puts 'Hello, CodeRay!' ---- - EOS + END hello_text = (pdf.find_text 'Hello, CodeRay!')[0] (expect hello_text).not_to be_nil @@ -1084,7 +1084,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should fallback to text language if language is not recognized' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: coderay [,scala] @@ -1092,7 +1092,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do val l = List(1,2,3,4) l.foreach {i => println(i)} ---- - EOS + END expected_color = '333333' (expect pdf.text.map {|it| it[:font_color] }.uniq).to eql [expected_color] @@ -1101,7 +1101,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should not crash if token text is nil' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: coderay [source,sass] @@ -1112,7 +1112,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do background: #fafafa; } ---- - EOS + END closing_bracket_text = pdf.find_unique_text '}' (expect closing_bracket_text[:font_color]).to eql 'CC3300' @@ -1120,14 +1120,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should use sub-language if language starts with html+' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: coderay [source,html+js] ---- document.addEventListener('load', function () { console.log('page is loaded!') }) ---- - EOS + END message_text = (pdf.find_text 'page is loaded!')[0] (expect message_text).not_to be_nil @@ -1135,14 +1135,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should fall back to text if language does not have valid characters' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: coderay [source,?!?] ---- ,[.,] ---- - EOS + END text = (pdf.find_text ',[.,]')[0] (expect text[:font_color]).to eql '333333' @@ -1150,7 +1150,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should not crash if source-highlighter attribute is defined outside of document header' do (expect do - to_pdf <<~'EOS' + to_pdf <<~'END' = Document Title :source-highlighter: coderay @@ -1159,12 +1159,12 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- puts 'yo, world!' ---- - EOS + END end).not_to raise_exception end it 'should add indentation guards at start of line that begins with space to preserve indentation' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: coderay [source,yaml] @@ -1173,12 +1173,12 @@ describe 'Asciidoctor::PDF::Converter - Source' do hash: key: "value" ---- - EOS + END (expect pdf.lines).to eql ['category:', %(\u00a0 hash:), %(\u00a0 key: "value")] end it 'should expand tabs to preserve indentation' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :source-highlighter: coderay [source,c] @@ -1188,7 +1188,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do \treturn 0; } ---- - EOS + END lines = pdf.lines (expect lines).to have_size 4 (expect lines[1]).to eql %(\u00a0 event_loop();) @@ -1196,7 +1196,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should extract conums so they do not interfere with syntax highlighting' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: coderay [source,xml] @@ -1206,7 +1206,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do content </tag> ---- - EOS + END attr_name_text = (pdf.find_text 'attr')[0] (expect attr_name_text).not_to be_nil @@ -1217,14 +1217,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do context 'Pygments' do it 'should highlight source using Pygments if source-highlighter is pygments' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,ruby] ---- puts "Hello, Pygments!" ---- - EOS + END hello_text = (pdf.find_text '"Hello, Pygments!"')[0] (expect hello_text).not_to be_nil @@ -1233,14 +1233,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should display encoded source without highlighting if lexer fails to return a value' do - input = <<~'EOS' + input = <<~'END' :source-highlighter: pygments [source,xml] ---- <payload>&</payload> ---- - EOS + END # warm up pygments pdf = to_pdf input, analyze: true @@ -1253,14 +1253,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do def highlight *_args; end end - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,xml] ---- <payload>&</payload> ---- - EOS + END (expect pdf.text).to have_size 1 source_text = pdf.text[0] @@ -1275,7 +1275,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should not crash when adding indentation guards' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,yaml] @@ -1284,7 +1284,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do hash: key: "value" ---- - EOS + END (expect pdf.find_text %r/: ?/).to have_size 3 lines = pdf.lines (expect lines).to have_size 3 @@ -1296,7 +1296,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should expand tabs to preserve indentation' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :source-highlighter: pygments [source,c] @@ -1306,7 +1306,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do \treturn 0; } ---- - EOS + END lines = pdf.lines (expect lines).to have_size 4 (expect lines[1]).to eql %(\u00a0 event_loop();) @@ -1314,14 +1314,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should use plain text lexer if language is not recognized' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,foobar] ---- puts "Hello, World!" ---- - EOS + END puts_text = (pdf.find_text 'puts')[0] (expect puts_text).to be_nil @@ -1330,14 +1330,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should enable start_inline option for PHP by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,php] ---- echo "<?php"; ---- - EOS + END echo_text = (pdf.find_text 'echo')[0] (expect echo_text).not_to be_nil @@ -1346,14 +1346,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should not enable the start_inline option for PHP if the mixed option is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source%mixed,php] ---- echo "<?php"; ---- - EOS + END echo_text = (pdf.find_text 'echo')[0] # NOTE: the echo keyword should not be highlighted @@ -1362,7 +1362,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should not crash when aligning line numbers' do (expect do - expected_lines = <<~'EOS'.split ?\n + expected_lines = <<~'END'.split ?\n 1 <?xml version="1.0" encoding="UTF-8"?> 2 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 3 <url> @@ -1374,9 +1374,9 @@ describe 'Asciidoctor::PDF::Converter - Source' do 9 <lastmod>2019-01-01T00:00:00.000Z</lastmod> 10 </url> 11 </urlset> - EOS + END - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,xml,linenums] @@ -1393,31 +1393,31 @@ describe 'Asciidoctor::PDF::Converter - Source' do </url> </urlset> ---- - EOS + END (expect pdf.lines).to eql expected_lines end).not_to raise_exception end it 'should honor start value for line numbering' do - expected_lines = <<~'EOS'.split ?\n + expected_lines = <<~'END'.split ?\n 5 puts 'Hello, World!' - EOS + END - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,xml,linenums,start=5] ---- puts 'Hello, World!' ---- - EOS + END (expect pdf.lines).to eql expected_lines end it 'should preserve space before callout on last line' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,yaml] @@ -1426,7 +1426,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do key: 'value' #<1> ---- <1> key-value pair - EOS + END text = pdf.text conum_idx = text.index {|it| it[:string] == '①' } @@ -1435,7 +1435,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should support background color on highlighted tokens', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-pygments-token-background-color.pdf' + to_file = to_pdf_file <<~'END', 'source-pygments-token-background-color.pdf' :source-highlighter: pygments :pygments-style: murphy @@ -1446,13 +1446,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do puts 'hex color' end ---- - EOS + END (expect to_file).to visually_match 'source-pygments-token-background-color.pdf' end it 'should use background color from style', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-pygments-background-color.pdf', pdf_theme: { code_background_color: 'fafafa' } + to_file = to_pdf_file <<~'END', 'source-pygments-background-color.pdf', pdf_theme: { code_background_color: 'fafafa' } :source-highlighter: pygments :pygments-style: monokai @@ -1472,13 +1472,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do const TAG_ALL_RX = /<[^>]+>/g module.exports = (html) => html && html.replace(TAG_ALL_RX, '') ---- - EOS + END (expect to_file).to visually_match 'source-pygments-background-color.pdf' end it 'should use font color from style' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments :pygments-style: monokai @@ -1488,7 +1488,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do bar baz ---- - EOS + END pdf.text.each do |text| (expect text[:font_color]).to eql 'F8F8F2' @@ -1496,7 +1496,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should ignore highlight attribute if empty' do - pdf = to_pdf <<~'EOS', analyze: :rect + pdf = to_pdf <<~'END', analyze: :rect :source-highlighter: pygments :pygments-style: tango @@ -1504,14 +1504,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do ---- puts "Hello, World!" ---- - EOS + END (expect pdf.rectangles).to be_empty end it 'should fall back to pastie style if style is not recognized' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments :pygments-style: not-recognized @@ -1522,7 +1522,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do puts 'hex color' end ---- - EOS + END comment_text = pdf.find_unique_text %r/^#/ (expect comment_text[:font_color]).to eql '888888' @@ -1532,7 +1532,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should highlight selected lines but not the line numbers', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-pygments-line-highlighting.pdf' + to_file = to_pdf_file <<~'END', 'source-pygments-line-highlighting.pdf' :source-highlighter: pygments [source,groovy,linenums,highlight=7-9] @@ -1549,26 +1549,26 @@ describe 'Asciidoctor::PDF::Converter - Source' do } } ---- - EOS + END (expect to_file).to visually_match 'source-pygments-line-highlighting.pdf' end it 'should not add line number to first line if source is empty' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source%linenums] ---- ---- - EOS + END (expect pdf.text).to be_empty end it 'should not emit error if linenums are enabled and language is not set' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source%linenums] @@ -1578,21 +1578,21 @@ describe 'Asciidoctor::PDF::Converter - Source' do fo fum ---- - EOS + END (expect pdf.lines).to eql ['1 fee', '2 fi', '3 fo', '4 fum'] end).to not_log_message end it 'should indent wrapped line if line numbers are enabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: pygments [source,text,linenums] ---- Here we go again here we go again here we go again here we go again here we go again Here we go again ---- - EOS + END linenum_text = (pdf.find_text '1 ')[0] (expect linenum_text[:x]).not_to be_nil @@ -1603,7 +1603,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should highlight and indent wrapped line', visual: true do - to_file = to_pdf_file <<~'EOS', 'source-pygments-highlight-wrapped-line.pdf' + to_file = to_pdf_file <<~'END', 'source-pygments-highlight-wrapped-line.pdf' :source-highlighter: pygments [source,xml,linenums,highlight=1;3] @@ -1612,13 +1612,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do <modelVersion>4.0.0</modelVersion> </project> ---- - EOS + END (expect to_file).to visually_match 'source-pygments-highlight-wrapped-line.pdf' end it 'should guard inner indents' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :source-highlighter: pygments [source,text] @@ -1627,20 +1627,20 @@ describe 'Asciidoctor::PDF::Converter - Source' do flush lead space ---- - EOS + END (expect pdf.lines).to eql [%(\u00a0 lead space), 'flush', %(\u00a0 lead space)] end it 'should ignore fragment if empty' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true :source-highlighter: pygments [source,ruby] ---- <1> ---- - EOS + END (expect pdf.lines).to eql ['①'] end @@ -1648,7 +1648,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do context 'Unsupported' do it 'should apply specialcharacters substitution and indentation guards for client-side syntax highlighter' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: highlight.js [source,xml] @@ -1657,7 +1657,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do <child>content</child> </root> ---- - EOS + END (expect pdf.lines).to eql ['<root>', %(\u00a0 <child>content</child>), '</root>'] (expect pdf.text.map {|it| it[:font_color] }.uniq).to eql ['333333'] @@ -1672,7 +1672,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end end - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: foobar [source,xml] @@ -1681,7 +1681,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do <child>content</child> </root> ---- - EOS + END (expect pdf.lines).to eql ['<root>', %(\u00a0 <child>content</child>), '</root>'] (expect pdf.text.map {|it| it[:font_color] }.uniq).to eql ['333333'] @@ -1690,7 +1690,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do context 'Callouts' do it 'should allow callout to be escaped' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,ruby] @@ -1699,14 +1699,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do \<1> after) ---- - EOS + END (expect pdf.lines).to include '<1>' (expect pdf.find_text '①').to be_empty end it 'should not replace callouts if callouts sub is not present' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,ruby,subs=-callouts] @@ -1715,14 +1715,14 @@ describe 'Asciidoctor::PDF::Converter - Source' do not a conum <1> after) ---- - EOS + END (expect pdf.lines).to include 'not a conum <1>' (expect pdf.find_text '①').to be_empty end it 'should inherit font color if not set in theme when source highlighter is enabled' do - pdf = to_pdf <<~'EOS', pdf_theme: { code_font_color: '111111', conum_font_color: nil }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { code_font_color: '111111', conum_font_color: nil }, analyze: true :source-highlighter: rouge [source,ruby] @@ -1730,7 +1730,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do puts 'Hello, World' <1> ---- <1> Just a programming saying hi. - EOS + END conum_texts = pdf.find_text %r/①/ (expect conum_texts).to have_size 2 @@ -1739,13 +1739,13 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should inherit font color if not set in theme when source highlighter is not enabled' do - pdf = to_pdf <<~'EOS', pdf_theme: { code_font_color: '111111', conum_font_color: nil }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { code_font_color: '111111', conum_font_color: nil }, analyze: true [source,ruby] ---- puts 'Hello, World' <1> ---- <1> Just a programming saying hi. - EOS + END conum_texts = pdf.find_text %r/①/ (expect conum_texts).to have_size 2 @@ -1754,7 +1754,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should process a sequence of two or more callouts when not separated by spaces' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,java] @@ -1765,7 +1765,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do int getAge(); // <3><4><5> } ---- - EOS + END lines = pdf.lines (expect lines[1]).to end_with '; ① ②' @@ -1773,7 +1773,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should process a sequence of two or more callouts when separated by spaces' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,java] @@ -1784,7 +1784,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do int getAge(); // <3> <4> <5> } ---- - EOS + END lines = pdf.lines (expect lines[1]).to end_with '; ① ②' @@ -1792,7 +1792,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should honor font family set on conum category in theme for conum in source block' do - pdf = to_pdf <<~'EOS', pdf_theme: { code_font_family: 'Courier' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { code_font_family: 'Courier' }, analyze: true :source-highlighter: rouge [source,java] @@ -1803,7 +1803,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do int getAge(); <3> } ---- - EOS + END lines = pdf.lines (expect lines[1]).to end_with '; ①' @@ -1814,7 +1814,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should substitute autonumber callouts with circled numbers when using rouge as syntax highlighter' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,java] @@ -1825,7 +1825,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do int getAge(); // <.> } ---- - EOS + END lines = pdf.lines (expect lines[1]).to end_with '; ①' @@ -1834,7 +1834,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should process multiple autonumber callouts on a single line when using rouge as syntax highlighter' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,java] @@ -1845,7 +1845,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do int getAge(); // <.> <.> } ---- - EOS + END lines = pdf.lines (expect lines[1]).to end_with '; ①' @@ -1855,7 +1855,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do it 'should preserve space before callout on final line' do ['rouge', (gem_available? 'pygments.rb') ? 'pygments' : nil].compact.each do |highlighter| - pdf = to_pdf <<~'EOS', attribute_overrides: { 'source-highlighter' => highlighter }, analyze: true + pdf = to_pdf <<~'END', attribute_overrides: { 'source-highlighter' => highlighter }, analyze: true [source,java] ---- public interface Person { @@ -1863,7 +1863,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do } <1> ---- <1> End class definition - EOS + END lines = pdf.lines (expect lines).to include '} ①' @@ -1871,7 +1871,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should hide spaces in front of conum from source highlighter' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [source,apache] @@ -1882,7 +1882,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do </Directory> ---- <1> Cannot be overridden by .htaccess - EOS + END none_text = (pdf.find_text 'None')[0] (expect none_text).not_to be_nil @@ -1890,7 +1890,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end it 'should preserve callouts if custom subs are used on code block when source highlighter is enabled' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :source-highlighter: rouge [,ruby,subs=+quotes] @@ -1898,7 +1898,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do puts "*Hello, World!*" <1> ---- <1> Welcome the world to the show. - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -1917,7 +1917,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do backend = %(pdf#{ext_class.object_id}) source_lines[0] = %( register_for '#{backend}'\n) ext_class.class_eval source_lines.join, source_file - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true :source-highlighter: coderay [,ruby] @@ -1927,7 +1927,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do end puts lines * ?\n ---- - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 reference_text = (pdf.find_text 'lines')[0] @@ -1946,7 +1946,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do source_lines[0] = %( register_for '#{backend}'\n) ext_class.class_eval source_lines.join, source_file pdf_theme = { page_columns: 2, page_column_gap: 12 } - pdf = to_pdf <<~'EOS', backend: backend, pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', backend: backend, pdf_theme: pdf_theme, analyze: true :source-highlighter: coderay image::tall-spacer.png[pdfwidth=5] @@ -1958,7 +1958,7 @@ describe 'Asciidoctor::PDF::Converter - Source' do Asciidoctor.convert_file 'README.adoc', backend: 'pdf', safe: :safe ---- - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 reference_text = (pdf.find_text 'require')[0] diff --git a/spec/spec_helper/helpers.rb b/spec/spec_helper/helpers.rb index caace555..a6a99bcd 100644 --- a/spec/spec_helper/helpers.rb +++ b/spec/spec_helper/helpers.rb @@ -280,13 +280,13 @@ module RSpec::ExampleHelpers end def with_content_spacer width, height, units = 'pt' - contents = <<~EOS + contents = <<~END <svg width="#{width}#{units}" height="#{height}#{units}" viewBox="0 0 #{width} #{height}" version="1.0" xmlns="http://www.w3.org/2000/svg"> <g> <rect style="fill:#999999" width="#{width}" height="#{height}" x="0" y="0"></rect> </g> </svg> - EOS + END with_tmp_file '.svg', contents: contents do |spacer_file| yield spacer_file.path end @@ -354,12 +354,12 @@ module RSpec::ExampleHelpers def with_svg_with_remote_image refname = 'main' if ((refname = %(v#{Asciidoctor::PDF::VERSION})).count '[a-z]') > 0 image_url = "https://cdn.jsdelivr.net/gh/asciidoctor/asciidoctor-pdf@#{refname}/spec/fixtures/logo.png" - svg_data = <<~EOS + svg_data = <<~END <svg width="1cm" height="1cm" version="1.1" viewBox="0 0 5 5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <image x="0" y="0" width="5" height="5" xlink:href="#{image_url}"/> <rect x="0.25" y="0.25" width="4.5" height="4.5" fill-opacity="0" stroke="#000" stroke-width="0.5"/> </svg> - EOS + END with_tmp_file '.svg', contents: svg_data do |tmp_file| yield tmp_file.path, image_url end diff --git a/spec/stem_spec.rb b/spec/stem_spec.rb index ae46141e..97a4a977 100644 --- a/spec/stem_spec.rb +++ b/spec/stem_spec.rb @@ -4,14 +4,14 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - STEM' do it 'should render stem as code block if stem extension not present' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [stem] ++++ sig = enc(H(D), s) ++++ after - EOS + END equation_text = (pdf.find_text 'sig = enc(H(D), s)')[0] (expect equation_text[:font_name]).to eql 'mplus1mn-regular' @@ -20,7 +20,7 @@ describe 'Asciidoctor::PDF::Converter - STEM' do end it 'should preserve indentation in stem block' do - pdf = to_pdf <<~'EOS', pdf_theme: { page_margin: 36, code_padding: 10 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { page_margin: 36, code_padding: 10 }, analyze: true [stem] ++++ M = \left[ @@ -29,7 +29,7 @@ describe 'Asciidoctor::PDF::Converter - STEM' do 3 & 4 \end{array} \right] ++++ - EOS + END pdf.text.each {|text| (expect text[:font_name]).to eql 'mplus1mn-regular' } lhs_text = pdf.find_unique_text %r/^M/ @@ -40,7 +40,7 @@ describe 'Asciidoctor::PDF::Converter - STEM' do end it 'should show caption and anchor above block if specified' do - input = <<~'EOS' + input = <<~'END' // listing-caption is not used in this case :listing-caption: Listing @@ -53,7 +53,7 @@ describe 'Asciidoctor::PDF::Converter - STEM' do 3 & 4 \end{array} \right] ++++ - EOS + END pdf = to_pdf input, analyze: true caption_text = pdf.find_unique_text 'A basic matrix' diff --git a/spec/table_spec.rb b/spec/table_spec.rb index 09bd0e4a..2088921c 100644 --- a/spec/table_spec.rb +++ b/spec/table_spec.rb @@ -5,10 +5,10 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Table' do it 'should not crash if table has no rows' do (expect do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line |=== |=== - EOS + END (expect pdf.lines).to have_size 4 end).to not_raise_exception & (log_message severity: :WARN, message: 'no rows found in table') @@ -16,12 +16,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not crash if cols and table cells are mismatched' do (expect do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [cols="1,"] |=== | cell |=== - EOS + END (expect pdf.lines).to have_size 8 end).to not_raise_exception & (log_message severity: :WARN, message: 'no rows found in table') @@ -29,7 +29,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not crash when rows have cells with colspans of varying length' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=3*] |=== 3+|X @@ -37,7 +37,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |Y 2+|Z |=== - EOS + END y_text = pdf.find_unique_text 'Y' z_text = pdf.find_unique_text 'Z' @@ -48,50 +48,50 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Decoration' do it 'should apply frame all and grid all by default' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line |=== |1 |2 |3 |4 |=== - EOS + END (expect pdf.lines.uniq).to have_size 12 end it 'should allow frame and grid to be specified on table using frame and grid attributes' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [frame=ends,grid=cols] |=== |1 |2 |3 |4 |=== - EOS + END (expect pdf.lines.uniq).to have_size 6 end it 'should treat topbot value of frame attribute as an alias for ends' do - pdf_a = to_pdf <<~'EOS', analyze: :line + pdf_a = to_pdf <<~'END', analyze: :line [frame=ends] |=== |1 |2 |3 |4 |=== - EOS + END - pdf_b = to_pdf <<~'EOS', analyze: :line + pdf_b = to_pdf <<~'END', analyze: :line [frame=topbot] |=== |1 |2 |3 |4 |=== - EOS + END (expect pdf_a.lines).to eql pdf_b.lines end it 'should allow frame and grid to be set globally using table-frame and table-grid attributes' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line :table-frame: ends :table-grid: cols @@ -99,7 +99,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |1 |2 |3 |4 |=== - EOS + END (expect pdf.lines.uniq).to have_size 6 end @@ -109,7 +109,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_body_background_color: 'FDFDFD', table_body_stripe_background_color: 'EFEFEF', } - to_file = to_pdf_file <<~'EOS', 'table-stripes-even.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'table-stripes-even.pdf', pdf_theme: pdf_theme [stripes=even] |=== |fee @@ -117,39 +117,39 @@ describe 'Asciidoctor::PDF::Converter - Table' do |fo |fum |=== - EOS + END (expect to_file).to visually_match 'table-stripes-even.pdf' end it 'should apply stripes to odd rows as specified by stripes attribute', visual: true do - to_file = to_pdf_file <<~'EOS', 'table-stripes-odd.pdf' + to_file = to_pdf_file <<~'END', 'table-stripes-odd.pdf' [cols=3*,stripes=odd] |=== |A1 |B1 |C1 |A2 |B2 |C2 |A3 |B3 |C3 |=== - EOS + END (expect to_file).to visually_match 'table-stripes-odd.pdf' end it 'should apply stripes to all rows as specified by stripes attribute', visual: true do - to_file = to_pdf_file <<~'EOS', 'table-stripes-all.pdf' + to_file = to_pdf_file <<~'END', 'table-stripes-all.pdf' [cols=3*,stripes=all] |=== |A1 |B1 |C1 |A2 |B2 |C2 |A3 |B3 |C3 |=== - EOS + END (expect to_file).to visually_match 'table-stripes-all.pdf' end it 'should apply thicker bottom border to table head row' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [frame=none,grid=rows] |=== | Col A | Col B @@ -160,7 +160,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 | B2 |=== - EOS + END lines = pdf.lines.uniq (expect lines).to have_size 4 @@ -174,7 +174,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should apply 2.5 * grid row width to bottom border of table head row if override not specified' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_head_border_bottom_width: nil }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { table_head_border_bottom_width: nil }, analyze: :line [frame=none,grid=rows] |=== | Col A | Col B @@ -185,7 +185,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 | B2 |=== - EOS + END lines = pdf.lines.uniq (expect lines).to have_size 4 @@ -199,7 +199,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should use grid color as default border color for head bottom border' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_grid_color: 'AA0000' }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { table_grid_color: 'AA0000' }, analyze: :line [frame=none,grid=rows] |=== | Col A | Col B @@ -207,7 +207,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A1 | B1 |=== - EOS + END lines = pdf.lines (expect lines).to have_size 4 @@ -228,7 +228,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end end opts = { extension_registry: Asciidoctor::Extensions.create { tree_processor(&tree_processor_impl) } } - pdf = to_pdf <<~'EOS', (opts.merge analyze: :line) + pdf = to_pdf <<~'END', (opts.merge analyze: :line) [%header,frame=none,grid=rows] |=== | Columns @@ -238,7 +238,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 |=== - EOS + END lines = pdf.lines.uniq ys = lines.map {|l| l[:from][:y] }.sort.reverse.uniq @@ -250,7 +250,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should retain border on bottom of table head when grid and frame are disabled' do - input = <<~'EOS' + input = <<~'END' [grid=none,frame=none] |=== |A |B @@ -261,7 +261,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |A2 |B2 |=== - EOS + END pdf = to_pdf input, analyze: :line @@ -286,7 +286,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_head_border_bottom_style: 'dashed', table_head_border_bottom_color: 'a9a9a9', } - to_file = to_pdf_file <<~'EOS', 'table-head-border-bottom.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'table-head-border-bottom.pdf', pdf_theme: pdf_theme [frame=none,grid=rows] |=== | Col A | Col B @@ -297,7 +297,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 | B2 |=== - EOS + END (expect to_file).to visually_match 'table-head-border-bottom.pdf' end @@ -310,14 +310,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do end end opts = { extension_registry: Asciidoctor::Extensions.create { tree_processor(&tree_processor_impl) } } - pdf = to_pdf <<~EOS, (opts.merge analyze: true) + pdf = to_pdf <<~END, (opts.merge analyze: true) [%header] |=== 2+^| Columns ^| Column A ^| Column B #{['| cell | cell'] * 40 * ?\n} |=== - EOS + END [1, 2].each do |page_number| col_a_text = (pdf.find_text page_number: page_number, string: 'Column A')[0] @@ -335,7 +335,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_head_border_bottom_color: 'transparent', } - pdf = to_pdf <<~'EOS', analyze: :line, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', analyze: :line, pdf_theme: pdf_theme [frame=none,grid=rows] |=== | Col A | Col B @@ -346,7 +346,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 | B2 |=== - EOS + END lines = pdf.lines.uniq (expect lines).not_to be_empty @@ -363,7 +363,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_color: cmyk_color, } - pdf = to_pdf <<~'EOS', analyze: :line, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', analyze: :line, pdf_theme: pdf_theme [frame=none,grid=rows] |=== | Col A | Col B @@ -374,7 +374,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 | B2 |=== - EOS + END lines = pdf.lines.uniq (expect lines).not_to be_empty @@ -389,13 +389,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_width: 2, table_grid_style: 'dotted', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line [frame=none,grid=all] |=== | A | B | C | D |=== - EOS + END # NOTE: it appears Prawn table is drawing the same grid line multiple times lines = pdf.lines.uniq @@ -413,13 +413,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_color: cmyk_color, table_grid_width: 1, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line [frame=none,grid=all] |=== | A | B | C | D |=== - EOS + END # NOTE: it appears Prawn table is drawing the same grid line multiple times lines = pdf.lines.uniq @@ -436,7 +436,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_color: nil, } - pdf = to_pdf <<~'EOS', analyze: :line, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', analyze: :line, pdf_theme: pdf_theme |=== | Col A | Col B @@ -446,7 +446,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 | B2 |=== - EOS + END lines = pdf.lines.uniq (expect lines).not_to be_empty @@ -461,12 +461,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_color: '3D3D3D', table_grid_width: 0, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line |=== | A | B | C | D |=== - EOS + END line_colors = pdf.lines.map {|l| l[:color] }.uniq (expect line_colors).not_to be_empty @@ -480,13 +480,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_color: %w(3D3D3D D3D3D3), table_grid_width: 0, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line [grid=none] |=== | A | B | C | D |=== - EOS + END line_colors = pdf.lines.map {|l| l[:color] }.uniq (expect line_colors).not_to be_empty @@ -499,13 +499,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_border_width: 3, table_border_style: 'dashed', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line [frame=all,grid=none] |=== | A | B | C | D |=== - EOS + END lines = pdf.lines (expect lines).to have_size 8 @@ -523,18 +523,18 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_border_style: 'double', } (expect do - to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line [frame=all,grid=none] |=== | A | B | C | D |=== - EOS + END end).to raise_exception ArgumentError, 'border_line must be :solid, :dotted or :dashed' end it 'should honor cellbgcolor attribute in table cell to set background color of cell', visual: true do - to_file = to_pdf_file <<~'EOS', 'table-cellbgcolor.pdf' + to_file = to_pdf_file <<~'END', 'table-cellbgcolor.pdf' :attribute-undefined: drop [%autowidth,cols=3*] @@ -543,39 +543,39 @@ describe 'Asciidoctor::PDF::Converter - Table' do | {set:cellbgcolor:#FF0000}red background color | {set:cellbgcolor!}default background color again |=== - EOS + END (expect to_file).to visually_match 'table-cellbgcolor.pdf' end it 'should allow value of cellbgcolor attribute in table cell to be transparent', visual: true do - to_file = to_pdf_file <<~'EOS', 'table-cellbgcolor.pdf' + to_file = to_pdf_file <<~'END', 'table-cellbgcolor.pdf' [%autowidth,cols=3*] |=== | default background color | {set:cellbgcolor:#FF0000}red background color | {set:cellbgcolor:transparent}default background color again |=== - EOS + END (expect to_file).to visually_match 'table-cellbgcolor.pdf' end it 'should ignore cellbgcolor attribute if not a valid hex color', visual: true do - to_file = to_pdf_file <<~'EOS', 'table-cellbgcolor-invalid.pdf' + to_file = to_pdf_file <<~'END', 'table-cellbgcolor-invalid.pdf' [%autowidth,cols=3*] |=== | {set:cellbgcolor:#f00}default background color | {set:cellbgcolor:#ff0000}red background color | {set:cellbgcolor:bogus}default background color again |=== - EOS + END (expect to_file).to visually_match 'table-cellbgcolor.pdf' end it 'should use value of cellbgcolor attribute in table cell to override background color set by theme', visual: true do - to_file = to_pdf_file <<~'EOS', 'table-cellbgcolor-override.pdf', pdf_theme: { table_body_background_color: 'CCCCCC' } + to_file = to_pdf_file <<~'END', 'table-cellbgcolor-override.pdf', pdf_theme: { table_body_background_color: 'CCCCCC' } :attribute-undefined: drop [%autowidth,cols=3*] @@ -584,7 +584,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | {set:cellbgcolor:#FF0000}red background color | {set:cellbgcolor!}default background color again |=== - EOS + END (expect to_file).to visually_match 'table-cellbgcolor-override.pdf' end @@ -595,12 +595,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_width: [0.5, 1.2], table_grid_style: %w(dashed solid), } - to_file = to_pdf_file <<~'EOS', 'table-grid-axes.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'table-grid-axes.pdf', pdf_theme: pdf_theme |=== | A | B | C | D |=== - EOS + END (expect to_file).to visually_match 'table-grid-axes.pdf' end @@ -611,13 +611,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_border_width: [0.5, 1, 3, 1], table_border_style: [:solid, :dashed, :solid, :dotted], } - to_file = to_pdf_file <<~'EOS', 'table-border-per-side.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'table-border-per-side.pdf', pdf_theme: pdf_theme [grid=none] |=== | A | B | C | D |=== - EOS + END (expect to_file).to visually_match 'table-border-per-side.pdf' end @@ -628,12 +628,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_border_width: [0.5, 1], table_border_style: [:solid, :dashed], } - lines = (to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line).lines [grid=none] |=== | cell |=== - EOS + END (expect lines).to have_size 4 solid_lines = lines.select {|it| it[:style] == :solid && it[:color] == '000000' && it[:width] == 0.5 } @@ -652,12 +652,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_border_width: [0.5, 1, 2], table_border_style: [:solid, :dashed, :dotted], } - lines = (to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line).lines [grid=none] |=== | cell |=== - EOS + END (expect lines).to have_size 4 top_line = lines.find {|it| it[:style] == :solid && it[:color] == '000000' && it[:width] == 0.5 } @@ -679,12 +679,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_width: 0.5, table_border_style: [:solid, :dotted, :solid, :dashed], } - to_file = to_pdf_file <<~'EOS', 'table-grid-fallbacks.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'table-grid-fallbacks.pdf', pdf_theme: pdf_theme |=== | A | B | C | D |=== - EOS + END (expect to_file).to visually_match 'table-grid-fallbacks.pdf' end @@ -697,12 +697,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_border_style: [:solid, nil, :solid, nil], } (expect do - to_pdf <<~'EOS', pdf_theme: pdf_theme + to_pdf <<~'END', pdf_theme: pdf_theme |=== | A | B | C | D |=== - EOS + END end).to not_raise_exception end @@ -715,12 +715,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_width: [0.5, (prop == 'width' ? nil : 0.5)], table_grid_style: [:solid, (prop == 'style' ? nil : :solid)], } - to_pdf <<~'EOS', pdf_theme: pdf_theme + to_pdf <<~'END', pdf_theme: pdf_theme |=== | A | B | C | D |=== - EOS + END end end).to not_raise_exception end @@ -732,12 +732,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_width: nil, table_grid_color: nil, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line |=== | A | B | C | D |=== - EOS + END lines = pdf.lines (expect lines).to have_size 16 (expect lines.map {|it| it[:color] }.uniq).to eql %w(DDDDDD) @@ -752,12 +752,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_grid_width: nil, table_grid_color: nil, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line |=== | A | B | C | D |=== - EOS + END lines = pdf.lines (expect lines).to have_size 16 (expect lines.map {|it| it[:color] }.uniq).to eql %w(000000) @@ -771,13 +771,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_padding: 3, } - input = <<~'EOS' + input = <<~'END' |=== a|first last |=== - EOS + END to_file = to_pdf_file input, 'table-border-end-caps.pdf', pdf_theme: pdf_theme (expect to_file).to visually_match 'table-border-end-caps.pdf' @@ -787,7 +787,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Dimensions' do it 'should log error if no width is assigned to column' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true before table [cols=",50%,50%"] @@ -796,7 +796,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== after table - EOS + END text = pdf.text (expect text).to have_size 2 (expect text[0][:string]).to eql 'before table' @@ -806,7 +806,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should report file and line number in cannot fit error if sourcemap is enabled' do (expect do - pdf = to_pdf <<~'EOS', sourcemap: true, attribute_overrides: { 'docfile' => 'test.adoc' }, analyze: true + pdf = to_pdf <<~'END', sourcemap: true, attribute_overrides: { 'docfile' => 'test.adoc' }, analyze: true before table [cols="2m,49,49"] @@ -815,7 +815,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== after table - EOS + END text = pdf.text (expect text).to have_size 2 (expect text[0][:string]).to eql 'before table' @@ -824,22 +824,22 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not fail to fit text in cell' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== |Aaaaa Bbbbb Ccccc |*{zwsp}* Aaaaa_Bbbbb_Ccccc |Aaaaa_Bbbbb_Ccccc |Aaaaa_Bbbbb_Ccccc |A |=== - EOS + END (expect pdf.strings.index 'Aaaaa Bbbbb').to be 0 (expect pdf.strings.index 'Ccccc').to be 1 end it 'should not fail to fit image with no explicit width in cell' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image [width=10%] |=== |image:tux.png[] |=== - EOS + END images = pdf.images (expect images).to have_size 1 (expect images[0][:intrinsic_width]).to eql 204 @@ -847,12 +847,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should fit image using intrinsic width in autowidth cell' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image [%autowidth] |=== |image:tux.png[] |=== - EOS + END images = pdf.images (expect images).to have_size 1 (expect images[0][:intrinsic_width]).to eql 204 @@ -860,12 +860,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should fit image using explicit width in autowidth cell' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image [%autowidth] |=== |image:tux.png[pdfwidth=1.5in] |=== - EOS + END images = pdf.images (expect images).to have_size 1 (expect images[0][:intrinsic_width]).to eql 204 @@ -873,12 +873,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should fit image using percentage width in autowidth cell' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_cell_padding: 0 }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: { table_cell_padding: 0 }, analyze: :image [%autowidth] |=== |image:tux.png[width=25%] | image:tux.png[] |=== - EOS + END images = pdf.images (expect images).to have_size 2 (expect images[0][:intrinsic_width]).to eql 204 @@ -889,12 +889,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should fit passthrough image using percentage width in autowidth cell' do - input = <<~EOS + input = <<~END [%autowidth] |=== |see pass:[<img src="#{fixture_file 'tux.png'}" alt="tux" width="75%">] run |=== - EOS + END pdf = to_pdf input, pdf_theme: { table_cell_padding: 0 }, analyze: true text = pdf.text (expect text).to have_size 2 @@ -908,7 +908,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not break words in head row when autowidth option is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%autowidth] |=== |Operation |Operator @@ -925,14 +925,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do |divide |/ |=== - EOS + END (expect pdf.find_text 'Operation').not_to be_empty (expect pdf.find_text 'Operator').not_to be_empty end it 'should not break words in body rows when autowidth option is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%autowidth] |=== |Op @@ -945,7 +945,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |divide |=== - EOS + END (expect pdf.find_text 'add').not_to be_empty (expect pdf.find_text 'subtract').not_to be_empty @@ -954,7 +954,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should wrap text by character when autowidth option is set and cell forces table to page boundary' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%autowidth,cols=3*] |=== | 100 @@ -962,18 +962,18 @@ describe 'Asciidoctor::PDF::Converter - Table' do | Lorem ipsum dolor sit amet, elit fusce duis, voluptatem ut, mauris tempor orci odio sapien viverra ut, deserunt luctus. |=== - EOS + END (expect pdf.lines).to eql ['10', '0', 'Label', '1', 'Lorem ipsum dolor sit amet, elit fusce duis, voluptatem ut, mauris tempor orci odio', 'sapien viverra ut, deserunt luctus.'] end it 'should stretch table to width of bounds by default' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [grid=none,frame=sides] |=== |A |B |=== - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -982,12 +982,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not stretch autowidth table to width of bounds by default' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [%autowidth,grid=none,frame=sides] |=== |A |B |=== - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -996,13 +996,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should account for hard line breaks when computing natural width of table cell' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [%autowidth,grid=none,frame=sides] |=== |Everywhere that Mary went, + the lamb was sure to go. |=== - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -1011,7 +1011,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should assume width of empty line is 0 when computing natural width of table cell' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [%autowidth,grid=none,frame=sides] |=== |fee + @@ -1020,7 +1020,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do fo + fum |=== - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -1029,12 +1029,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should stretch autowidth table with stretch role to width of bounds' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [%autowidth.stretch,grid=none,frame=sides] |=== |A |B |=== - EOS + END lines = pdf.lines (expect lines).to have_size 2 @@ -1043,12 +1043,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should set width of autowidth table if explicit width is specified' do - input = <<~'EOS' + input = <<~'END' [%autowidth,width=50%,grid=cols,frame=sides] |=== |short |a much wider table column |=== - EOS + END pdf = to_pdf input, analyze: :line @@ -1064,12 +1064,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should apply equal width to columns by default when width attribute is set' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [frame=sides,grid=cols] |=== |a | bbbbb | c |=== - EOS + END lines = pdf.lines.uniq {|it| [it[:from][:x], it[:from][:y], it[:to][:x], it[:to][:y]] } (expect lines).to have_size 4 @@ -1081,12 +1081,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should apply automatic width to columns by default when autowidth option is set and width attribute is set' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line [%autowidth,frame=sides,grid=cols] |=== |a | bbbbb | a |=== - EOS + END lines = pdf.lines.uniq {|it| [it[:from][:x], it[:from][:y], it[:to][:x], it[:to][:y]] } (expect lines).to have_size 4 @@ -1098,7 +1098,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should allocate remaining width to autowidth column' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols="10,>~"] |=== |0x00 @@ -1107,7 +1107,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |0x01 |OK |=== - EOS + END (expect pdf.strings).to eql %w(0x00 UNSPECIFIED 0x01 OK) unspecified_text = (pdf.find_text 'UNSPECIFIED')[0] (expect unspecified_text[:x].floor).to be 476 @@ -1116,7 +1116,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should extend width of table to fit content in autowidth column when autowidth option is set on table' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%autowidth,cols="10,>~"] |=== |0x00 @@ -1125,7 +1125,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |0x01 |OK |=== - EOS + END (expect pdf.strings).to eql %w(0x00 UNSPECIFIED 0x01 OK) unspecified_text = (pdf.find_text 'UNSPECIFIED')[0] (expect unspecified_text[:x].floor).to be 81 @@ -1134,7 +1134,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not apply padding to cell if padding is nil' do - input = <<~'EOS' + input = <<~'END' [cols=2*] |=== |A1 @@ -1143,7 +1143,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |A2 |B2 |=== - EOS + END pdf = to_pdf input, pdf_theme: { table_cell_padding: 0 }, analyze: true b1_x = (pdf.find_unique_text 'B1')[:x] @@ -1155,7 +1155,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should account for line metrics in cell padding' do - input = <<~'EOS' + input = <<~'END' |=== |A |B @@ -1165,7 +1165,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |A2 |B2 |=== - EOS + END last_y = nil [5, [5, 5, 5, 5], [5, 5, 5, 5, 5]].each do |cell_padding| @@ -1181,7 +1181,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should account for font size when computing padding' do - input = <<~'EOS' + input = <<~'END' |=== |A |B @@ -1191,7 +1191,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |A2 |B2 |=== - EOS + END pdf = to_pdf input, pdf_theme: { table_font_size: 20 }, analyze: true a2_text = (pdf.find_text 'A2')[0] @@ -1200,7 +1200,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not accumulate cell padding between tables' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_cell_padding: [5, 5, 5, 5] }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_cell_padding: [5, 5, 5, 5] }, analyze: true |=== |A |B @@ -1230,7 +1230,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |A2 |B2 |=== - EOS + END first_a1_text = (pdf.find_text 'A1')[0] first_a2_text = (pdf.find_text 'A2')[0] @@ -1240,7 +1240,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should set padding on head cells the same as body cells by default' do - input = <<~'EOS' + input = <<~'END' [frame=none,grid=rows] |=== | Column A | Column B @@ -1248,7 +1248,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A1 | B1 |=== - EOS + END reference_pdf = to_pdf input, analyze: :line pdf = to_pdf input, pdf_theme: { table_cell_padding: [10, 3, 10, 3] }, analyze: :line @@ -1258,7 +1258,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should set padding on head cells as specified by table_head_cell_padding theme key' do - input = <<~'EOS' + input = <<~'END' [frame=none,grid=rows] |=== | Column A | Column B @@ -1266,7 +1266,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A1 | B1 |=== - EOS + END reference_pdf = to_pdf input, analyze: true pdf = to_pdf input, pdf_theme: { table_head_cell_padding: [10, 3, 10, 3] }, analyze: true @@ -1283,7 +1283,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do filler = (['filler'] * 40).join hard_line_break head_cell1 = %w(this is a very tall cell in the head row of this table).join hard_line_break head_cell2 = %w(this is an even taller cell also in the head row of this table).join hard_line_break - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{filler} [%header,cols=2*] @@ -1294,7 +1294,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |body cell |body cell |=== - EOS + END filler_page_nums = (pdf.find_text 'filler').map {|it| it[:page_number] } (expect filler_page_nums.uniq).to have_size 1 @@ -1307,7 +1307,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Basic table cell' do it 'should keep paragraphs in table cell separate' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== |all one line @@ -1318,7 +1318,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do paragraph 2 |=== - EOS + END cell1_text = pdf.find_text 'all one line' (expect cell1_text).not_to be_empty @@ -1332,13 +1332,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should normalize newlines and whitespace' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true |=== |He's a real nowhere man, Sitting in his nowhere land, Making all his nowhere plans\tfor nobody. |=== - EOS + END (expect pdf.text).to have_size 1 text = pdf.text[0][:string] (expect text).not_to include ' ' @@ -1349,7 +1349,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should strip whitespace after applying substitutions' do ['%autowidth', '%header%autowidth'].each do |table_attrs| - pdf = to_pdf <<~EOS, analyze: :line + pdf = to_pdf <<~END, analyze: :line [#{table_attrs}] |=== | text @@ -1368,7 +1368,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== | {empty} text |=== - EOS + END lines_by_page = pdf.lines.each_with_object({}) do |line, accum| (accum[line.delete :page_number] ||= []) << line @@ -1381,14 +1381,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should transform non-ASCII letters when text transform is uppercase' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_head_text_transform: 'uppercase' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_head_text_transform: 'uppercase' }, analyze: true |=== |über |étudier |cell |cell |=== - EOS + END text = pdf.text (expect text[0][:string]).to eql 'ÜBER' @@ -1401,13 +1401,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do 'lowercase' => ['heading in head', 'heading in body'], 'none' => ['Heading in head', 'Heading in body'], }.each do |transform, expected| - pdf = to_pdf <<~'EOS', pdf_theme: { table_head_text_transform: transform }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_head_text_transform: transform }, analyze: true |=== |Heading in head h|Heading in body |=== - EOS + END text = pdf.text (expect text[0][:string]).to eql expected[0] @@ -1416,12 +1416,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should honor horizontal alignment on cell' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols="1,>1"] |=== |a |z |=== - EOS + END page_width = pdf.pages[0][:size][0] midpoint = page_width * 0.5 @@ -1432,12 +1432,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should apply line height specified for cell' do - input = <<~'EOS' + input = <<~'END' [width=50%] |=== | A long table cell that wraps | Another table cell |=== - EOS + END reference_pdf = to_pdf input, analyze: true reference_spacing = (reference_pdf.find_unique_text %r/^A long/)[:y] - (reference_pdf.find_unique_text 'wraps')[:y] @@ -1450,7 +1450,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do (expect do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true |=== |before |start @@ -1460,7 +1460,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end |after |=== - EOS + END (expect pdf.pages.size).to eql 3 before_text = (pdf.find_text 'before')[0] @@ -1479,7 +1479,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do (expect do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true before [%unbreakable] @@ -1492,7 +1492,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end |last cell |=== - EOS + END (expect pdf.pages.size).to eql 3 before_text = (pdf.find_text 'before')[0] @@ -1512,7 +1512,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do (expect do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, sourcemap: true, attribute_overrides: { 'docfile' => 'test.adoc' }, analyze: true + pdf = to_pdf <<~END, sourcemap: true, attribute_overrides: { 'docfile' => 'test.adoc' }, analyze: true |=== |first cell |second cell @@ -1520,7 +1520,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do #{(['filler'] * 25).join blank_line} |last cell |=== - EOS + END (expect pdf.pages.size).to eql 3 (expect (pdf.find_unique_text 'first cell')[:page_number]).to eql 1 @@ -1533,7 +1533,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Strong table cell' do it 'should style text a strong table cell as bold' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=2*,width=50%] |=== |Item 1 @@ -1545,7 +1545,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do >s|Total |$15 |=== - EOS + END item_text = (pdf.find_text 'Item 1')[0] total_text = (pdf.find_text 'Total')[0] @@ -1556,7 +1556,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Monospaced table cell' do it 'should apply codespan style to text in a monospaced table cell' do - pdf = to_pdf <<~'EOS', pdf_theme: { codespan_font_size: 10.25 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { codespan_font_size: 10.25 }, analyze: true [cols="1m,1",width=50%] |=== m|site.title @@ -1565,7 +1565,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do m|site.url |The URL of the site. |=== - EOS + END monospaced_text = (pdf.find_text 'site.title')[0] (expect monospaced_text[:font_name]).to eql 'mplus1mn-regular' @@ -1574,13 +1574,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should apply codespan style with relative font size to text in a monospaced table cell' do - pdf = to_pdf <<~'EOS', pdf_theme: { codespan_font_size: '0.8em' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { codespan_font_size: '0.8em' }, analyze: true [cols=2*,width=50%] |=== m|site.url |The URL of the site. |=== - EOS + END monospaced_text = pdf.find_unique_text 'site.url' reference_text = pdf.find_unique_text 'The URL of the site.' @@ -1590,12 +1590,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should ignore line-height on codespan category when computing line metrics' do - input = <<~'EOS' + input = <<~'END' [cols=2*m,width=50%] |=== | A long table cell that wraps | Another table cell |=== - EOS + END reference_pdf = to_pdf input, analyze: true reference_spacing = (reference_pdf.find_unique_text %r/^A long/)[:y] - (reference_pdf.find_unique_text 'wraps')[:y] @@ -1607,7 +1607,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Head and header table cell' do it 'should style a header table cell like a cell in the head row by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%autowidth,cols="1h,3"] |=== | Vendor @@ -1622,7 +1622,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | Resolution | 3040x1440 |=== - EOS + END vendor_text = (pdf.find_text 'Vendor')[0] (expect vendor_text[:font_name]).to eql 'NotoSerif-Bold' @@ -1636,7 +1636,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_header_cell_font_style: 'italic', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [%header%autowidth,cols="1h,3"] |=== | Feature | Value @@ -1653,7 +1653,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | Resolution | 3040x1440 |=== - EOS + END feature_text = (pdf.find_text 'Feature')[0] (expect feature_text[:font_color]).to eql '222222' @@ -1670,7 +1670,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should apply line height specified for head to cell in table head' do - input = <<~'EOS' + input = <<~'END' [width=50%] |=== | Column header that wraps | Another column header @@ -1678,7 +1678,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | cell | cell |=== - EOS + END reference_pdf = to_pdf input, analyze: true reference_spacing = (reference_pdf.find_unique_text %r/^Column/)[:y] - (reference_pdf.find_unique_text 'wraps')[:y] @@ -1688,7 +1688,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should inherit line height specified on cell' do - input = <<~'EOS' + input = <<~'END' [width=50%] |=== | Column header that wraps | Another column header @@ -1696,7 +1696,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | cell | cell |=== - EOS + END reference_pdf = to_pdf input, analyze: true reference_spacing = (reference_pdf.find_unique_text %r/^Column/)[:y] - (reference_pdf.find_unique_text 'wraps')[:y] @@ -1711,7 +1711,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_background_color: nil, } - to_file = to_pdf_file <<~'EOS', 'table-transparent-header-cell.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'table-transparent-header-cell.pdf', pdf_theme: pdf_theme [%header%autowidth,cols="1h,3"] |=== | Feature | Value @@ -1728,7 +1728,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | Resolution | 3040x1440 |=== - EOS + END (expect to_file).to visually_match 'table-transparent-header-cell.pdf' end @@ -1742,7 +1742,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_foot_font_family: 'Helvetica', table_foot_font_color: '5d5d5d', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [%footer] |=== @@ -1759,7 +1759,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |Total |6 |=== - EOS + END total_text = pdf.find_unique_text 'Total' (expect total_text[:font_name]).to eql 'Helvetica-Bold' @@ -1770,17 +1770,17 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Literal table cell' do it 'should not apply substitutions' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== l|{asciidoctor-version} foo--bar |=== - EOS + END (expect pdf.lines[0]).to eql '{asciidoctor-version} foo--bar' end it 'should expand tabs and preserve indentation' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true |=== l| here @@ -1788,7 +1788,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do \t\tgo again |=== - EOS + END lines = pdf.lines (expect lines).to have_size 4 @@ -1797,11 +1797,11 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not double escape specialchars' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== l|< and > |=== - EOS + END (expect pdf.lines).to eql ['< and >'] end @@ -1811,11 +1811,11 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_font_size: 8, code_font_size: 10.5, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true |=== |normal cell l|literal cell |=== - EOS + END (expect (pdf.find_text 'normal cell')[0][:font_size].to_f).to eql 8.0 (expect (pdf.find_text 'literal cell')[0][:font_size].to_f).to eql 8.0 @@ -1827,13 +1827,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_font_size: 8, codespan_font_size: '0.9em', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .`code` in caption |=== |`code` in normal cell a|`code` in AsciiDoc cell |=== - EOS + END code_texts = pdf.find_text 'code' (expect code_texts).to have_size 3 @@ -1846,12 +1846,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Verse table cell' do it 'should support verse if supported by core' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== v|foo bar |=== - EOS + END foobar_text = (pdf.find_text 'foo bar')[0] (expect foobar_text).not_to be_nil @@ -1860,7 +1860,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'AsciiDoc table cell' do it 'should convert blocks in an AsciiDoc table cell' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== a| [start=10] @@ -1873,12 +1873,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do my shoe |=== - EOS + END (expect pdf.lines).to eql ['10. ten', '11. eleven', '12. twelve', 'buckle', 'my', 'shoe'] end it 'should honor horizontal alignment on AsciiDoc table cell' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=1a] |=== |left @@ -1893,7 +1893,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== |right |=== - EOS + END page_width = pdf.pages[0][:size][0] midpoint = page_width * 0.5 @@ -1907,7 +1907,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not honor horizontal alignment on AsciiDoc table cell that contains non-paragraph blocks' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=>1a] |=== | @@ -1917,7 +1917,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do left |=== - EOS + END page_width = pdf.pages[0][:size][0] midpoint = page_width * 0.5 @@ -1927,7 +1927,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should convert nested table' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols="1,2a"] |=== |Normal cell @@ -1937,7 +1937,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do !Nested table cell 1 !Nested table cell 2 !=== |=== - EOS + END (expect pdf.lines.any? {|l| l.include? '!' }).to be false (expect pdf.lines).to have_size 2 @@ -1949,7 +1949,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not compound font scale in nested document' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_font_size: 21 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_font_size: 21 }, analyze: true |=== |foo a| @@ -1959,13 +1959,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do !=== baz |=== - EOS + END (expect pdf.text.map {|it| it[:font_size] }.uniq).to eql [21] end it 'should apply uniform font scale to table and nested table' do - pdf = to_pdf <<~'EOS', pdf_theme: { sidebar_font_size: 8.4 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { sidebar_font_size: 8.4 }, analyze: true **** before |=== @@ -1978,13 +1978,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do baz |=== **** - EOS + END (expect pdf.text.map {|it| it[:font_size] }.uniq).to eql [8.4] end it 'should restore counter after computing height of table cell in scratch document' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=2*] |=== a|{counter:req} @@ -1992,19 +1992,19 @@ describe 'Asciidoctor::PDF::Converter - Table' do a|{counter:req} |Second requirement. |=== - EOS + END (expect pdf.lines).to eql ['1 First requirement.', '2 Second requirement.'] end it 'should align bullet for list item to left cell boundary' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true * yin - EOS + END reference_x = ((pdf.find_unique_text ?\u2022)[:x] - 48.24 + 3).round 2 - input = <<~'EOS' + input = <<~'END' [cols=4*,grid=cols,frame=none] |=== |foo @@ -2014,7 +2014,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do * ying * yang |=== - EOS + END pdf = to_pdf input, analyze: :line @@ -2029,7 +2029,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should capture footnotes in AsciiDoc table cell and render them with other footnotes' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true before{empty}footnote:[Footnote before table] |=== @@ -2037,7 +2037,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== after{empty}footnote:[Footnote after table] - EOS + END expected_lines = [ 'before[1]', @@ -2056,12 +2056,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do prose_margin_bottom: 0, table_cell_padding: [5, 0, 5, 0], } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true |=== a| * abc |=== - EOS + END p1_lines = pdf.lines (pdf.page 1)[:text] (expect p1_lines).to eql ['• abc'] @@ -2073,7 +2073,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do base_font_family: 'M+ 1mn', prose_margin_bottom: 2, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true before |=== @@ -2083,7 +2083,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== after - EOS + END p1_lines = pdf.lines (pdf.page 1)[:text] (expect p1_lines).to eql ['before', '• abc', '• xyz', 'after'] @@ -2096,7 +2096,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do code_border_radius: 0, } - input = <<~EOS + input = <<~END [cols="1,1a",frame=none,grid=none] |=== | cell @@ -2112,7 +2112,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do after block |=== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :line lines = pdf.lines @@ -2131,7 +2131,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should not add margin below last block of content in AsciiDoc table cell' do - input = <<~'EOS' + input = <<~'END' [frame=ends,grid=none] |=== a| @@ -2139,7 +2139,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do sidebar **** |=== - EOS + END horizontal_lines = (to_pdf input, analyze: :line).lines .select {|it| it[:from][:y] == it[:to][:y] }.sort_by {|it| -it[:from][:y] } @@ -2148,7 +2148,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should honor vertical alignment on cell' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=3*] |=== a| 1 + @@ -2161,7 +2161,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do .>a| bottom |=== - EOS + END ref_middle = (pdf.find_text '2')[0][:y] ref_bottom = (pdf.find_text '3')[0][:y] @@ -2172,26 +2172,26 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should align middle vertical alignment on cell to center' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%autowidth] |=== .<| Ay< Ay< .^| Ay^ |=== - EOS + END expected = pdf.text[0][:y] - (pdf.text[0][:y] - pdf.text[1][:y]) * 0.5 (expect expected - pdf.text[2][:y]).to be_between 0, 0.5 end it 'should coerce middle vertical alignment on head cell to center' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%header,width=50%] |=== ^.^| Short ^.^| Something Rather Long ^.^| Last |=== - EOS + END long_text = pdf.find_unique_text 'Something' short_text = pdf.find_unique_text 'Short' @@ -2200,12 +2200,12 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should apply cell padding to AsciiDoc table cell' do [10, [10], [10, 10, 10, 10, 10]].each do |padding| - pdf = to_pdf <<~'EOS', pdf_theme: { table_cell_padding: padding }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_cell_padding: padding }, analyze: true |=== | a a| b | c | a | b | c |=== - EOS + END a_texts = pdf.find_text 'a' b_texts = pdf.find_text 'b' @@ -2222,11 +2222,11 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_font_family: 'Helvetica', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true |=== | normal table cell a| AsciiDoc table cell |=== - EOS + END normal_text = (pdf.find_text 'normal table cell')[0] (expect normal_text[:font_name]).to eql 'Helvetica-Oblique' @@ -2245,7 +2245,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_font_family: 'Helvetica', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .... literal block outside table .... @@ -2263,7 +2263,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do .... !=== |=== - EOS + END outside_text = (pdf.find_text 'literal block outside table')[0] (expect outside_text[:font_name]).to eql 'mplus1mn-regular' @@ -2282,14 +2282,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_font_size: 9, sidebar_font_size: '0.9em', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true |=== a| **** sidebar **** |=== - EOS + END sidebar_text = pdf.find_unique_text 'sidebar' (expect sidebar_text[:font_size]).to eql 8.1 @@ -2303,7 +2303,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_font_size: 9, } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true |=== a| .... @@ -2319,7 +2319,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do .... |=== ==== - EOS + END outside_text = (pdf.find_text 'literal block outside sidebar')[0] (expect outside_text[:font_name]).to eql 'mplus1mn-regular' @@ -2331,7 +2331,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not compound font scale when computing font size for nested blocks' do pdf_theme = { heading_h2_font_size: 20, table_font_size: 5.25 } - input = <<~'EOS' + input = <<~'END' before table |=== @@ -2349,7 +2349,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do **** ==== |=== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true (expect (pdf.find_unique_text 'before table')[:font_size]).to eql 10.5 @@ -2368,11 +2368,11 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_font_family: 'Helvetica', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true |=== | normal table cell a| AsciiDoc table cell |=== - EOS + END normal_text = (pdf.find_text 'normal table cell')[0] (expect normal_text[:font_name]).to eql 'Helvetica-Oblique' @@ -2393,7 +2393,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do } (expect do - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, enable_footer: true, analyze: true |=== |before a|start @@ -2403,7 +2403,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end |after |=== - EOS + END (expect pdf.pages.size).to eql 3 p2_text = pdf.find_text page_number: 2 @@ -2417,7 +2417,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do (expect do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true |=== |before a|start @@ -2427,7 +2427,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end |after |=== - EOS + END (expect pdf.pages.size).to eql 3 before_text = (pdf.find_text 'before')[0] @@ -2446,7 +2446,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do (expect do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true before [%unbreakable] @@ -2459,7 +2459,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end |last cell |=== - EOS + END (expect pdf.pages.size).to eql 3 before_text = (pdf.find_text 'before')[0] @@ -2479,7 +2479,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do (expect do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, sourcemap: true, attribute_overrides: { 'docfile' => 'test.adoc' }, analyze: true + pdf = to_pdf <<~END, sourcemap: true, attribute_overrides: { 'docfile' => 'test.adoc' }, analyze: true before table |=== @@ -2490,7 +2490,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do #{(['* list item'] * 50).join blank_line} |last cell |=== - EOS + END (expect pdf.pages).to have_size 3 (expect (pdf.find_unique_text 'before list')[:page_number]).to eql 2 @@ -2501,7 +2501,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not warn if cell exceeds page height in scratch document' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [%unbreakable] -- |=== @@ -2515,7 +2515,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do -- after - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.find_unique_text 'page two').to be_nil @@ -2525,14 +2525,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not warn if cell explicitly advances to new page without adding content to subsequent page' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== a| paragraph <<< |=== - EOS + END (expect pdf.pages).to have_size 1 end).to not_log_message @@ -2540,7 +2540,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not warn if cell overflows page without adding content to subsequent page' do (expect do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true |=== a| paragraph @@ -2549,7 +2549,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do paragraph |=== - EOS + END (expect pdf.pages).to have_size 1 end).to not_log_message @@ -2557,7 +2557,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should warn if cell exceeds more than one page height' do (expect do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true |=== a| page one @@ -2570,7 +2570,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do page three |=== - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.find_unique_text 'page two').to be_nil @@ -2579,7 +2579,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should preserve left margin on page that follows page containing a table with an AsciiDoc table cell' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true == Section Title image::tall.svg[pdfwidth=38mm] @@ -2605,7 +2605,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do .list title * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore. - EOS + END first_page_text = pdf.text.select {|it| it[:page_number] == 1 } second_page_text = pdf.text.select {|it| it[:page_number] == 2 } @@ -2619,7 +2619,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should account for top and bottom padding when computing natural height of table cell' do pdf_theme = { page_margin: 36, page_size: 'Letter', table_cell_padding: 50, block_margin_bottom: 10 } with_content_spacer 10, 575 do |spacer_path| - input = <<~EOS + input = <<~END |=== a| before image @@ -2628,7 +2628,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do after image |=== - EOS + END (expect do pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -2646,7 +2646,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Caption' do it 'should add title as caption above table by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true .Table description |=== | Col A | Col B @@ -2657,7 +2657,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 | B2 |=== - EOS + END caption_text = pdf.text[0] (expect caption_text[:string]).to eql 'Table 1. Table description' @@ -2666,7 +2666,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should add title as caption below table if table_caption_end key in theme is bottom' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_caption_end: 'bottom' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_caption_end: 'bottom' }, analyze: true .Table description |=== | Col A | Col B @@ -2677,7 +2677,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | A2 | B2 |=== - EOS + END caption_text = pdf.text[-1] (expect caption_text[:string]).to eql 'Table 1. Table description' @@ -2685,7 +2685,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should restrict caption to width of table by default', visual: true do - to_file = to_pdf_file <<~'EOS', 'table-caption-width.pdf', pdf_theme: { caption_align: 'center' } + to_file = to_pdf_file <<~'END', 'table-caption-width.pdf', pdf_theme: { caption_align: 'center' } .A rather long description for this table [%header%autowidth] |=== @@ -2721,13 +2721,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do | E2 | F2 |=== - EOS + END (expect to_file).to visually_match 'table-caption-width.pdf' end it 'should not restrict caption to width of table if table_caption_max_width key in theme is none' do - pdf = to_pdf <<~'EOS', pdf_theme: { caption_align: 'center', table_caption_max_width: 'none' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { caption_align: 'center', table_caption_max_width: 'none' }, analyze: true :table-caption!: .A rather long description for this table @@ -2765,7 +2765,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | E2 | F2 |=== - EOS + END caption_texts = pdf.find_text 'A rather long description for this table' (expect caption_texts).to have_size 3 @@ -2773,7 +2773,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should set caption to percentage of table width as specified by argument to fit-content function' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_caption_max_width: 'fit-content(50%)' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_caption_max_width: 'fit-content(50%)' }, analyze: true :!table-caption: .A rather long description for this table @@ -2781,14 +2781,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== | Col A | Col B | Col C | Col D |=== - EOS + END - expected_lines = <<~'EOS'.lines.map(&:chomp) + expected_lines = <<~'END'.lines.map(&:chomp) A rather long description for this table Col A Col B Col C Col D - EOS + END (expect pdf.lines).to eql expected_lines @@ -2804,7 +2804,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_caption_text_align: 'left', table_caption_max_width: '15%', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true :table-caption!: .A rather long description for this table @@ -2812,7 +2812,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== | Col A | Col B |=== - EOS + END caption_texts = pdf.find_text font_name: 'NotoSerif-Italic' (expect caption_texts).to have_size 3 @@ -2822,14 +2822,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should allow theme to constrain caption to fixed width' do [144, '144'].each do |it| pdf_theme = { table_caption_max_width: it } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true :table-caption!: .A rather long description for this table |=== | Col A | Col B |=== - EOS + END caption_lines = pdf.lines pdf.find_text font_name: 'NotoSerif-Italic' (expect caption_lines).to eql ['A rather long description for', 'this table'] @@ -2837,14 +2837,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should allow theme to set caption alignment to inherit from table' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_caption_align: 'inherit' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_caption_align: 'inherit' }, analyze: true .Right-aligned caption [width=25%,align=right] |=== |1 |2 |3 |4 |=== - EOS + END first_cell_text = (pdf.find_text '1')[0] caption_text = (pdf.find_text %r/^Table 1\./)[0] @@ -2857,14 +2857,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_caption_text_align: 'left', table_caption_max_width: 'fit-content(50%)', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Right-aligned caption [width=25%,align=right] |=== |1 |2 |3 |4 |=== - EOS + END caption_prefix_text = pdf.find_unique_text 'Table 1.' caption_wrap_text = pdf.find_unique_text 'caption' @@ -2879,14 +2879,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do table_caption_text_align: 'inherit', table_caption_max_width: 'fit-content(50%)', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true .Right-aligned caption [width=25%,align=right] |=== |1 |2 |3 |4 |=== - EOS + END caption_prefix_text = pdf.find_unique_text 'Table 1.' caption_wrap_text = pdf.find_unique_text 'caption' @@ -2898,7 +2898,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Table alignment' do it 'should allow theme to customize default alignment of table' do - pdf = to_pdf <<~'EOS', pdf_theme: { table_align: 'right' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { table_align: 'right' }, analyze: true [cols=3*,width=50%] |=== |RIGHT |B1 |C1 @@ -2912,7 +2912,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |A2 |B2 |C2 |A3 |B3 |C3 |=== - EOS + END cell_right = (pdf.find_text 'RIGHT')[0] cell_left = (pdf.find_text 'LEFT')[0] @@ -2921,7 +2921,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should allow position of table to be set using align attribute on table' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=3*,width=50%] |=== |LEFT |B1 |C1 @@ -2935,7 +2935,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |A2 |B2 |C2 |A3 |B3 |C3 |=== - EOS + END cell_right_text = (pdf.find_text 'RIGHT')[0] cell_left_text = (pdf.find_text 'LEFT')[0] @@ -2946,7 +2946,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not mangle margin box on subsequent pages if table with alignment crosses page boundary' do blank_line = %(\n\n) - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true #{(['filler'] * 25).join blank_line} [%autowidth,align=right] @@ -2966,7 +2966,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do #{(['filler'] * 22).join blank_line} #{(['* list item'] * 6).join ?\n} - EOS + END page_width = pdf.pages[0][:size][0] a1_text = (pdf.find_text 'A1')[0] @@ -2982,7 +2982,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should set width of aligned table relative to bounds' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [width=25%,align=right] |=== |A | B @@ -3008,7 +3008,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |=== **** ==== - EOS + END page_width = pdf.pages[0][:size][0] first_a1_text = (pdf.find_text 'A1')[0] @@ -3019,7 +3019,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should break line on any CJK character if value of scripts attribute is cjk' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :scripts: cjk :pdf-theme: default-with-font-fallbacks @@ -3027,7 +3027,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do | AsciiDoc 是一个人类可读的文件格式,语义上等同于 DocBook 的 XML,但使用纯文本标记了约定。可以使用任何文本编辑器创建文件把 AsciiDoc 和阅读“原样”,或呈现为HTML 或由 DocBook 的工具链支持的任何其他格式,如 PDF,TeX 的,Unix 的手册页,电子书,幻灯片演示等。 | AsciiDoc は、意味的には DocBook XML のに相当するが、プレーン·テキスト·マークアップの規則を使用して、人間が読めるドキュメントフォーマット、である。 AsciiDoc は文書は、任意のテキストエディタを使用して作成され、「そのまま"または、HTML や DocBook のツールチェーンでサポートされている他のフォーマット、すなわち PDF、TeX の、Unix の man ページ、電子書籍、スライドプレゼンテーションなどにレンダリングすることができます。 |=== - EOS + END lines = pdf.lines (expect lines).to have_size 8 (expect lines[0]).to end_with '任何' @@ -3039,7 +3039,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Cell spanning' do it 'should honor colspan on cell in head row' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=2*^] |=== 2+|Columns @@ -3047,7 +3047,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |cell |cell |=== - EOS + END page_width = (get_page_size pdf)[0] midpoint = page_width * 0.5 @@ -3058,7 +3058,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should honor colspan on cell in body row' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=2*^] |=== |cell @@ -3066,7 +3066,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do 2+|one big cell |=== - EOS + END page_width = (get_page_size pdf)[0] midpoint = page_width * 0.5 @@ -3078,13 +3078,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not allow colspan to cause table to exceed width of bounds' do pdf_theme = { page_margin: 36 } - input = <<~'EOS' + input = <<~'END' [cols="1,1,1,2",grid=none,frame=sides] |=== |a 3+|b 2+|c |d >|z |=== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -3098,13 +3098,13 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not allow colspan to cause stretch table with autowidth columns to exceed width of bounds' do pdf_theme = { page_margin: 36 } - input = <<~'EOS' + input = <<~'END' [.stretch%autowidth,grid=none,frame=sides] |=== |a 3+|b 2+|c |dddddddddddddddddddddddddddddddddddddddddddddddddd >|z |=== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -3118,14 +3118,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do it 'should not allow colspan to cause table to exceed width of bounds when also using rowspan' do pdf_theme = { page_margin: 36 } - input = <<~'EOS' + input = <<~'END' [cols="1,1,1,1,1,4",grid=none,frame=sides] |=== .3+|a 5.+|bcd .2+|e |f |g |h >|z |one |more |time |fin |=== - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines @@ -3138,7 +3138,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should honor rowspan on cell in body row' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [cols=2*^.^] |=== .2+|one big cell @@ -3146,7 +3146,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do |cell |=== - EOS + END big_cell_text = (pdf.find_text 'one big cell')[0] top_cell_text, bottom_cell_text = pdf.find_text 'cell' @@ -3158,7 +3158,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should advance table to next page if rowspan in first row does not fit on current page' do - input = <<~EOS + input = <<~END #{(['filler'] * 5).join %(\n\n)} [cols=2*] @@ -3169,7 +3169,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do .30+|Group B |Member 1 #{29.times.map {|idx| '|Member ' + idx.next.to_s }.join ?\n} |=== - EOS + END pdf = to_pdf input, analyze: true (expect pdf.pages).to have_size 3 @@ -3181,7 +3181,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do context 'Arrange block' do it 'should advance table to next page to avoid it from breaking if %unbreakable option is set on table' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true image::tall.svg[pdfwidth=75mm] [%unbreakable] @@ -3190,7 +3190,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do #{(1.upto 5).map {|idx| %(| A#{idx} | B#{idx}) }.join %(\n\n)} |=== - EOS + END column_a_text = pdf.find_text 'Column A' (expect column_a_text).to have_size 1 @@ -3200,7 +3200,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should advance table with ID to next page to avoid it from breaking if %unbreakable option is set on table' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END image::tall.svg[pdfwidth=75mm] [#t1%unbreakable] @@ -3209,14 +3209,14 @@ describe 'Asciidoctor::PDF::Converter - Table' do #{(1.upto 5).map {|idx| %(| A#{idx} | B#{idx}) }.join %(\n\n)} |=== - EOS + END (expect (table_dest = get_dest pdf, 't1')).not_to be_nil (expect table_dest[:page_number]).to be 2 end it 'should advance table with caption to next page to avoid it from breaking if %unbreakable option is set on table' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true image::tall.svg[pdfwidth=75mm] .Title @@ -3226,7 +3226,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do #{(1.upto 5).map {|idx| %(| A#{idx} | B#{idx}) }.join %(\n\n)} |=== - EOS + END title_text = pdf.find_unique_text 'Table 1. Title' (expect title_text[:page_number]).to be 2 @@ -3238,7 +3238,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should keep caption with table if %breakable option is set on table' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true image::tall.svg[pdfwidth=80mm] .Title that goes on #{['and on'] * 50 * ' '} @@ -3248,7 +3248,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do #{(1.upto 5).map {|idx| %(| A#{idx} | B#{idx}) }.join %(\n\n)} |=== - EOS + END title_text = pdf.find_unique_text %r/^Table 1\. / (expect title_text[:page_number]).to be 2 @@ -3258,7 +3258,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do end it 'should keep ID with table if %breakable option is set on table' do - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END image::tall.svg[pdfwidth=85mm] [#t1%breakable] @@ -3267,7 +3267,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do #{(1.upto 5).map {|idx| %(| A#{idx} | B#{idx}) }.join %(\n\n)} |=== - EOS + END table_dest = get_dest pdf, 't1' (expect table_dest[:page_number]).to be 2 diff --git a/spec/thematic_break_spec.rb b/spec/thematic_break_spec.rb index 37fdcea6..89bc8990 100644 --- a/spec/thematic_break_spec.rb +++ b/spec/thematic_break_spec.rb @@ -4,7 +4,7 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Thematic Break' do it 'should apply margin bottom to thematic break' do - input = <<~'EOS' + input = <<~'END' before ''' @@ -12,7 +12,7 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do **** after **** - EOS + END { 'base' => 12.0, 'default' => 18.0 }.each do |theme, bottom_margin| lines = (to_pdf input, attribute_overrides: { 'pdf-theme' => theme }, analyze: :line).lines break_line = lines[0] @@ -29,7 +29,7 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do sidebar_background_color: 'transparent', thematic_break_border_color: '00EE00', } - input = <<~'EOS' + input = <<~'END' **** before **** @@ -39,7 +39,7 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do **** after **** - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines sidebar_h_lines = lines.select {|it| it[:from][:y] == it[:to][:y] && it[:color] == '0000EE' }.sort_by {|it| -it[:from][:y] } break_line = lines.find {|it| it[:color] == '00EE00' } @@ -57,13 +57,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do thematic_break_padding: 0, block_margin_bottom: 10, } - input = <<~'EOS' + input = <<~'END' ''' **** after **** - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines sidebar_h_lines = lines.select {|it| it[:from][:y] == it[:to][:y] && it[:color] == '0000EE' }.sort_by {|it| -it[:from][:y] } break_line = lines.find {|it| it[:color] == '00EE00' } @@ -80,7 +80,7 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do thematic_break_margin_top: 3, thematic_break_padding: nil, } - input = <<~'EOS' + input = <<~'END' **** before **** @@ -90,7 +90,7 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do **** after **** - EOS + END lines = (to_pdf input, pdf_theme: pdf_theme, analyze: :line).lines sidebar_h_lines = lines.select {|it| it[:from][:y] == it[:to][:y] && it[:color] == '0000EE' }.sort_by {|it| -it[:from][:y] } break_line = lines.find {|it| it[:color] == '00EE00' } @@ -99,13 +99,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do end it 'should apply side padding to thematic break' do - pdf = to_pdf <<~'EOS', pdf_theme: { thematic_break_padding: [0, 36] }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { thematic_break_padding: [0, 36] }, analyze: :line before --- after - EOS + END break_line = pdf.lines[0] (expect break_line[:from][:x]).to eql 84.24 @@ -113,13 +113,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do end it 'should draw a horizonal rule at the location of a thematic break' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line before --- after - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -129,13 +129,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do end it 'should set width of thematic break to 0.5 if not set in theme' do - pdf = to_pdf <<~'EOS', pdf_theme: { thematic_break_border_width: nil }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { thematic_break_border_width: nil }, analyze: :line before --- after - EOS + END lines = pdf.lines (expect lines).to have_size 1 @@ -149,13 +149,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do thematic_break_border_style: 'dashed', thematic_break_border_color: 'a0a0a0', } - to_file = to_pdf_file <<~'EOS', 'thematic-break-line-style-dashed.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'thematic-break-line-style-dashed.pdf', pdf_theme: pdf_theme before --- after - EOS + END (expect to_file).to visually_match 'thematic-break-line-style-dashed.pdf' end @@ -166,13 +166,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do thematic_break_border_style: 'dotted', thematic_break_border_color: 'aa0000', } - to_file = to_pdf_file <<~'EOS', 'thematic-break-line-style-dotted.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'thematic-break-line-style-dotted.pdf', pdf_theme: pdf_theme before --- after - EOS + END (expect to_file).to visually_match 'thematic-break-line-style-dotted.pdf' end @@ -183,13 +183,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do thematic_break_border_style: 'double', thematic_break_border_color: 'a0a0a0', } - to_file = to_pdf_file <<~'EOS', 'thematic-break-line-style-double.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'thematic-break-line-style-double.pdf', pdf_theme: pdf_theme before --- after - EOS + END (expect to_file).to visually_match 'thematic-break-line-style-double.pdf' end @@ -200,13 +200,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do thematic_break_border_color: nil, } - lines = (to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line).lines before --- after - EOS + END (expect lines).to have_size 1 (expect lines[0][:color]).to eql '0000FF' @@ -218,13 +218,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do thematic_break_border_color: nil, } - lines = (to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line).lines before --- after - EOS + END (expect lines).to have_size 1 (expect lines[0][:color]).to eql '000000' @@ -235,13 +235,13 @@ describe 'Asciidoctor::PDF::Converter - Thematic Break' do thematic_break_border_color: 'transparent', } - lines = (to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line).lines before --- after - EOS + END (expect lines).to be_empty end diff --git a/spec/theme_loader_spec.rb b/spec/theme_loader_spec.rb index 9133d59c..55f0628b 100644 --- a/spec/theme_loader_spec.rb +++ b/spec/theme_loader_spec.rb @@ -29,7 +29,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should store flattened keys in OpenStruct' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' page: size: A4 base: @@ -39,7 +39,7 @@ describe Asciidoctor::PDF::ThemeLoader do admonition: label: font_style: bold - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme).to respond_to :page_size @@ -49,7 +49,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should not flatten admonition icon keys' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' admonition: icon: tip: @@ -60,7 +60,7 @@ describe Asciidoctor::PDF::ThemeLoader do name: far-sticky-note stroke_color: 0000ff size: 24 - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.admonition_icon_tip).to be_a Hash @@ -70,18 +70,18 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should ignore admonition icon type def if value is falsy' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' admonition: icon: advice: ~ - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.admonition_icon_advice).to be_nil end it 'should replace hyphens in key names with underscores' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' page-size: A4 base: font-family: Times-Roman @@ -91,7 +91,7 @@ describe Asciidoctor::PDF::ThemeLoader do icon: tip: stroke-color: FFFF00 - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme).to respond_to :page_size @@ -103,14 +103,14 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should not replace hyphens with underscores in role names' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' role: flaming-red: font-color: ff0000 so-very-blue: font: color: 0000ff - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme).to respond_to 'role_flaming-red_font_color' @@ -120,11 +120,11 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should allow role to contain uppercase characters' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' role: BOLD: font-style: bold - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme).to respond_to 'role_BOLD_font_style' @@ -132,7 +132,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should coerce value of keys that end in content to a string' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' menu: caret_content: - '>' @@ -146,7 +146,7 @@ describe Asciidoctor::PDF::ThemeLoader do content: true right: content: 2 * 2 - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.menu_caret_content).to eql '[">"]' @@ -157,7 +157,7 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should remap align keys to text-align keys' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' base: align: center heading: @@ -170,7 +170,7 @@ describe Asciidoctor::PDF::ThemeLoader do caption: align: $base-align text-align: $heading-align - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.base_align).to be_nil @@ -188,14 +188,14 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should remap table-caption-side key to table-caption-end' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' table: caption: side: bottom image: caption: end: $table-caption-side - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.table_caption_side).to be_nil @@ -206,10 +206,10 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should remap kbd-separator key to kbd-separator-content key and warn' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' kbd: separator: '-' - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.kbd_separator).to be_nil @@ -219,13 +219,13 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should remap outline-list category to list category and warn' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' outline-list: item-spacing: 6 footnotes: margin-top: $outline-list-item-spacing item-spacing: $outline_list_item_spacing / 2 - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.outline_list_item_spacing).to be_nil @@ -237,13 +237,13 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should remap blockquote category to quote category and warn' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' blockquote: font-color: 4A4A4A border-color: $blockquote-font-color verse: font-color: $blockquote-font-color - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.blockquote_font_color).to be_nil @@ -255,12 +255,12 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should remap key category to kbd category and warn' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' key: border-color: CCCCCC background-color: EFEFEF font-color: $key-border-color - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.key_border_color).to be_nil @@ -271,12 +271,12 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should remap literal category to codespan category and warn' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' literal: font-family: M+ 1mn verse: font-family: $literal-font-family - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.literal_font_family).to be_nil @@ -286,7 +286,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should neutralize bottom padding hack on example, quote, sidebar, and verse categories' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' example: padding: [12, 12, 0, 12] quote: @@ -295,7 +295,7 @@ describe Asciidoctor::PDF::ThemeLoader do padding: [12, 12, 0, 12] verse: padding: [6, 12, -6, 14] - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.example_padding).to eql [12, 12, 12, 12] @@ -305,17 +305,17 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should not neutralize bottom padding hack if top padding is negative' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' quote: padding: [-3, 12, -3, 14] - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.quote_padding).to eql [-3, 12, -3, 14] end it 'should expand variables in value of keys that end in _content' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' page: size: A4 base: @@ -326,7 +326,7 @@ describe Asciidoctor::PDF::ThemeLoader do content: 2 * $base_font_size right: content: $page_size - EOS + END theme = subject.new.load theme_data (expect theme).to be_an OpenStruct (expect theme.footer_verso_left_content).to eql '2 * 12' @@ -334,28 +334,28 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should ignore font key if value is not a Hash' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font: ~ base_font_color: 333333 - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_nil (expect theme.base_font_color).to eql '333333' end it 'should ignore font_catalog key if value is not a Hash' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font: catalog: ~ base_font_color: 333333 - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_nil (expect theme.base_font_color).to eql '333333' end it 'should ignore unrecognized font subkeys' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font: catalog: Yolo: @@ -366,7 +366,7 @@ describe Asciidoctor::PDF::ThemeLoader do yin: yang base: font_family: Yolo - EOS + END theme = subject.new.load theme_data (expect theme.foo).to be_nil (expect theme.yin).to be_nil @@ -375,13 +375,13 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should ignore font if value is falsy' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font: catalog: Fancy: normal: /path/to/fancy.ttf Yolo: ~ - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to have_size 1 (expect theme.font_catalog).to have_key 'Fancy' @@ -390,11 +390,11 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should allow font to be declared once for all styles using string value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font: catalog: Serif: /path/to/serif-font.ttf - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog['Serif']).to be_a Hash @@ -406,12 +406,12 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should allow font to be declared once for all styles using * style' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font: catalog: Serif: '*': /path/to/serif-font.ttf - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog['Serif']).to be_a Hash @@ -423,13 +423,13 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should allow single style to be customized for font defined using * key' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font: catalog: Serif: '*': /path/to/serif-font.ttf bold: /path/to/bold-serif-font.ttf - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog['Serif']).to be_a Hash @@ -441,12 +441,12 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should allow regular to be used as alias for normal style when defining fonts' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font: catalog: Serif: regular: /path/to/serif-regular.ttf - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog['Serif']).to be_a Hash @@ -454,7 +454,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should allow font catalog and font fallbacks to be defined as flat keys' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font_catalog: Serif: normal: /path/to/serif-font.ttf @@ -462,7 +462,7 @@ describe Asciidoctor::PDF::ThemeLoader do normal: /path/to/fallback-font.ttf font_fallbacks: - Fallback - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog['Serif']).to be_a Hash @@ -472,12 +472,12 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should set font fallbacks to empty array if value is falsy' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' font_catalog: Serif: normal: /path/to/serif-font.ttf font_fallbacks: ~ - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog['Serif']).to be_a Hash @@ -509,21 +509,21 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should load and extend themes specified by extends array' do - with_pdf_theme_file <<~'EOS' do |custom_theme_path| + with_pdf_theme_file <<~'END' do |custom_theme_path| base: font-family: Times-Roman - EOS - with_pdf_theme_file <<~'EOS' do |red_theme_path| + END + with_pdf_theme_file <<~'END' do |red_theme_path| base: font-color: ff0000 - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - #{File.basename custom_theme_path} - ./#{File.basename red_theme_path} base: text-align: justify - EOS + END theme = subject.load_file theme_path, nil, (File.dirname theme_path) (expect theme.base_text_align).to eql 'justify' (expect theme.base_font_family).to eql 'Times-Roman' @@ -534,12 +534,12 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should be able to extend them from absolute path' do - with_pdf_theme_file <<~EOS do |theme_path| + with_pdf_theme_file <<~END do |theme_path| extends: - #{fixture_file 'custom-theme.yml'} base: text-align: justify - EOS + END theme = subject.load_file theme_path (expect theme.base_text_align).to eql 'justify' (expect theme.base_font_family).to eql 'Times-Roman' @@ -547,17 +547,17 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should extend built-in default theme if value of extends entry is default' do - with_pdf_theme_file <<~'EOS' do |red_theme_path| + with_pdf_theme_file <<~'END' do |red_theme_path| base: font-color: ff0000 - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - default - #{File.basename red_theme_path} base: font-color: 0000ff - EOS + END theme = subject.load_file theme_path, nil, (File.dirname theme_path) (expect theme.base_font_family).to eql 'Noto Serif' (expect theme.base_font_color).to eql '0000FF' @@ -566,15 +566,15 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should extend built-in base theme last if listed last in extends entry' do - with_pdf_theme_file <<~'EOS' do |heading_font_color_theme_path| + with_pdf_theme_file <<~'END' do |heading_font_color_theme_path| heading: font-color: #AA0000 - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - #{File.basename heading_font_color_theme_path} - base - EOS + END theme = subject.load_file theme_path, nil, (File.dirname theme_path) (expect theme.heading_font_color).to eql 'AA0000' (expect theme.base_font_family).to eql 'Helvetica' @@ -583,21 +583,21 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should only extend theme once by default' do - with_pdf_theme_file <<~'EOS' do |extended_default_theme_path| + with_pdf_theme_file <<~'END' do |extended_default_theme_path| extends: default base: font-color: 222222 - EOS - with_pdf_theme_file <<~'EOS' do |heading_font_family_theme_path| + END + with_pdf_theme_file <<~'END' do |heading_font_family_theme_path| extends: default heading: font-family: M+ 1mn - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - #{File.basename extended_default_theme_path} - #{File.basename heading_font_family_theme_path} - EOS + END theme = subject.load_file theme_path, nil, (File.dirname theme_path) (expect theme.base_font_color).to eql '222222' (expect theme.heading_font_family).to eql 'M+ 1mn' @@ -607,19 +607,19 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should only extend base theme once by default' do - with_pdf_theme_file <<~'EOS' do |extended_base_theme_path| + with_pdf_theme_file <<~'END' do |extended_base_theme_path| extends: base base: font-family: Times-Roman font-color: 333333 - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - #{File.basename extended_base_theme_path} - base link: font-color: 0000FF - EOS + END theme = subject.load_file theme_path, nil, (File.dirname theme_path) (expect theme.base_font_color).to eql '333333' (expect theme.base_font_family).to eql 'Times-Roman' @@ -629,17 +629,17 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should force base theme to be loaded if qualified with !important' do - with_pdf_theme_file <<~'EOS' do |extended_base_theme_path| + with_pdf_theme_file <<~'END' do |extended_base_theme_path| extends: base base: font-color: 222222 font-family: Times-Roman - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - #{File.basename extended_base_theme_path} - base !important - EOS + END theme = subject.load_file theme_path, nil, (File.dirname theme_path) (expect theme.base_font_color).to eql '000000' (expect theme.base_font_family).to eql 'Helvetica' @@ -648,17 +648,17 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should force default theme to be loaded if qualified with !important' do - with_pdf_theme_file <<~'EOS' do |extended_default_theme_path| + with_pdf_theme_file <<~'END' do |extended_default_theme_path| extends: default base: font-color: 222222 font-family: Times-Roman - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - #{File.basename extended_default_theme_path} - default !important - EOS + END theme = subject.load_file theme_path, nil, (File.dirname theme_path) (expect theme.base_font_color).to eql '333333' (expect theme.base_font_family).to eql 'Noto Serif' @@ -667,7 +667,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should allow font catalog to be merged with font catalog from theme being extended' do - with_pdf_theme_file <<~'EOS' do |theme_path| + with_pdf_theme_file <<~'END' do |theme_path| extends: default font: catalog: @@ -681,7 +681,7 @@ describe Asciidoctor::PDF::ThemeLoader do bold_italic: *VLGothic fallbacks: - VLGothic - EOS + END theme = subject.load_file theme_path (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog).to have_size 3 @@ -700,12 +700,12 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should not fail to merge font catalog if inherited theme does not define a font catalog' do - with_pdf_theme_file <<~'EOS' do |extends_no_theme_path| + with_pdf_theme_file <<~'END' do |extends_no_theme_path| extends: ~ base: font_family: Times-Roman - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: #{File.basename extends_no_theme_path} font: catalog: @@ -721,7 +721,7 @@ describe Asciidoctor::PDF::ThemeLoader do - VLGothic base: font_family: M+ 1p - EOS + END theme = subject.load_file theme_path, nil, (File.dirname theme_path) (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog).to have_size 2 @@ -770,27 +770,27 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should not inherit from base theme if custom theme extends default' do - with_pdf_theme_file <<~'EOS' do |theme_path| + with_pdf_theme_file <<~'END' do |theme_path| extends: default base: font-color: 222222 - EOS + END theme = subject.load_theme (File.basename theme_path), (File.dirname theme_path) (expect theme.table_border_style).to be_nil end end it 'should not inherit from base theme if custom theme extends nil' do - with_pdf_theme_file <<~'EOS' do |extends_no_theme_path| + with_pdf_theme_file <<~'END' do |extends_no_theme_path| extends: ~ base: font-family: Times-Roman - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: #{File.basename extends_no_theme_path} heading: font-family: $base-font-family - EOS + END theme = subject.load_theme (File.basename theme_path), (File.dirname theme_path) (expect theme.base_font_family).to eql 'Times-Roman' (expect theme.heading_font_family).to eql 'Times-Roman' @@ -809,12 +809,12 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should inherit from base theme if custom theme extends base' do base_theme = subject.load_base_theme - with_pdf_theme_file <<~'EOS' do |theme_path| + with_pdf_theme_file <<~'END' do |theme_path| extends: base base: font_family: Times-Roman font_color: 333333 - EOS + END theme = subject.load_theme theme_path (expect theme.base_font_family).not_to eql base_theme.base_font_family (expect theme.base_font_color).not_to eql base_theme.base_font_color @@ -845,21 +845,21 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should load extended themes relative to theme file if they start with ./' do - with_pdf_theme_file <<~'EOS' do |custom_theme_path| + with_pdf_theme_file <<~'END' do |custom_theme_path| base: font-family: Times-Roman - EOS - with_pdf_theme_file <<~'EOS' do |red_theme_path| + END + with_pdf_theme_file <<~'END' do |red_theme_path| base: font-color: ff0000 - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - ./#{File.basename custom_theme_path} - ./#{File.basename red_theme_path} base: text-align: justify - EOS + END theme = subject.load_theme theme_path, fixtures_dir (expect theme.__dir__).to eql fixtures_dir (expect theme.base_text_align).to eql 'justify' @@ -871,21 +871,21 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should load extended themes relative to theme file when theme_dir is not specified' do - with_pdf_theme_file <<~'EOS' do |custom_theme_path| + with_pdf_theme_file <<~'END' do |custom_theme_path| base: font-family: Times-Roman - EOS - with_pdf_theme_file <<~'EOS' do |red_theme_path| + END + with_pdf_theme_file <<~'END' do |red_theme_path| base: font-color: ff0000 - EOS - with_pdf_theme_file <<~EOS do |theme_path| + END + with_pdf_theme_file <<~END do |theme_path| extends: - #{File.basename custom_theme_path} - #{File.basename red_theme_path} base: text-align: justify - EOS + END theme = subject.load_theme theme_path (expect theme.__dir__).to eql File.dirname theme_path (expect theme.base_text_align).to eql 'justify' @@ -909,11 +909,11 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should link code and conum font family to codespan font family by default' do - with_pdf_theme_file <<~'EOS' do |theme_path| + with_pdf_theme_file <<~'END' do |theme_path| extends: ~ codespan: font-family: M+ 1mn - EOS + END theme = subject.load_theme (File.basename theme_path), (File.dirname theme_path) (expect theme.__dir__).to eql (File.dirname theme_path) (expect theme.codespan_font_family).to eql 'M+ 1mn' @@ -923,11 +923,11 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should link sidebar and abstract title font family to heading font family if only latter is set' do - with_pdf_theme_file <<~'EOS' do |theme_path| + with_pdf_theme_file <<~'END' do |theme_path| extends: default heading: font-family: M+ 1mn - EOS + END theme = subject.load_theme (File.basename theme_path), (File.dirname theme_path) (expect theme.__dir__).to eql (File.dirname theme_path) (expect theme.heading_font_family).to eql 'M+ 1mn' @@ -937,11 +937,11 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should not overwrite required keys with default values if already set' do - with_pdf_theme_file <<~'EOS' do |theme_path| + with_pdf_theme_file <<~'END' do |theme_path| extends: default base: font-color: 222222 - EOS + END theme = subject.load_theme (File.basename theme_path), (File.dirname theme_path) (expect theme.base_text_align).to eql 'justify' (expect theme.code_font_family).to eql 'M+ 1mn' @@ -992,19 +992,19 @@ describe Asciidoctor::PDF::ThemeLoader do context 'data types' do it 'should resolve null color value as nil' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' page: background_color: null - EOS + END theme = subject.new.load theme_data (expect theme.page_background_color).to be_nil end it 'should resolve transparent color value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' sidebar: background_color: transparent - EOS + END theme = subject.new.load theme_data (expect theme.sidebar_background_color).to eql 'transparent' (expect theme.sidebar_background_color).to be_a subject::TransparentColorValue @@ -1021,17 +1021,17 @@ describe Asciidoctor::PDF::ThemeLoader do '2222' => '002222', '11223344' => '112233', }.each do |input, resolved| - theme_data = YAML.safe_load <<~EOS + theme_data = YAML.safe_load <<~END page: background_color: #{input} - EOS + END theme = subject.new.load theme_data (expect theme.page_background_color).to eql resolved end end it 'should wrap cmyk color values in color type if key ends with _color' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' page: background_color: [0, 0, 0, 0] base: @@ -1044,7 +1044,7 @@ describe Asciidoctor::PDF::ThemeLoader do font-color: [0%, 0%, 0%, 0.87] table: grid-color: [0, 0, 0, 27] - EOS + END theme = subject.new.load theme_data (expect theme.page_background_color).to eql 'FFFFFF' (expect theme.page_background_color).to be_a subject::HexColorValue @@ -1061,7 +1061,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should wrap hex color values in color type if key ends with _color' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' page: background_color: 'ffffff' base: @@ -1072,7 +1072,7 @@ describe Asciidoctor::PDF::ThemeLoader do font-color: 428bca codespan: font-color: 222 - EOS + END theme = subject.new.load theme_data (expect theme.page_background_color).to eql 'FFFFFF' (expect theme.page_background_color).to be_a subject::HexColorValue @@ -1088,7 +1088,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should coerce rgb color values to hex and wrap in color type if key ends with _color' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' page: background_color: [255, 255, 255] base: @@ -1101,7 +1101,7 @@ describe Asciidoctor::PDF::ThemeLoader do font-color: ['34', '34', '34'] table: grid-color: [187, 187, 187] - EOS + END theme = subject.new.load theme_data (expect theme.page_background_color).to eql 'FFFFFF' (expect theme.page_background_color).to be_a subject::HexColorValue @@ -1118,19 +1118,19 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should coerce rgb color values for each axis of table grid' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' table: grid-color: [[255, 0, 0], [0, 255, 0]] - EOS + END theme = subject.new.load theme_data (expect theme.table_grid_color).to eql %w(FF0000 00FF00) end it 'should coerce cmyk color values for each axis of table grid' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' table: grid-color: [[0, 1, 1, 0], [1, 0, 1, 0]] - EOS + END theme = subject.new.load theme_data (expect theme.table_grid_color).to eql [[0, 100, 100, 0], [100, 0, 100, 0]] (expect theme.table_grid_color[0]).to be_a subject::CMYKColorValue @@ -1138,12 +1138,12 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should flatten array color value of unsupported length to string if key ends with _color' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' page: background_color: ['fff', 'fff'] base: font_color: [0, 0, 0, 0, 0, 0] - EOS + END theme = subject.new.load theme_data (expect theme.page_background_color).to eql 'FFFFFF' (expect theme.page_background_color).to be_a subject::HexColorValue @@ -1152,11 +1152,11 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should not wrap value in color type if key does not end with _color' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' menu: caret: content: 4a4a4a - EOS + END theme = subject.new.load theme_data (expect theme.menu_caret_content).to eql '4a4a4a' (expect theme.menu_caret_content).not_to be_a subject::HexColorValue @@ -1181,7 +1181,7 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should coerce content key to a string' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' vars: foo: bar footer: @@ -1190,7 +1190,7 @@ describe Asciidoctor::PDF::ThemeLoader do content: $vars_foo right: content: 10 - EOS + END theme = subject.new.load theme_data (expect theme.footer_recto_left_content).to eql 'bar' (expect theme.footer_recto_right_content).to be_a String @@ -1199,10 +1199,10 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should not modify value without units' do [36, 36.0, 48.24, (20 / 17.0)].each do |val| - theme_data = YAML.safe_load <<~EOS + theme_data = YAML.safe_load <<~END footer: padding: #{val} - EOS + END theme = subject.new.load theme_data (expect theme.footer_padding).to eql val end @@ -1210,21 +1210,21 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should resolve value with fixed units to PDF point value' do ['0.5in', '36pt', '48px', '12.7mm', '1.27cm'].each do |val| - theme_data = YAML.safe_load <<~EOS + theme_data = YAML.safe_load <<~END footer: padding: #{val} - EOS + END theme = subject.new.load theme_data (expect theme.footer_padding.to_f.round 2).to eql 36.0 end end it 'should preserve value with relative units' do - theme_data = YAML.safe_load <<~EOS + theme_data = YAML.safe_load <<~END role: big: font-size: 1.2em - EOS + END theme = subject.new.load theme_data (expect theme.role_big_font_size).to eql '1.2em' end @@ -1232,42 +1232,42 @@ describe Asciidoctor::PDF::ThemeLoader do context 'interpolation' do it 'should resolve variable reference with underscores to previously defined key' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' brand: blue: '0000FF' base: font_color: $brand_blue heading: font_color: $base_font_color - EOS + END theme = subject.new.load theme_data (expect theme.base_font_color).to eql '0000FF' (expect theme.heading_font_color).to eql theme.base_font_color end it 'should resolve variable reference with hyphens to previously defined key' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' brand: blue: '0000FF' base: font_color: $brand-blue heading: font_color: $base-font-color - EOS + END theme = subject.new.load theme_data (expect theme.base_font_color).to eql '0000FF' (expect theme.heading_font_color).to eql theme.base_font_color end it 'should resolve variable reference to previously defined color' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' brand: blue-color: '0000FF' base: font_color: $brand-blue-color heading: font_color: $base-font-color - EOS + END theme = subject.new.load theme_data (expect theme.base_font_color).to eql '0000FF' (expect theme.heading_font_color).to eql theme.base_font_color @@ -1275,12 +1275,12 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should warn if variable reference cannot be resolved' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' brand: blue: '0000FF' base: font_color: $brand-red - EOS + END theme = subject.new.load theme_data (expect theme.base_font_color).to eql '$BRAND' end).to log_message severity: :WARN, message: %(unknown variable reference in PDF theme: $brand-red) @@ -1288,17 +1288,17 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should warn if negated variable reference cannot be resolved' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' block: margin-bottom: -$vertical-rhythm - EOS + END theme = subject.new.load theme_data (expect theme.block_margin_bottom).to eql '-$vertical-rhythm' end).to log_message severity: :WARN, message: %(unknown variable reference in PDF theme: $vertical-rhythm) end it 'should interpolate variables in value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' brand: font_family_name: Noto font_family_variant: Serif @@ -1306,7 +1306,7 @@ describe Asciidoctor::PDF::ThemeLoader do font_family: $brand_font_family_name $brand_font_family_variant heading: font_family: $brand_font_family_name Sans - EOS + END theme = subject.new.load theme_data (expect theme.base_font_family).to eql 'Noto Serif' (expect theme.heading_font_family).to eql 'Noto Sans' @@ -1314,19 +1314,19 @@ describe Asciidoctor::PDF::ThemeLoader do it 'should warn if variable reference cannot be resolved when interpolating value' do (expect do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' brand: font_family_name: Noto base: font_family: $brand-font-family-name $brand-font-family-variant - EOS + END theme = subject.new.load theme_data (expect theme.base_font_family).to eql 'Noto $brand-font-family-variant' end).to log_message severity: :WARN, message: %(unknown variable reference in PDF theme: $brand-font-family-variant) end it 'should interpolate computed value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' base: font_size: 10 line_height_length: 12 @@ -1337,7 +1337,7 @@ describe Asciidoctor::PDF::ThemeLoader do quote: border_width: 5 padding: [-0.001, $base_line_height_length - 2, $base_line_height_length * -0.75, $base_line_height_length + $quote_border_width / 2] - EOS + END theme = subject.new.load theme_data (expect theme.base_line_height).to eql 1.2 (expect theme.base_font_size_large).to eql 12.5 @@ -1347,32 +1347,32 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should coerce value to numeric if negated variable is a number' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' vertical-rhythm: 12 block: anchor-top: -$vertical-rhythm - EOS + END theme = subject.new.load theme_data expected = -12 (expect theme.block_anchor_top).to eql expected end it 'should allow numeric value with units to be negative' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' footer: padding: [0, -0.67in, 0, -0.67in] - EOS + END theme = subject.new.load theme_data (expect theme.footer_padding).to eql [0, -48.24, 0, -48.24] end it 'should not compute value if operator is not surrounded by spaces on either side' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' brand: ten: 10 a_string: ten*10 another_string: ten-10 - EOS + END theme = subject.new.load theme_data (expect theme.brand_ten).to be 10 @@ -1381,64 +1381,64 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should resolve fixed units before computing value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' title-page: title: top: 3in / 4 - EOS + END theme = subject.new.load theme_data (expect theme.title_page_title_top).to eql 54 end it 'should preserve em units when computing value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' title-page: title: top: 1em / 4 - EOS + END theme = subject.new.load theme_data (expect theme.title_page_title_top).to eql '0.25em' end it 'should preserve rem units when computing value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' title-page: title: top: 3rem / 4 - EOS + END theme = subject.new.load theme_data (expect theme.title_page_title_top).to eql '0.75rem' end it 'should preserve em units when applying precision to value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' title-page: title: top: ceil(3em / 4) - EOS + END theme = subject.new.load theme_data (expect theme.title_page_title_top).to eql '1em' end it 'should preserve rem units when applying precision to value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' title-page: title: top: floor(4rem / 3) - EOS + END theme = subject.new.load theme_data (expect theme.title_page_title_top).to eql '1rem' end it 'should apply precision functions to value' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' base: font_size: 10.5 heading: h1_font_size: ceil($base_font_size * 2.6) h2_font_size: floor($base_font_size * 2.1) h3_font_size: round($base_font_size * 1.5) - EOS + END theme = subject.new.load theme_data (expect theme.heading_h1_font_size).to be 28 (expect theme.heading_h2_font_size).to be 22 @@ -1446,14 +1446,14 @@ describe Asciidoctor::PDF::ThemeLoader do end it 'should resolve variable references in font catalog' do - theme_data = YAML.safe_load <<~'EOS' + theme_data = YAML.safe_load <<~'END' vars: serif-font: /path/to/serif-font.ttf font: catalog: Serif: normal: $vars-serif-font - EOS + END theme = subject.new.load theme_data (expect theme.font_catalog).to be_a Hash (expect theme.font_catalog['Serif']).to be_a Hash diff --git a/spec/title_page_spec.rb b/spec/title_page_spec.rb index 8e3cabde..15a90212 100644 --- a/spec/title_page_spec.rb +++ b/spec/title_page_spec.rb @@ -5,33 +5,33 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Title Page' do context 'book doctype' do it 'should not include title page if notitle attribute is set' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: :page + pdf = to_pdf <<~'END', doctype: :book, analyze: :page = Document Title :notitle: body - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:strings]).not_to include 'Document Title' end it 'should not include title page if title_page key in theme is false' do - pdf = to_pdf <<~'EOS', doctype: :book, pdf_theme: { title_page: false }, analyze: :page + pdf = to_pdf <<~'END', doctype: :book, pdf_theme: { title_page: false }, analyze: :page = Document Title body - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:strings]).not_to include 'Document Title' end it 'should not include title page if showtitle attribute is unset when Asciidoctor >= 2.0.11' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: :page + pdf = to_pdf <<~'END', doctype: :book, analyze: :page = Document Title :!showtitle: body - EOS + END if (Gem::Version.new Asciidoctor::VERSION) >= (Gem::Version.new '2.0.11') (expect pdf.pages[0][:strings]).not_to include 'Document Title' else @@ -40,11 +40,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should place document title on title page when doctype is book' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title body - EOS + END (expect pdf.pages).to have_size 2 text = pdf.text @@ -63,24 +63,24 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should include revision number, date, and remark on title page' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title Author Name v1.0, 2019-01-01: Draft :doctype: book - EOS + END (expect pdf.lines).to include 'Version 1.0, 2019-01-01: Draft' end it 'should display author names under document title on title page' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title Doc Writer; Antonín Dvořák :doctype: book body - EOS + END title_page_lines = pdf.lines pdf.find_text page_number: 1 (expect title_page_lines).to eql ['Document Title', 'Doc Writer, Antonín Dvořák'] @@ -91,14 +91,14 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_authors_content_with_email: '{author} // {email}', title_page_authors_content_with_url: '{author} // {url}', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title Doc Writer <https://example.org/doc>; Junior Writer <jr@example.org> :doctype: book :url: https://opensource.org {url} - EOS + END title_page_lines = pdf.lines pdf.find_text page_number: 1 (expect title_page_lines).to eql ['Document Title', 'Doc Writer // https://example.org/doc, Junior Writer // jr@example.org'] @@ -108,14 +108,14 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should not carry over url from one author to the next' do pdf_theme = { title_page_authors_content_with_url: '{author} // {url}' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title Doc Writer <https://example.org/doc>; Junior Writer :doctype: book :url: https://opensource.org {url} - EOS + END title_page_lines = pdf.lines pdf.find_text page_number: 1 (expect title_page_lines).to eql ['Document Title', 'Doc Writer // https://example.org/doc, Junior Writer'] @@ -124,14 +124,14 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should apply base font style when document has title page' do - pdf = to_pdf <<~'EOS', pdf_theme: { base_font_style: 'bold' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { base_font_style: 'bold' }, analyze: true = Document Title Author Name v1.0, 2020-01-01 :doctype: book bold body - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.text.map {|it| it[:font_name] }.uniq).to eql %w(NotoSerif-Bold) @@ -140,24 +140,24 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do context 'title-page attribute' do it 'should not include title page if notitle attribute is set' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page = Document Title :title-page: :notitle: what's it gonna do? - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.pages[0][:strings]).not_to include 'Document Title' end it 'should place document title on title page if title-page attribute is set' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page = Document Title :title-page: body - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'body' @@ -172,11 +172,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do context 'Logo' do it 'should add logo specified by title-logo-image document attribute to title page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :title-logo-image: image:tux.png[] - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -186,26 +186,26 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should not add border to raster logo image if border is specified for image block in theme' do pdf_theme = { image_border_width: 1, image_border_color: '000000' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line = Document Title :doctype: book :title-logo-image: image:tux.png[] content - EOS + END (expect pdf.lines).to be_empty end it 'should not add border to SVG logo image if border is specified for image block in theme' do pdf_theme = { image_border_width: 1, image_border_color: '0000EE' } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :line = Document Title :doctype: book :title-logo-image: image:square.svg[] content - EOS + END image_border_lines = pdf.lines.select {|it| it[:color] == '0000EE' } (expect image_border_lines).to be_empty @@ -214,11 +214,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should add remote logo specified by title-logo-image document attribute to title page' do with_local_webserver do |base_url| [%(#{base_url}/tux.png), %(image:#{base_url}/tux.png[])].each do |image_url| - pdf = to_pdf <<~EOS, attribute_overrides: { 'allow-uri-read' => '' } + pdf = to_pdf <<~END, attribute_overrides: { 'allow-uri-read' => '' } = Document Title :doctype: book :title-logo-image: #{image_url} - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -232,11 +232,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do image_data = File.binread fixture_file 'tux.png' encoded_image_data = Base64.strict_encode64 image_data image_url = %(image:data:image/jpg;base64,#{encoded_image_data}[]) - pdf = to_pdf <<~EOS + pdf = to_pdf <<~END = Document Title :doctype: book :title-logo-image: #{image_url} - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -247,11 +247,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should use image format for title logo specified by format attribute' do source_file = (dest_file = fixture_file 'square') + '.svg' FileUtils.cp source_file, dest_file - pdf = to_pdf <<~EOS, enable_footer: true, analyze: :rect + pdf = to_pdf <<~END, enable_footer: true, analyze: :rect = Document Title :title-page: :title-logo-image: image:#{dest_file}[format=svg] - EOS + END (expect pdf.rectangles).to have_size 1 rect = pdf.rectangles[0] (expect rect[:width]).to eql 200.0 @@ -262,11 +262,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should not allow PDF to be used as title logo image' do (expect do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :title-logo-image: image:red-green-blue.pdf[page=1] - EOS + END # QUESTION: should we validate page background color? (expect pdf.pages).to have_size 1 @@ -274,11 +274,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should position logo using value of top attribute with vh units on image macro in title-logo-image attribute' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :doctype: book :title-logo-image: image:tux.png[align=left,top=0vh] - EOS + END left_margin = 0.67 * 72 page_height = 841.89 # ~11.69in @@ -291,11 +291,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should position logo using value of top attribute with in units on image macro in title-logo-image attribute' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :doctype: book :title-logo-image: image:tux.png[align=left,top=1in] - EOS + END left_margin = 0.67 * 72 top_margin = 0.5 * 72 @@ -309,11 +309,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should position logo using value of top attribute with unrecognized units on image macro in title-logo-image attribute' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :doctype: book :title-logo-image: image:tux.png[align=left,top=1ft] - EOS + END left_margin = 0.67 * 72 top_margin = 0.5 * 72 @@ -327,11 +327,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should align logo using value of align attribute specified on image macro', visual: true do - to_file = to_pdf_file <<~'EOS', 'title-page-logo-align-attribute.pdf' + to_file = to_pdf_file <<~'END', 'title-page-logo-align-attribute.pdf' = Document Title :doctype: book :title-logo-image: image:tux.png[align=left] - EOS + END (expect to_file).to visually_match 'title-page-logo-align-left.pdf' end @@ -341,11 +341,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_logo_align: nil, title_page_text_align: 'center', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :image = Document Title :doctype: book :title-logo-image: image:tux.png[] - EOS + END images = pdf.images (expect images).to have_size 1 @@ -357,11 +357,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_logo_align: nil, title_page_text_align: 'left', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: :image = Document Title :doctype: book :title-logo-image: image:tux.png[align=foo] - EOS + END images = pdf.images (expect images).to have_size 1 @@ -369,11 +369,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should allow left margin to be set for left-aligned logo image' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_logo_margin_left: 10 }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: { title_page_logo_margin_left: 10 }, analyze: :image = Document Title :doctype: book :title-logo-image: image:tux.png[align=left] - EOS + END left_margin = 0.67 * 72 @@ -385,11 +385,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should allow right margin to be set for right-aligned logo image' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_logo_margin_right: 10 }, analyze: :image + pdf = to_pdf <<~'END', pdf_theme: { title_page_logo_margin_right: 10 }, analyze: :image = Document Title :doctype: book :title-logo-image: image:tux.png[align=right] - EOS + END right_margin = (8.27 - 0.67) * 72 @@ -401,13 +401,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should resize raster logo to keep it on title page' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :title-page: :title-logo-image: image:cover.jpg[pdfwidth=100%,top=70%] content - EOS + END (expect pdf.page_count).to eql 2 images = pdf.images @@ -418,13 +418,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should resize SVG logo to keep it on title page' do - pdf = to_pdf <<~'EOS', analyze: :line + pdf = to_pdf <<~'END', analyze: :line = Document Title :title-page: :title-logo-image: image:red-blue-squares.svg[pdfwidth=50%,top=70%] content - EOS + END (expect pdf.lines.map {|it| it[:page_number] }.uniq).to eql [1] end @@ -432,7 +432,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do context 'Background' do it 'should set background image of title page from title-page-background-image attribute' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = The Amazing Author Name :doctype: book @@ -447,7 +447,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do <<< end - EOS + END (expect pdf.pages).to have_size 4 [1, 0, 0, 0].each_with_index do |expected_num_images, idx| @@ -457,7 +457,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should set background image of title page when document has image cover page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = The Amazing Author Name :doctype: book @@ -473,7 +473,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do <<< end - EOS + END (expect pdf.pages).to have_size 5 [1, 1, 0, 0, 0].each_with_index do |expected_num_images, idx| @@ -483,7 +483,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should set background image of title page and body pages when document has PDF cover page' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = The Amazing Author Name :doctype: book @@ -500,7 +500,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do <<< end - EOS + END images_by_page = [] (expect pdf.pages).to have_size 5 @@ -517,14 +517,14 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should not create extra blank page when document has cover page and raster page background image' do image_data = File.binread fixture_file 'cover.jpg' - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = The Amazing Author Name :doctype: book :front-cover-image: image:blue-letter.pdf[] :title-page-background-image: image:cover.jpg[] :page-background-image: image:tux.png[] - EOS + END (expect pdf.pages).to have_size 2 images_by_page = [] @@ -539,7 +539,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should not create extra blank page when document has cover page and SVG page background image', visual: true do - to_file = to_pdf_file <<~'EOS', 'title-page-background-image-svg-with-cover.pdf' + to_file = to_pdf_file <<~'END', 'title-page-background-image-svg-with-cover.pdf' = The Amazing Author Name :doctype: book @@ -548,17 +548,17 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do :page-background-image: image:watermark.svg[] content - EOS + END (expect to_file).to visually_match 'title-page-background-image-svg-with-cover.pdf' end it 'should not create extra blank page when document has PDF cover page and doctype is book' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :front-cover-image: image:red-green-blue.pdf[page=1] - EOS + END (expect pdf.pages).to have_size 2 doctitle_text = pdf.find_unique_text 'Document Title' @@ -566,13 +566,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should be able to set size and position of title page background image', visual: true do - to_file = to_pdf_file <<~'EOS', 'title-page-background-image-size-position.pdf' + to_file = to_pdf_file <<~'END', 'title-page-background-image-size-position.pdf' = Document Title :doctype: book :title-page-background-image: image:tux.png[fit=none,position=bottom left] content - EOS + END (expect to_file).to visually_match 'title-page-background-image-size-position.pdf' end @@ -596,12 +596,12 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_revision_margin_bottom: 10, } - input = <<~'EOS' + input = <<~'END' = Document Title: Subtitle :doctype: book Author Name v1.0 - EOS + END reference_pdf = to_pdf input, pdf_theme: reference_pdf_theme, analyze: true pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true @@ -616,13 +616,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should allow theme to customize content of authors line' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_authors_content: '{url}[{author}]' } + pdf = to_pdf <<~'END', pdf_theme: { title_page_authors_content: '{url}[{author}]' } = Document Title Doc Writer <doc@example.org>; Junior Writer <https://github.com/ghost> :doctype: book body - EOS + END (expect (pdf.page 1).text).to include 'Doc Writer, Junior Writer' annotations = get_annotations pdf, 1 @@ -636,37 +636,37 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should normalize whitespace in authors content' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_authors_content: %({url}\n[{author}]) }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { title_page_authors_content: %({url}\n[{author}]) }, analyze: true = Document Title Doc Writer <doc@example.org> :doctype: book body - EOS + END (expect pdf.lines).to include 'mailto:doc@example.org [Doc Writer]' end it 'should drop lines with missing attribute reference in authors content' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_authors_content: %(keep: {firstname}\ndrop{no-such-attr}\nkeep: {lastname}) }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { title_page_authors_content: %(keep: {firstname}\ndrop{no-such-attr}\nkeep: {lastname}) }, analyze: true = Document Title Doc Writer <doc@example.org> :doctype: book body - EOS + END (expect pdf.lines).to include 'keep: Doc keep: Writer' end it 'should honor explicit hard line breaks in authors content' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_authors_content: %({firstname} +\n{lastname}) }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { title_page_authors_content: %({firstname} +\n{lastname}) }, analyze: true = Document Title Doc Writer <doc@example.org> :doctype: book body - EOS + END title_page_lines = pdf.lines pdf.find_text page_number: 1 (expect title_page_lines).to eql ['Document Title', 'Doc', 'Writer'] @@ -679,13 +679,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_authors_content_with_url: '{url}[{author}]', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title Doc Writer <doc@example.org>; Junior Writer <https://github.com/ghost>; Jane Doe :doctype: book body - EOS + END (expect (pdf.page 1).text).to include 'Writer, Doc <doc@example.org>, Junior Writer, JD' annotations = get_annotations pdf, 1 @@ -703,13 +703,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do role_author_font_color: '00AA00', title_page_authors_content: '{url}[{author},role=author]', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title Junior Writer <https://github.com/ghost> :doctype: book body - EOS + END author_text = (pdf.find_text 'Junior Writer')[0] (expect author_text[:font_color]).to eql '00AA00' @@ -720,14 +720,14 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_authors_content: '{author} {url}[icon:twitter[]]', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title Doc Writer <https://twitter.com/asciidoctor> :icons: font :doctype: book body - EOS + END title_page_lines = pdf.lines pdf.find_text page_number: 1 (expect title_page_lines).to include %(Doc Writer \uf099) @@ -739,14 +739,14 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_revision_delimiter: ' - ', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title Doc Writer; Junior Writer v1.0, 2019-01-01 :doctype: book content - EOS + END lines = pdf.lines (expect lines).to include 'Doc Writer / Junior Writer' @@ -754,33 +754,33 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should allow theme to customize content of revision line' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_revision_content: '{revdate} (*v{revnumber}*)' } + pdf = to_pdf <<~'END', pdf_theme: { title_page_revision_content: '{revdate} (*v{revnumber}*)' } = Document Title Author Name v1.0, 2022-10-22 :doctype: book body - EOS + END (expect (pdf.page 1).text).to include '2022-10-22 (v1.0)' end it 'should include version label in revision line if revnumber attribute is set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title Author Name v1.0, 2022-10-22 :doctype: book body - EOS + END (expect pdf.lines).to include 'Version 1.0, 2022-10-22' end it 'should not include version label in revision line if version-label attribute is unset' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title Author Name v1.0, 2022-10-22 @@ -788,16 +788,16 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do :!version-label: body - EOS + END (expect pdf.lines).to include '1.0, 2022-10-22' end it 'should add logo specified by title_page_logo_image theme key to title page' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_logo_image: 'image:{docdir}/tux.png[]' }, attribute_overrides: { 'docdir' => fixtures_dir } + pdf = to_pdf <<~'END', pdf_theme: { title_page_logo_image: 'image:{docdir}/tux.png[]' }, attribute_overrides: { 'docdir' => fixtures_dir } = Document Title :doctype: book - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -810,10 +810,10 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do __dir__: fixtures_dir, title_page_logo_image: 'tux.png', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title :doctype: book - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -823,10 +823,10 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should resolve title page logo image specified using path in theme relative to themesdir in classloader', if: RUBY_ENGINE == 'jruby' do require fixture_file 'pdf-themes.jar' - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => 'uri:classloader:/pdf-themes/title-page-logo-image-theme.yml' } + pdf = to_pdf <<~'END', attribute_overrides: { 'pdf-theme' => 'uri:classloader:/pdf-themes/title-page-logo-image-theme.yml' } = Document Title :doctype: book - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -836,10 +836,10 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should resolve title page logo image with absolute path for theme loaded from classloader', if: RUBY_ENGINE == 'jruby' do require fixture_file 'pdf-themes.jar' - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => 'uri:classloader:/pdf-themes/title-page-logo-image-from-fixturesdir-theme.yml', 'fixturesdir' => fixtures_dir } + pdf = to_pdf <<~'END', attribute_overrides: { 'pdf-theme' => 'uri:classloader:/pdf-themes/title-page-logo-image-from-fixturesdir-theme.yml', 'fixturesdir' => fixtures_dir } = Document Title :doctype: book - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -849,20 +849,20 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should ignore missing attribute reference when resolve title page logo image from theme' do (expect do - to_pdf <<~'EOS', pdf_theme: { title_page_logo_image: 'image:{no-such-attribute}{attribute-missing}.png[]' }, attribute_overrides: { 'attribute-missing' => 'warn' } + to_pdf <<~'END', pdf_theme: { title_page_logo_image: 'image:{no-such-attribute}{attribute-missing}.png[]' }, attribute_overrides: { 'attribute-missing' => 'warn' } = Document Title :doctype: book - EOS + END end).to log_message severity: :WARN, message: '~skip.png' end it 'should add remote logo specified by title_page_logo_image theme key to title page' do with_local_webserver do |base_url| [%(#{base_url}/tux.png), %(image:#{base_url}/tux.png[])].each do |image_url| - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_logo_image: image_url }, attribute_overrides: { 'allow-uri-read' => '' } + pdf = to_pdf <<~'END', pdf_theme: { title_page_logo_image: image_url }, attribute_overrides: { 'allow-uri-read' => '' } = Document Title :doctype: book - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -876,10 +876,10 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do image_data = File.binread fixture_file 'tux.png' encoded_image_data = Base64.strict_encode64 image_data image_url = %(image:data:image/jpg;base64,#{encoded_image_data}[]) - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_logo_image: image_url } + pdf = to_pdf <<~'END', pdf_theme: { title_page_logo_image: image_url } = Document Title :doctype: book - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -892,10 +892,10 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do __dir__: examples_dir, title_page_logo_image: 'image:sample-logo.jpg[]', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title :doctype: book - EOS + END images = get_images pdf, 1 (expect images).to have_size 1 @@ -909,13 +909,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_logo_top: top, } - pdf = to_pdf <<~'EOS', analyze: :image, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', analyze: :image, pdf_theme: pdf_theme = Document Title :doctype: book :title-logo-image: image:tux.png[align=left] image::tux.png[] - EOS + END left_margin = 0.67 * 72 top_margin = 0.5 * 72 @@ -939,13 +939,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should move logo down from top margin of page by numeric value of title_page_logo_top key' do pdf_theme = { title_page_logo_top: 20 } - pdf = to_pdf <<~'EOS', analyze: :image, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', analyze: :image, pdf_theme: pdf_theme = Document Title :doctype: book :title-logo-image: image:tux.png[align=left] image::tux.png[] - EOS + END left_margin = 0.67 * 72 @@ -966,13 +966,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_logo_top: '20pt', } - pdf = to_pdf <<~'EOS', analyze: :image, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', analyze: :image, pdf_theme: pdf_theme = Document Title :doctype: book :title-logo-image: image:tux.png[align=left] image::tux.png[] - EOS + END left_margin = 0.67 * 72 @@ -993,11 +993,11 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_logo_top: '5vh', } - pdf = to_pdf <<~'EOS', analyze: :image, pdf_theme: pdf_theme + pdf = to_pdf <<~'END', analyze: :image, pdf_theme: pdf_theme = Document Title :doctype: book :title-logo-image: image:tux.png[align=left] - EOS + END left_margin = 0.67 * 72 page_height = 841.89 # ~11.69in @@ -1016,12 +1016,12 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_title_top: '10%', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book content - EOS + END page_height = 841.89 # ~11.69in top_margin = 0.5 * 72 @@ -1037,12 +1037,12 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do it 'should move title down from top margin by numeric value of title_page_title_top key' do pdf_theme = { title_page_title_top: 20 } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book content - EOS + END page_height = 841.89 # ~11.69in top_margin = 0.5 * 72 @@ -1058,12 +1058,12 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_title_top: '20pt', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book content - EOS + END page_height = 841.89 # ~11.69in top_margin = 0.5 * 72 @@ -1079,12 +1079,12 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_title_top: '0vh', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book content - EOS + END page_height = 841.89 # ~11.69in @@ -1094,13 +1094,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should allow left margin of elements on title page to be configured' do - input = <<~'EOS' + input = <<~'END' = Book Title: Bring Out Your Dead Trees Author Name v1.0, 2001-01-01 body - EOS + END pdf_theme = { title_page_text_align: 'left' } @@ -1121,13 +1121,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do end it 'should allow right margin of elements on title page to be configured' do - input = <<~'EOS' + input = <<~'END' = Book Title: Bring Out Your Dead Trees Author Name v1.0, 2001-01-01 body - EOS + END pdf = to_pdf input, doctype: :book, analyze: true @@ -1153,19 +1153,19 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_authors_font_color: 'DBDBDB', } - to_file = to_pdf_file <<~'EOS', 'title-page-background-color.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'title-page-background-color.pdf', pdf_theme: pdf_theme = Dark and Stormy Author Name :doctype: book body - EOS + END (expect to_file).to visually_match 'title-page-background-color.pdf' end it 'should set background color when document has PDF cover page' do - pdf = to_pdf <<~'EOS', pdf_theme: { title_page_background_color: 'eeeeee' } + pdf = to_pdf <<~'END', pdf_theme: { title_page_background_color: 'eeeeee' } = The Amazing Author Name :doctype: book @@ -1182,7 +1182,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do <<< end - EOS + END images_by_page = [] (expect pdf.pages).to have_size 5 @@ -1201,12 +1201,12 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do __dir__: fixtures_dir, title_page_background_image: (macro ? 'image:bg.png[]' : 'bg.png'), } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title :doctype: book content - EOS + END (expect pdf.pages).to have_size 2 (expect get_images pdf, 1).to have_size 1 @@ -1219,13 +1219,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_background_image: %(image:#{fixture_file 'bg.png'}[]), } [' none', ''].each do |val| - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme + pdf = to_pdf <<~END, pdf_theme: pdf_theme = Document Title :doctype: book :title-page-background-image:#{val} content - EOS + END (expect pdf.pages).to have_size 2 (expect get_images pdf).to be_empty @@ -1237,7 +1237,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do page_background_image: %(image:#{fixture_file 'bg.png'}[]), title_page_background_image: 'none', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title :doctype: book @@ -1248,7 +1248,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do == Chapter 2 content - EOS + END (expect pdf.pages).to have_size 3 (expect get_images pdf, 1).to have_size 0 @@ -1264,7 +1264,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_logo_display: 'none', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title: Subtitle :doctype: book :title-logo-image: image:tux.png[] @@ -1272,7 +1272,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do v1.0, 2020-01-01 first page of content - EOS + END (expect pdf.pages).to have_size 2 (expect (pdf.page 1).text).to eql 'Document Title' @@ -1284,12 +1284,12 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_title_display: 'none', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title: Subtitle :doctype: book first page of content - EOS + END title_page_lines = pdf.lines pdf.find_text page_number: 1 (expect title_page_lines).to eql %w(Subtitle) @@ -1303,7 +1303,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_revision_display: 'none', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title: Subtitle :doctype: book :title-page-background-image: image:cover.jpg[] @@ -1311,7 +1311,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do v1.0, 2020-01-01 first page of content - EOS + END (expect pdf.pages).to have_size 2 title_page_text = (pdf.page 1).text @@ -1331,13 +1331,13 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do title_page_revision_display: 'none', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme + pdf = to_pdf <<~'END', pdf_theme: pdf_theme = Document Title: Subtitle :doctype: book :title-page-background-image: image:cover.jpg[] Author Name v1.0, 2020-01-01 - EOS + END (expect pdf.pages).to have_size 1 title_page_text = (pdf.page 1).text @@ -1359,7 +1359,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do pdf = nil (expect do - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title Author Name v1.0 @@ -1368,7 +1368,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do == First Chapter content - EOS + END end).to log_message severity: :WARN, message: 'the title page contents has been truncated to prevent it from overrunning the bounds of a single page' (expect pdf.pages).to have_size 2 diff --git a/spec/toc_spec.rb b/spec/toc_spec.rb index beb6a610..2c094d18 100644 --- a/spec/toc_spec.rb +++ b/spec/toc_spec.rb @@ -5,7 +5,7 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - TOC' do context 'book' do it 'should not generate toc by default' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title == Introduction @@ -13,13 +13,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Main == Conclusion - EOS + END (expect pdf.pages).to have_size 4 (expect pdf.find_text 'Table of Contents').to be_empty end it 'should insert toc between title page and first page of body when toc is set' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title :toc: @@ -28,7 +28,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Main == Conclusion - EOS + END (expect pdf.pages).to have_size 5 (expect pdf.find_text 'Document Title', page_number: 1).not_to be_empty (expect pdf.find_text 'Table of Contents', page_number: 2).not_to be_empty @@ -39,7 +39,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should space items in toc evently even if title is entirely monospace' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title :toc: @@ -48,7 +48,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == `Middle` == End - EOS + END (expect pdf.find_text 'Table of Contents', page_number: 2).not_to be_empty beginning_pagenum_text = (pdf.find_text '1', page_number: 2)[0] middle_pagenum_text = (pdf.find_text '2', page_number: 2)[0] @@ -59,7 +59,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should only include preface in toc if preface-title is set' do - input = <<~'EOS' + input = <<~'END' = Document Title [preface] @@ -68,7 +68,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Chapter 1 And away we go! - EOS + END [{ 'toc' => '' }, { 'toc' => '', 'preface-title' => 'Preface' }].each do |attrs| pdf = to_pdf input, doctype: :book, attributes: attrs, analyze: :page @@ -91,7 +91,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should output toc with depth specified by toclevels' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: :page + pdf = to_pdf <<~'END', doctype: :book, analyze: :page = Document Title :toc: :toclevels: 1 @@ -101,7 +101,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Level 2 ==== Level 3 - EOS + END (expect pdf.pages).to have_size 3 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'Table of Contents' @@ -112,7 +112,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should only show parts in toc if toclevels attribute is 0' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: :page + pdf = to_pdf <<~'END', doctype: :book, analyze: :page = Document Title :toc: :toclevels: 0 @@ -124,7 +124,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do = Part Two == Chapter B - EOS + END (expect pdf.pages).to have_size 6 (expect pdf.pages[1][:strings]).to include 'Table of Contents' (expect pdf.pages[1][:strings]).to include 'Part One' @@ -134,7 +134,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not show any section titles when toclevels is less than 0' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title :toc: :toclevels: -1 @@ -146,14 +146,14 @@ describe 'Asciidoctor::PDF::Converter - TOC' do = Part Two == Chapter B - EOS + END (expect pdf.pages).to have_size 6 toc_lines = pdf.lines pdf.find_text page_number: 2 (expect toc_lines).to eql ['Table of Contents'] end it 'should allow section to override toclevels for descendant sections' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :toc: @@ -171,7 +171,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Appendix Section ==== Appendix Subsection - EOS + END (expect pdf.find_text page_number: 2, string: 'Chapter').to have_size 1 (expect pdf.find_text page_number: 2, string: 'Chapter Section').to have_size 1 @@ -181,7 +181,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should allow section to remove itself from toc by setting toclevels to less than section level' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :toc: @@ -199,7 +199,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Appendix Section ==== Appendix Subsection - EOS + END (expect pdf.find_text page_number: 2, string: 'Chapter').to have_size 1 (expect pdf.find_text page_number: 2, string: 'Chapter Section').to have_size 1 @@ -209,12 +209,12 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should reserve enough pages for toc if it spans more than one page' do sections = (1..40).map {|num| %(\n\n=== Section #{num}) } - pdf = to_pdf <<~EOS, doctype: :book, analyze: :page + pdf = to_pdf <<~END, doctype: :book, analyze: :page = Document Title :toc: == Chapter 1#{sections.join} - EOS + END (expect pdf.pages).to have_size 6 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'Table of Contents' @@ -222,7 +222,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should render all TOC entries when computing extent of TOC when sectids is unset' do - input = <<~EOS + input = <<~END = Document Title :doctype: book :pdf-page-size: A5 @@ -232,7 +232,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do the preface #{30.times.map {|idx| %(== Chapter #{idx + 1}) }.join ?\n} - EOS + END pdf = to_pdf input, analyze: true preface_text = pdf.find_unique_text 'the preface' @@ -241,7 +241,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should render descendants of section without ID when computing extent of TOC' do - input = <<~EOS + input = <<~END = Document Title :doctype: book :pdf-page-size: A5 @@ -256,7 +256,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do #{5.times.map {|idx| %(=== Section #{idx + 1}) }.join ?\n} #{21.times.map {|idx| %(== Chapter #{idx + 2}) }.join ?\n} - EOS + END pdf = to_pdf input, analyze: true preface_text = pdf.find_unique_text 'the preface' @@ -265,7 +265,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should insert toc after preamble if toc attribute is preamble' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :toc: preamble @@ -278,7 +278,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion content - EOS + END toc_title_text = pdf.find_unique_text 'Table of Contents' (expect toc_title_text[:page_number]).to be 1 @@ -290,7 +290,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should insert toc at location of toc macro if toc attribute is macro' do lorem = ['lorem ipsum'] * 10 * %(\n\n) - input = <<~EOS + input = <<~END = Document Title :doctype: book :toc: macro @@ -310,7 +310,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion #{lorem} - EOS + END pdf = to_pdf input, analyze: true (expect pdf.pages).to have_size 6 toc_title_text = (pdf.find_text 'Table of Contents')[0] @@ -327,7 +327,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should insert macro toc in outline as sibling of section in which it is contained' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toc: macro @@ -339,7 +339,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc::[] === Another Section - EOS + END outline = extract_outline pdf chapter_entry = outline[1] @@ -353,7 +353,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not toc at default location if document has no sections' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :toc: @@ -362,7 +362,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do No sections here either. Fin. - EOS + END (expect pdf.lines).to eql ['Document Title', 'No sections here.', 'No sections here either.', 'Fin.'] p1_text = pdf.find_unique_text 'No sections here.' @@ -380,7 +380,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true = Document Title :toc: @@ -391,14 +391,14 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == End content - EOS + END (expect (pdf.find_unique_text 'Table of Contents')).to be_nil (expect (pdf.find_text 'Beginning')).to have_size 1 end it 'should not insert toc at location of toc macro if document has no sections' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :toc: macro No sections here. @@ -408,7 +408,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do No sections here either. Fin. - EOS + END (expect pdf.lines).to eql ['No sections here.', 'No sections here either.', 'Fin.'] p1_text = pdf.find_unique_text 'No sections here.' @@ -426,7 +426,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end end - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true = Document Title :toc: macro @@ -439,7 +439,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == End content - EOS + END (expect (pdf.find_unique_text 'Table of Contents')).to be_nil (expect (pdf.find_text 'Beginning')).to have_size 1 @@ -447,7 +447,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should only insert macro toc at location of first toc macro' do lorem = ['lorem ipsum'] * 10 * %(\n\n) - input = <<~EOS + input = <<~END = Document Title :doctype: book :toc: macro @@ -469,7 +469,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion #{lorem} - EOS + END pdf = to_pdf input, analyze: true (expect pdf.pages).to have_size 6 @@ -483,19 +483,19 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not insert toc at location of toc macro if toc attribute is not set' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true == Before toc::[] == After - EOS + END (expect pdf.lines).to eql %w(Before After) end it 'should not insert toc at location of toc macro if toc-placement attribute is set but not toc attribute' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :toc-placement: macro == Before @@ -503,13 +503,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc::[] == After - EOS + END (expect pdf.lines).to eql %w(Before After) end it 'should not insert toc at location of toc macro if value of toc attribute is not macro' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :doctype: book :toc: @@ -518,14 +518,14 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc::[] text - EOS + END (expect pdf.find_unique_text 'Table of Contents').not_to be_nil (expect pdf.lines pdf.find_text page_number: 2).to eql %w(Chapter text) end it 'should not start new page for toc in book if already at top of page' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :doctype: book :toc: macro @@ -539,7 +539,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Last Chapter Fin. - EOS + END (expect pdf.pages).to have_size 4 toc_heading_text = pdf.find_unique_text 'Table of Contents' @@ -547,7 +547,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should add top margin specified by theme to toc contents when toc has a title' do - input = <<~'EOS' + input = <<~'END' = Document Title :toc: @@ -556,7 +556,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Subsection == Section B - EOS + END toc_top_without_margin_top = ((to_pdf input, analyze: true).find_text 'Section A')[0][:y] toc_top_with_margin_top = ((to_pdf input, pdf_theme: { toc_margin_top: 50 }, analyze: true).find_text 'Section A')[0][:y] @@ -564,7 +564,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should add top margin specified by theme to toc contents when toc has no title and not at page top' do - input = <<~'EOS' + input = <<~'END' = Document Title :toc: :!toc-title: @@ -574,7 +574,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Subsection == Section B - EOS + END toc_top_without_margin_top = ((to_pdf input, analyze: true).find_text 'Section A')[0][:y] toc_top_with_margin_top = ((to_pdf input, pdf_theme: { toc_margin_top: 50 }, analyze: true).find_text 'Section A')[0][:y] @@ -582,7 +582,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not add top margin specified by theme to toc contents when toc contents is at top of page' do - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book :toc: @@ -593,7 +593,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Subsection == Section B - EOS + END toc_top_without_margin_top = ((to_pdf input, analyze: true).find_text 'Section A')[0][:y] toc_top_with_margin_top = ((to_pdf input, pdf_theme: { toc_margin_top: 50 }, analyze: true).find_text 'Section A')[0][:y] @@ -601,7 +601,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should start preamble toc on recto page for prepress book' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :media: prepress @@ -616,7 +616,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Last Chapter Fin. - EOS + END (expect pdf.pages).to have_size 9 toc_heading_text = pdf.find_unique_text 'Table of Contents' @@ -624,7 +624,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should start macro toc on recto page for prepress book' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :doctype: book :media: prepress @@ -639,7 +639,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Last Chapter Fin. - EOS + END (expect pdf.pages).to have_size 7 toc_heading_text = pdf.find_unique_text 'Table of Contents' @@ -647,7 +647,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not advance toc to recto page for prepress book when nonfacing option is specified on macro' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :doctype: book :media: prepress @@ -662,7 +662,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Last Chapter Fin. - EOS + END (expect pdf.pages).to have_size 5 toc_heading_text = pdf.find_unique_text 'Table of Contents' @@ -670,7 +670,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not advance toc in preamble to recto page for prepress book when nonfacing option is specified on macro' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :doctype: book :media: prepress @@ -686,7 +686,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Last Chapter Fin. - EOS + END (expect pdf.pages).to have_size 5 toc_heading_text = pdf.find_unique_text 'Table of Contents' @@ -705,7 +705,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do } sections = (1..37).map {|num| %(== Section #{num}) }.join %(\n\n) - pdf = to_pdf <<~EOS, pdf_theme: pdf_theme, enable_footer: true, analyze: true + pdf = to_pdf <<~END, pdf_theme: pdf_theme, enable_footer: true, analyze: true = Document Title :doctype: book :toc: macro @@ -718,7 +718,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc::[] == Last Chapter - EOS + END toc_text = (pdf.find_text 'Table of Contents')[0] (expect toc_text).not_to be_nil @@ -739,7 +739,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not add toc title to page or outline if toc-title is unset' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book :toc: @@ -750,7 +750,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Middle == End - EOS + END (expect pdf.pages).to have_size 5 (expect pdf.pages[1].text).to start_with 'Beginning' @@ -763,12 +763,12 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should not attempt to create dots if number of dots is less than 0' do section_title = (%w(verylongsectiontitle) * 5).join - pdf = to_pdf <<~EOS, doctype: :book, analyze: true + pdf = to_pdf <<~END, doctype: :book, analyze: true :toc: :toc-max-pagenum-digits: 0 == #{section_title} - EOS + END toc_lines = pdf.lines pdf.find_text page_number: 1 (expect toc_lines).to have_size 2 @@ -777,14 +777,14 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should line up dots and page number with wrapped line' do - pdf = to_pdf <<~'EOS', doctype: :book, analyze: true + pdf = to_pdf <<~'END', doctype: :book, analyze: true = Document Title :toc: == This Here is an Absurdly Long Section Title That Exceeds the Length of a Single Line and Therefore Wraps content - EOS + END toc_text = pdf.find_text page_number: 2 (expect toc_text.size).to be > 1 @@ -800,7 +800,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should line up dots and page number with wrapped line when section title gets split across a page boundary' do sections = (1..37).map {|num| %(\n\n== Section #{num}) }.join - pdf = to_pdf <<~EOS, doctype: :book, analyze: true + pdf = to_pdf <<~END, doctype: :book, analyze: true = Document Title :toc: #{sections} @@ -808,7 +808,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == This is a unbelievably long section title that probably shouldn't be a section title at all but here we are content - EOS + END page_2_lines = pdf.lines pdf.find_text page_number: 2 (expect page_2_lines).to include 'Table of Contents' @@ -820,7 +820,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should not crash if last fragment in toc entry is not rendered' do (expect do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :notitle: :!toc-title: @@ -830,7 +830,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Chapter == #{(['foo bar'] * 12).join ' '} foo +++<span><br></span>+++ - EOS + END toc_lines = pdf.lines pdf.find_text page_number: 1 (expect toc_lines).to have_size 2 @@ -840,7 +840,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should not crash if last fragment in toc entry that wraps is not rendered' do (expect do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :notitle: :!toc-title: @@ -850,7 +850,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Chapter == #{(['foo bar'] * 24).join ' '} foo foo +++<span><br></span>+++ - EOS + END toc_lines = pdf.lines pdf.find_text page_number: 1 (expect toc_lines).to have_size 3 @@ -860,12 +860,12 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should not crash if theme does not specify toc_indent' do (expect do - pdf = to_pdf <<~'EOS', attributes: { 'pdf-theme' => (fixture_file 'custom-theme.yml') }, analyze: true + pdf = to_pdf <<~'END', attributes: { 'pdf-theme' => (fixture_file 'custom-theme.yml') }, analyze: true = Document Title :toc: == Section - EOS + END toc_text = pdf.find_unique_text %r/Table of Contents/ (expect toc_text).not_to be_nil @@ -874,14 +874,14 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should allow hanging indent to be applied to lines that wrap' do - pdf = to_pdf <<~'EOS', doctype: :book, pdf_theme: { toc_hanging_indent: 36 }, analyze: true + pdf = to_pdf <<~'END', doctype: :book, pdf_theme: { toc_hanging_indent: 36 }, analyze: true = Document Title :toc: == This Here is an Absurdly Long Section Title That Exceeds the Length of a Single Line and Therefore Wraps content - EOS + END toc_text = pdf.find_text page_number: 2 (expect toc_text.size).to be > 1 @@ -896,7 +896,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should allow theme to control font size of dot leader' do - pdf = to_pdf <<~'EOS', pdf_theme: { toc_dot_leader_font_size: '0.5em' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { toc_dot_leader_font_size: '0.5em' }, analyze: true = Book Title :doctype: book :toc: @@ -904,7 +904,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Foo == Bar - EOS + END reference_text = pdf.find_unique_text 'Foo', page_number: 2 dot_leader_texts = pdf.find_text %r/(?:\. )+/, page_number: 2 @@ -915,20 +915,20 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should allow theme to control font style of dot leader' do - pdf = to_pdf <<~'EOS', pdf_theme: { toc_dot_leader_font_style: 'bold' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { toc_dot_leader_font_style: 'bold' }, analyze: true = Book Title :doctype: book :toc: == Foo - EOS + END dot_leader_text = pdf.find_unique_text %r/(?:\. )+/ (expect dot_leader_text[:font_name]).to eql 'NotoSerif-Bold' end it 'should allow theme to disable dot leader by setting content to empty string' do - pdf = to_pdf <<~'EOS', pdf_theme: { toc_dot_leader_content: '' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { toc_dot_leader_content: '' }, analyze: true = Book Title :doctype: book :toc: @@ -938,7 +938,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Bar == Baz - EOS + END toc_lines = (pdf.lines pdf.find_text page_number: 2).join ?\n (expect toc_lines).to include 'Foo' @@ -948,7 +948,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should allow theme to disable dot leader by setting levels to none' do - pdf = to_pdf <<~'EOS', pdf_theme: { toc_dot_leader_levels: 'none' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { toc_dot_leader_levels: 'none' }, analyze: true = Book Title :doctype: book :toc: @@ -958,7 +958,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Bar == Baz - EOS + END toc_lines = (pdf.lines pdf.find_text page_number: 2).join ?\n (expect toc_lines).to include 'Foo' @@ -968,7 +968,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should allow theme to disable dot leader for nested levels' do - pdf = to_pdf <<~'EOS', pdf_theme: { toc_dot_leader_levels: 1 }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { toc_dot_leader_levels: 1 }, analyze: true = Book Title :doctype: book :toc: @@ -984,7 +984,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Baz === Baz Subsection - EOS + END toc_lines = pdf.lines.select {|it| it.include? 'Subsection' }.join ?\n (expect toc_lines).to include 'Foo Subsection' @@ -994,7 +994,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should allow theme to enable dot leader per level' do - pdf = to_pdf <<~'EOS', pdf_theme: { toc_dot_leader_levels: '1 3' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { toc_dot_leader_levels: '1 3' }, analyze: true = Book Title :doctype: book :toc: @@ -1017,7 +1017,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Baz Subsection ==== Baz Deep - EOS + END lines = pdf.lines @@ -1041,7 +1041,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not use part or chapter signifier in toc' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Book Title :doctype: book :sectnums: @@ -1055,7 +1055,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do = P2 == C2 - EOS + END lines = pdf.lines pdf.find_text page_number: 2 (expect lines).to have_size 5 @@ -1069,7 +1069,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should reserve enough room for toc when page number forces section title in toc to wrap' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true = Document Title :doctype: book :notitle: @@ -1082,7 +1082,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do #{(['== Chapter'] * 27).join ?\n} == Last Chapter - EOS + END (expect pdf.find_text page_number: 2, string: 'Last Chapter').to have_size 1 (expect pdf.find_text page_number: 2, string: 'Chapter').to be_empty @@ -1091,7 +1091,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do context 'article' do it 'should not generate toc by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title == Introduction @@ -1099,14 +1099,14 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Main == Conclusion - EOS + END (expect pdf.pages).to have_size 1 (expect pdf.find_text 'Table of Contents').to be_empty end it 'should insert toc between document title and content when toc is set' do lorem = ['lorem ipsum'] * 10 * %(\n\n) - input = <<~EOS + input = <<~END = Document Title :toc: @@ -1123,7 +1123,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion #{lorem} - EOS + END pdf = to_pdf input, analyze: true (expect pdf.pages).to have_size 2 (expect pdf.find_text 'Table of Contents', page_number: 1).to have_size 1 @@ -1140,13 +1140,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should insert toc at top of first page if toc is set and document has no doctitle' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :toc: == Section A == Section B - EOS + END toc_title_text = (pdf.find_text 'Table of Contents')[0] sect_a_text = (pdf.find_text 'Section A', font_size: 22)[0] @@ -1155,12 +1155,12 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should reserve enough pages for toc if it spans more than one page' do sections = (1..40).map {|num| %(\n\n== Section #{num}) } - input = <<~EOS + input = <<~END = Document Title :toc: #{sections.join} - EOS + END pdf = to_pdf input, analyze: :page (expect pdf.pages).to have_size 4 (expect pdf.pages[0][:strings]).to include 'Document Title' @@ -1182,7 +1182,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should insert toc between title page and first page of body when toc and title-page are set' do - pdf = to_pdf <<~'EOS', analyze: :page + pdf = to_pdf <<~'END', analyze: :page = Document Title :toc: :title-page: @@ -1192,7 +1192,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Main == Conclusion - EOS + END (expect pdf.pages).to have_size 3 (expect pdf.pages[0][:strings]).to include 'Document Title' (expect pdf.pages[1][:strings]).to include 'Table of Contents' @@ -1202,7 +1202,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not force page break after toc when title-page attribute is set and toc-break-after is auto' do - pdf = to_pdf <<~'EOS', pdf_theme: { toc_break_after: 'auto' }, analyze: true + pdf = to_pdf <<~'END', pdf_theme: { toc_break_after: 'auto' }, analyze: true = Document Title :title-page: :toc: @@ -1212,7 +1212,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Main == Conclusion - EOS + END (expect pdf.pages).to have_size 2 (expect pdf.find_unique_text 'Document Title', page_number: 1).not_to be_nil (expect pdf.find_unique_text 'Table of Contents', page_number: 2).not_to be_nil @@ -1224,7 +1224,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should insert toc at location of toc macro if toc attribute is macro' do lorem = ['lorem ipsum'] * 10 * %(\n\n) - input = <<~EOS + input = <<~END = Document Title :toc: macro @@ -1243,7 +1243,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion #{lorem} - EOS + END pdf = to_pdf input, analyze: true (expect pdf.pages).to have_size 2 (expect pdf.find_text 'Table of Contents', page_number: 1).to have_size 1 @@ -1269,7 +1269,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should insert macro toc in outline as sibling of section in which it is contained' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :toc: macro @@ -1280,7 +1280,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc::[] === Another Subsection - EOS + END outline = extract_outline pdf section_entry = outline[1] @@ -1294,7 +1294,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should insert macro toc in outline before other sections if macro proceeds sections' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :toc: macro @@ -1305,7 +1305,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Subsection === Another Subsection - EOS + END outline = extract_outline pdf toc_entry = outline[1] @@ -1326,7 +1326,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc_dot_leader_font_color: 'CCCCCC', running_content_start_at: 'toc', } - to_file = to_pdf_file <<~'EOS', 'toc-running-content-font-color.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'toc-running-content-font-color.pdf', pdf_theme: pdf_theme = Document Title Author Name :doctype: book @@ -1339,7 +1339,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == B text - EOS + END (expect to_file).to visually_match 'toc-running-content-font-color.pdf' end @@ -1349,7 +1349,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do extends: 'base', toc_font_color: '4a4a4a', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title Author Name :doctype: book @@ -1362,7 +1362,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Conclusion text - EOS + END intro_entry_font_color = (pdf.find_unique_text 'Intro', page_number: 2)[:font_color] dot_leader_font_color = (pdf.find_text page_number: 2).select {|it| it[:string].start_with? '.' }.map {|it| it[:font_color] }.uniq[0] @@ -1374,13 +1374,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc_font_style: 'bold', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :doctype: book :toc: == Get Started _Quickly_ - EOS + END get_started_text = (pdf.find_text page_number: 2, string: /^Get Started/)[0] quickly_text = (pdf.find_text page_number: 2, string: 'Quickly')[0] @@ -1392,13 +1392,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do pdf_theme = { toc_text_decoration: 'underline', } - input = <<~'EOS' + input = <<~'END' = Document Title :toc: :title-page: == Underline Me - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :line lines = pdf.lines @@ -1417,13 +1417,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc_text_decoration_color: 'cccccc', toc_text_decoration_width: 0.5, } - input = <<~'EOS' + input = <<~'END' = Document Title :toc: :title-page: == Underline Me - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :line lines = pdf.lines @@ -1457,7 +1457,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do base_text_align: 'center', }, ].each do |pdf_theme| - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true = Document Title :toc: :doctype: book @@ -1465,7 +1465,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Section A == Section B - EOS + END toc_title_text = pdf.find_unique_text 'Table of Contents' (expect toc_title_text[:x]).to be > 48.24 end @@ -1477,7 +1477,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do toc_h3_text_decoration_color: 'cccccc', toc_h3_text_decoration_width: 0.5, } - input = <<~'EOS' + input = <<~'END' = Document Title :toc: :title-page: @@ -1485,7 +1485,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Plain Title === Decorated Title - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :line lines = pdf.lines @@ -1503,13 +1503,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do pdf_theme = { toc_text_transform: 'uppercase', } - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book :toc: == Transform Me - EOS + END pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true toc_lines = pdf.lines pdf.find_text page_number: 2 @@ -1517,24 +1517,24 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should decode character references in toc entries' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :toc: == Paper Clips № 4 - EOS + END (expect pdf.find_text %(Paper Clips \u2116\u00a04)).to have_size 2 end it 'should not crash if section title is empty' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :toc: == {empty} content - EOS + END (expect pdf.text).to have_size 2 (expect pdf.find_unique_text 'content').not_to be_nil @@ -1542,7 +1542,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should not include section title or its children in toc if title is empty' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :toc: :title-page: @@ -1554,7 +1554,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Child Section content - EOS + END toc_lines = pdf.lines pdf.find_text page_number: 2 (expect toc_lines).to have_size 2 @@ -1565,13 +1565,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do it 'should allocate correct number of pages for toc if line numbers cause lines to wrap' do chapter_title = %(\n\n== A long chapter title that wraps to a second line in the toc when the page number exceeds one digit) - input = <<~EOS + input = <<~END = Document Title :doctype: book :toc: :nofooter: #{chapter_title * 38} - EOS + END pdf = to_pdf input, analyze: true last_pagenum_text = (pdf.find_text '38')[0] @@ -1580,13 +1580,13 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end it 'should render image at end of section title in toc entry' do - pdf = to_pdf <<~'EOS', analyze: :image + pdf = to_pdf <<~'END', analyze: :image = Document Title :doctype: book :toc: == Chapter image:tux.png[,16] - EOS + END images = pdf.images (expect images).to have_size 2 @@ -1614,7 +1614,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end end - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book :toc: @@ -1622,7 +1622,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do == Chapter A == Chapter B - EOS + END pdf = to_pdf input, backend: backend, analyze: true (expect pdf.pages).to have_size 5 @@ -1644,7 +1644,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do end end - input = <<~'EOS' + input = <<~'END' = Document Title :doctype: book :toc: @@ -1667,7 +1667,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do image::tux.png[] === Another Section - EOS + END pdf = to_pdf input, backend: backend, analyze: true (expect pdf.pages).to have_size 5 @@ -1692,7 +1692,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do backend = %(pdf#{ext_class.object_id}) source_lines[0] = %( register_for '#{backend}'\n) ext_class.class_eval source_lines.join, source_file - pdf = to_pdf <<~'EOS', backend: backend, analyze: true + pdf = to_pdf <<~'END', backend: backend, analyze: true = Document Title :doctype: book :toc: @@ -1711,7 +1711,7 @@ describe 'Asciidoctor::PDF::Converter - TOC' do === Last Section == Another Chapter - EOS + END toc_text = pdf.find_text page_number: 2 toc_lines = toc_text diff --git a/spec/verse_spec.rb b/spec/verse_spec.rb index 917d4e47..288ea256 100644 --- a/spec/verse_spec.rb +++ b/spec/verse_spec.rb @@ -4,14 +4,14 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Verse' do it 'should show caption above block if title is specified' do - input = <<~'EOS' + input = <<~'END' .Fog [verse] ____ The fog comes on little cat feet. ____ - EOS + END pdf = to_pdf input, analyze: :line lines = pdf.lines @@ -29,13 +29,13 @@ describe 'Asciidoctor::PDF::Converter - Verse' do end it 'should show attribution line below text of verse' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [verse,Robert Frost,'Fire & Ice'] ____ Some say the world will end in fire, Some say in ice. ____ - EOS + END last_verse_text = pdf.text[-2] attribution_text = (pdf.find_text %r/Robert Frost/)[0] @@ -48,7 +48,7 @@ describe 'Asciidoctor::PDF::Converter - Verse' do end it 'should expand tabs and preserve indentation' do - pdf = to_pdf <<~EOS, analyze: true + pdf = to_pdf <<~END, analyze: true [verse] ____ here @@ -56,7 +56,7 @@ describe 'Asciidoctor::PDF::Converter - Verse' do \t\tgo again ____ - EOS + END lines = pdf.lines (expect lines).to have_size 4 @@ -65,58 +65,58 @@ describe 'Asciidoctor::PDF::Converter - Verse' do end it 'should honor text alignment role' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [verse.text-right] ____ Over here. ____ - EOS + END midpoint = pdf.pages[0][:size][0] * 0.5 (expect (pdf.find_unique_text 'Over here.')[:x]).to be > midpoint end it 'should not draw left border if border_left_width is 0' do - pdf = to_pdf <<~'EOS', pdf_theme: { verse_border_left_width: 0 }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { verse_border_left_width: 0 }, analyze: :line [verse] ____ here we go ____ - EOS + END (expect pdf.lines).to be_empty end it 'should not draw left border if border_left_width is nil' do - pdf = to_pdf <<~'EOS', pdf_theme: { verse_border_left_width: nil, verse_border_width: nil }, analyze: :line + pdf = to_pdf <<~'END', pdf_theme: { verse_border_left_width: nil, verse_border_width: nil }, analyze: :line [verse] ____ here we go ____ - EOS + END (expect pdf.lines).to be_empty end it 'should not draw left border if color is transparent' do - lines = (to_pdf <<~'EOS', pdf_theme: { verse_border_color: 'transparent' }, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: { verse_border_color: 'transparent' }, analyze: :line).lines [verse] ____ here we go ____ - EOS + END (expect lines).to be_empty end it 'should not draw left border if color is nil and base border color is nil' do - lines = (to_pdf <<~'EOS', pdf_theme: { base_border_color: nil, verse_border_color: nil }, analyze: :line).lines + lines = (to_pdf <<~'END', pdf_theme: { base_border_color: nil, verse_border_color: nil }, analyze: :line).lines before [verse] @@ -125,7 +125,7 @@ describe 'Asciidoctor::PDF::Converter - Verse' do we go ____ - EOS + END (expect lines).to be_empty end @@ -137,13 +137,13 @@ describe 'Asciidoctor::PDF::Converter - Verse' do verse_font_color: '555555', } - pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + pdf = to_pdf <<~'END', pdf_theme: pdf_theme, analyze: true [verse] ____ The fog comes on little cat feet. ____ - EOS + END text = pdf.text (expect text).to have_size 2 @@ -157,13 +157,13 @@ describe 'Asciidoctor::PDF::Converter - Verse' do verse_background_color: 'dddddd', verse_border_color: 'aa0000', } - to_file = to_pdf_file <<~'EOS', 'verse-background-color.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'verse-background-color.pdf', pdf_theme: pdf_theme [verse] ____ Let it be. Let it be. ____ - EOS + END (expect to_file).to visually_match 'verse-background-color.pdf' end @@ -176,26 +176,26 @@ describe 'Asciidoctor::PDF::Converter - Verse' do verse_background_color: 'dddddd', quote_padding: [12, 15], } - to_file = to_pdf_file <<~'EOS', 'verse-border-and-background-color.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~'END', 'verse-border-and-background-color.pdf', pdf_theme: pdf_theme [verse,Paul McCartney] ____ Let it be. Let it be. ____ - EOS + END (expect to_file).to visually_match 'verse-border-and-background-color.pdf' end it 'should apply correct padding around content' do - input = <<~'EOS' + input = <<~'END' [verse] ____ first last ____ - EOS + END pdf = to_pdf input, analyze: true lines = (to_pdf input, analyze: :line).lines @@ -212,14 +212,14 @@ describe 'Asciidoctor::PDF::Converter - Verse' do end it 'should apply correct padding around content when using base theme' do - input = <<~'EOS' + input = <<~'END' [verse] ____ first last ____ - EOS + END pdf = to_pdf input, attribute_overrides: { 'pdf-theme' => 'base' }, analyze: true lines = (to_pdf input, attribute_overrides: { 'pdf-theme' => 'base' }, analyze: :line).lines @@ -243,12 +243,12 @@ describe 'Asciidoctor::PDF::Converter - Verse' do verse_background_color: 'EEEEEE', verse_padding: [6, 10, 12, 10], } - to_file = to_pdf_file <<~EOS, 'verse-page-split.pdf', pdf_theme: pdf_theme + to_file = to_pdf_file <<~END, 'verse-page-split.pdf', pdf_theme: pdf_theme [verse] ____ #{(['Let it be.'] * 50).join ?\n} ____ - EOS + END (expect to_file).to visually_match 'verse-page-split.pdf' end @@ -261,7 +261,7 @@ describe 'Asciidoctor::PDF::Converter - Verse' do verse_border_left_width: 0, } pdf = with_content_spacer 10, 690 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] [verse] @@ -269,7 +269,7 @@ describe 'Asciidoctor::PDF::Converter - Verse' do content that wraps ____ - EOS + END end pages = pdf.pages @@ -280,7 +280,7 @@ describe 'Asciidoctor::PDF::Converter - Verse' do (expect last_text_y - pdf_theme[:verse_padding]).to be > 48.24 pdf = with_content_spacer 10, 692 do |spacer_path| - to_pdf <<~EOS, pdf_theme: pdf_theme, analyze: true + to_pdf <<~END, pdf_theme: pdf_theme, analyze: true image::#{spacer_path}[] [verse] @@ -288,7 +288,7 @@ describe 'Asciidoctor::PDF::Converter - Verse' do content that wraps ____ - EOS + END end pages = pdf.pages diff --git a/spec/video_spec.rb b/spec/video_spec.rb index 9daca159..77ff092d 100644 --- a/spec/video_spec.rb +++ b/spec/video_spec.rb @@ -5,27 +5,27 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Video' do context 'Local' do it 'should replace video with poster image if specified', visual: true do - to_file = to_pdf_file <<~'EOS', 'video-local-file-poster.pdf' + to_file = to_pdf_file <<~'END', 'video-local-file-poster.pdf' video::asciidoctor.mp4[logo.png,200,200] - EOS + END (expect to_file).to visually_match 'video-local-file-poster.pdf' end it 'should replace video with video path and play icon if poster not specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font video::asciidoctor.mp4[] - EOS + END (expect pdf.lines).to eql [%(\uf04b\u00a0#{fixture_file 'asciidoctor.mp4'} (video))] end it 'should wrap text for video if it exceeds width of content area' do - pdf = to_pdf <<~'EOS', analyze: true, attribute_overrides: { 'imagesdir' => '' } + pdf = to_pdf <<~'END', analyze: true, attribute_overrides: { 'imagesdir' => '' } video::a-video-with-an-excessively-long-and-descriptive-name-as-they-often-are-that-causes-the-text-to-wrap.mp4[] - EOS + END (expect pdf.pages).to have_size 1 lines = pdf.lines pdf.find_text page_number: 1 @@ -33,12 +33,12 @@ describe 'Asciidoctor::PDF::Converter - Video' do end it 'should show caption for video with no poster if title is specified' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :icons: font .Asciidoctor training video::asciidoctor.mp4[] - EOS + END (expect pdf.lines).to eql [%(\uf04b\u00a0#{fixture_file 'asciidoctor.mp4'} (video)), 'Asciidoctor training'] end @@ -47,9 +47,9 @@ describe 'Asciidoctor::PDF::Converter - Video' do context 'YouTube' do it 'should replace video with poster image if allow-uri-read attribute is set', network: true, visual: true do video_id = 'EJ09pSuA9hw' - to_file = to_pdf_file <<~EOS, 'video-youtube-poster.pdf', attribute_overrides: { 'allow-uri-read' => '' } + to_file = to_pdf_file <<~END, 'video-youtube-poster.pdf', attribute_overrides: { 'allow-uri-read' => '' } video::#{video_id}[youtube,pdfwidth=100%] - EOS + END pdf = PDF::Reader.new to_file annotations = get_annotations pdf, 1 @@ -81,9 +81,9 @@ describe 'Asciidoctor::PDF::Converter - Video' do context 'Vimeo' do it 'should replace video with poster image if allow-uri-read attribute is set', network: true, visual: true do video_id = '77477140' - to_file = to_pdf_file <<~EOS, 'video-vimeo-poster.pdf', attribute_overrides: { 'allow-uri-read' => '' } + to_file = to_pdf_file <<~END, 'video-vimeo-poster.pdf', attribute_overrides: { 'allow-uri-read' => '' } video::#{video_id}[vimeo,pdfwidth=100%] - EOS + END pdf = PDF::Reader.new to_file annotations = get_annotations pdf, 1 diff --git a/spec/xref_spec.rb b/spec/xref_spec.rb index 1a83b649..9430edda 100644 --- a/spec/xref_spec.rb +++ b/spec/xref_spec.rb @@ -5,7 +5,7 @@ require_relative 'spec_helper' describe 'Asciidoctor::PDF::Converter - Xref' do context 'internal' do it 'should create reference to a section by title' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book @@ -16,7 +16,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do == Chapter B Here are the details you're looking for. - EOS + END names = get_names pdf (expect names).to have_key '_chapter_a' @@ -28,7 +28,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should create reference to a section by implicit ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book @@ -39,7 +39,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do == Chapter B Here are the details you're looking for. - EOS + END names = get_names pdf (expect names).to have_key '_chapter_a' @@ -51,7 +51,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should create reference to a section by explicit ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book @@ -64,7 +64,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do == Chapter B Here are the details you're looking for. - EOS + END names = get_names pdf (expect names).to have_key 'a' @@ -76,13 +76,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should short-circuit circular reference in section title' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true [#a] == A <<b>> [#b] == B <<a>> - EOS + END (expect pdf.lines).to eql ['A B [a]', 'B [a]'] lines = pdf.text.map {|it| it[:y] }.uniq @@ -91,11 +91,11 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should reference section with ID that contains non-ASCII characters' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' == Über Étudier See <<_über_étudier>>. - EOS + END hex_encoded_id = %(0x#{('_über_étudier'.unpack 'H*')[0]}) annotations = get_annotations pdf, 1 @@ -105,7 +105,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should create reference to a block by explicit ID' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' = Document Title :doctype: book @@ -125,7 +125,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do | bar | 1 |=== - EOS + END names = get_names pdf (expect names).to have_key 'observed-values' @@ -136,13 +136,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should create reference to an anchor in a paragraph' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' Jump to the <<explanation>>. <<< [[explanation,explanation]]This is the explanation. - EOS + END names = get_names pdf (expect names).to have_key 'explanation' @@ -153,13 +153,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should create reference to a list item with an anchor' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' Jump to the <<first-item>>. <<< * [[first-item,first item]]list item - EOS + END names = get_names pdf (expect names).to have_key 'first-item' @@ -170,7 +170,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should create reference to a table cell with an anchor' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' Jump to the <<first-cell>>. <<< @@ -178,7 +178,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do |=== |[[first-cell,first cell]]table cell |=== - EOS + END names = get_names pdf (expect names).to have_key 'first-cell' @@ -189,9 +189,9 @@ describe 'Asciidoctor::PDF::Converter - Xref' do end it 'should show ID enclosed in square brackets if reference cannot be resolved' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' Road to <<nowhere>>. - EOS + END (expect (pdf.page 1).text).to eql 'Road to [nowhere].' names = get_names pdf @@ -271,7 +271,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do context 'xrefstyle' do it 'should refer to part by label and number when xrefstyle is short' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :partnums: @@ -288,13 +288,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do == Advanced Lesson If you are so advanced, why do you even need a lesson? - EOS + END (expect pdf.lines).to include 'Now you are ready for Part II!' end it 'should refer to part by name when xrefstyle is basic' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :partnums: @@ -311,13 +311,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do == Advanced Lesson If you are so advanced, why do you even need a lesson? - EOS + END (expect pdf.lines).to include 'Now you are ready for Advanced!' end it 'should refer to part by label, number, and title when xrefstyle is full' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :partnums: @@ -334,13 +334,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do == Advanced Lesson If you are so advanced, why do you even need a lesson? - EOS + END (expect pdf.lines).to include 'Now you are ready for Part II, “Advanced”!' end it 'should refer to chapter by label and number when xrefstyle is short' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :sectnums: @@ -349,13 +349,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do Start with <<_a>>. == A - EOS + END (expect pdf.lines).to include 'Start with Chapter 1.' end it 'should refer to chapter title and number when xrefstyle is basic' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :sectnums: @@ -364,13 +364,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do Start with <<_a>>. == A - EOS + END (expect pdf.lines).to include 'Start with A.' end it 'should refer to chapter label, number and title when xrefstyle is full' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :sectnums: @@ -379,13 +379,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do Start with <<_a>>. == A - EOS + END (expect pdf.lines).to include 'Start with Chapter 1, A.' end it 'should use xrefstyle specified on xref macro' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true = Document Title :doctype: book :sectnums: @@ -394,25 +394,25 @@ describe 'Asciidoctor::PDF::Converter - Xref' do Start with xref:_a[xrefstyle=full]. == A - EOS + END (expect pdf.lines).to include 'Start with Chapter 1, A.' end it 'should refer to image with title by title by default' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true See <<img>>. .Title of Image [#img] image::tux.png[] - EOS + END (expect pdf.lines[0]).to eql 'See Title of Image.' end it 'should refer to image with title by reference signifier, number, and title when xrefstyle is full' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :xrefstyle: full See <<img>>. @@ -420,13 +420,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do .Title of Image [#img] image::tux.png[] - EOS + END (expect pdf.lines[0]).to eql 'See Figure 1, “Title of Image”.' end it 'should refer to image with title by reference signifier and number when xrefstyle is short' do - pdf = to_pdf <<~'EOS', analyze: true + pdf = to_pdf <<~'END', analyze: true :xrefstyle: short See <<img>>. @@ -434,13 +434,13 @@ describe 'Asciidoctor::PDF::Converter - Xref' do .Title of Image [#img] image::tux.png[] - EOS + END (expect pdf.lines[0]).to eql 'See Figure 1.' end it 'should show ID of reference enclosed in square brackets if reference has no xreftext' do - pdf = to_pdf <<~'EOS' + pdf = to_pdf <<~'END' :xrefstyle: full Jump to the <<first-item>>. @@ -448,7 +448,7 @@ describe 'Asciidoctor::PDF::Converter - Xref' do <<< * [[first-item]]list item - EOS + END names = get_names pdf (expect names).to have_key 'first-item' diff --git a/tasks/rubocop.rake b/tasks/rubocop.rake index 99b7450e..612736c4 100644 --- a/tasks/rubocop.rake +++ b/tasks/rubocop.rake @@ -7,10 +7,10 @@ begin end rescue LoadError => e task :lint do - raise <<~'EOS', cause: e + raise <<~'END', cause: e Failed to load lint task. Install required gems using: bundle --path=.bundle/gems Next, invoke Rake using: bundle exec rake - EOS + END end end |
