asciidoctor 0.1.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +209 -25
- data/{LICENSE → LICENSE.adoc} +4 -3
- data/README.adoc +392 -395
- data/Rakefile +94 -137
- data/benchmark/benchmark.rb +127 -0
- data/benchmark/sample-data/mdbasics.adoc +334 -0
- data/bin/asciidoctor +5 -8
- data/bin/asciidoctor-safe +4 -8
- data/compat/asciidoc.conf +78 -11
- data/compat/font-awesome-3-compat.css +397 -0
- data/data/stylesheets/asciidoctor-default.css +399 -0
- data/data/stylesheets/coderay-asciidoctor.css +89 -0
- data/features/open_block.feature +92 -0
- data/features/pass_block.feature +66 -0
- data/features/step_definitions.rb +42 -0
- data/features/text_formatting.feature +55 -0
- data/features/xref.feature +116 -0
- data/lib/asciidoctor.rb +1155 -605
- data/lib/asciidoctor/abstract_block.rb +157 -71
- data/lib/asciidoctor/abstract_node.rb +150 -93
- data/lib/asciidoctor/attribute_list.rb +85 -90
- data/lib/asciidoctor/block.rb +51 -24
- data/lib/asciidoctor/callouts.rb +4 -7
- data/lib/asciidoctor/cli.rb +3 -0
- data/lib/asciidoctor/cli/invoker.rb +86 -76
- data/lib/asciidoctor/cli/options.rb +111 -61
- data/lib/asciidoctor/converter.rb +232 -0
- data/lib/asciidoctor/converter/base.rb +58 -0
- data/lib/asciidoctor/converter/composite.rb +66 -0
- data/lib/asciidoctor/converter/docbook45.rb +94 -0
- data/lib/asciidoctor/converter/docbook5.rb +684 -0
- data/lib/asciidoctor/converter/factory.rb +225 -0
- data/lib/asciidoctor/converter/html5.rb +1081 -0
- data/lib/asciidoctor/converter/template.rb +296 -0
- data/lib/asciidoctor/core_ext.rb +7 -0
- data/lib/asciidoctor/core_ext/object/nil_or_empty.rb +23 -0
- data/lib/asciidoctor/core_ext/string/chr.rb +6 -0
- data/lib/asciidoctor/core_ext/symbol/length.rb +6 -0
- data/lib/asciidoctor/document.rb +590 -304
- data/lib/asciidoctor/extensions.rb +1100 -308
- data/lib/asciidoctor/helpers.rb +109 -46
- data/lib/asciidoctor/inline.rb +16 -9
- data/lib/asciidoctor/list.rb +23 -15
- data/lib/asciidoctor/opal_ext.rb +4 -0
- data/lib/asciidoctor/opal_ext/comparable.rb +38 -0
- data/lib/asciidoctor/opal_ext/dir.rb +13 -0
- data/lib/asciidoctor/opal_ext/error.rb +2 -0
- data/lib/asciidoctor/opal_ext/file.rb +125 -0
- data/lib/asciidoctor/{lexer.rb → parser.rb} +646 -455
- data/lib/asciidoctor/path_resolver.rb +141 -77
- data/lib/asciidoctor/reader.rb +257 -187
- data/lib/asciidoctor/section.rb +12 -16
- data/lib/asciidoctor/stylesheets.rb +91 -0
- data/lib/asciidoctor/substitutors.rb +1548 -0
- data/lib/asciidoctor/table.rb +73 -57
- data/lib/asciidoctor/timings.rb +39 -0
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +22 -14
- data/man/asciidoctor.adoc +18 -10
- data/test/attributes_test.rb +314 -14
- data/test/blocks_test.rb +763 -118
- data/test/converter_test.rb +352 -0
- data/test/document_test.rb +518 -199
- data/test/extensions_test.rb +273 -103
- data/test/fixtures/asciidoc_index.txt +27 -13
- data/test/fixtures/basic-docinfo.xml +1 -1
- data/test/fixtures/chapter-a.adoc +3 -0
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
- data/test/fixtures/docinfo.xml +1 -1
- data/test/fixtures/include-file.asciidoc +2 -0
- data/test/fixtures/master.adoc +5 -0
- data/test/invoker_test.rb +173 -61
- data/test/links_test.rb +97 -21
- data/test/lists_test.rb +181 -22
- data/test/options_test.rb +86 -2
- data/test/paragraphs_test.rb +47 -5
- data/test/{lexer_test.rb → parser_test.rb} +128 -57
- data/test/paths_test.rb +36 -1
- data/test/preamble_test.rb +25 -17
- data/test/reader_test.rb +404 -249
- data/test/sections_test.rb +623 -58
- data/test/substitutions_test.rb +609 -132
- data/test/tables_test.rb +198 -24
- data/test/test_helper.rb +101 -31
- data/test/text_test.rb +88 -31
- metadata +160 -64
- data/Gemfile +0 -12
- data/Guardfile +0 -18
- data/asciidoctor.gemspec +0 -143
- data/lib/asciidoctor/backends/_stylesheets.rb +0 -466
- data/lib/asciidoctor/backends/base_template.rb +0 -114
- data/lib/asciidoctor/backends/docbook45.rb +0 -774
- data/lib/asciidoctor/backends/docbook5.rb +0 -103
- data/lib/asciidoctor/backends/html5.rb +0 -1214
- data/lib/asciidoctor/renderer.rb +0 -259
- data/lib/asciidoctor/substituters.rb +0 -1083
- data/test/fixtures/asciidoc.txt +0 -105
- data/test/fixtures/ascshort.txt +0 -32
- data/test/fixtures/list_elements.asciidoc +0 -10
- data/test/renderer_test.rb +0 -162
    
        data/test/paths_test.rb
    CHANGED
    
    | @@ -1,4 +1,8 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
            unless defined? ASCIIDOCTOR_PROJECT_DIR
         | 
| 3 | 
            +
              $: << File.dirname(__FILE__); $:.uniq!
         | 
| 4 | 
            +
              require 'test_helper'
         | 
| 5 | 
            +
            end
         | 
| 2 6 |  | 
| 3 7 | 
             
            context 'Path Resolver' do
         | 
| 4 8 | 
             
              context 'Web Paths' do
         | 
| @@ -18,6 +22,12 @@ context 'Path Resolver' do | |
| 18 22 | 
             
                  assert_equal 'images', @resolver.web_path('images', nil)
         | 
| 19 23 | 
             
                end
         | 
| 20 24 |  | 
| 25 | 
            +
                test 'target with hidden relative path' do
         | 
| 26 | 
            +
                  assert_equal '.images', @resolver.web_path('.images')
         | 
| 27 | 
            +
                  assert_equal '.images', @resolver.web_path('.images', '')
         | 
| 28 | 
            +
                  assert_equal '.images', @resolver.web_path('.images', nil)
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 21 31 | 
             
                test 'target with path relative to current directory' do
         | 
| 22 32 | 
             
                  assert_equal './images', @resolver.web_path('./images')
         | 
| 23 33 | 
             
                  assert_equal './images', @resolver.web_path('./images', '')
         | 
| @@ -150,12 +160,22 @@ context 'Path Resolver' do | |
| 150 160 | 
             
                  assert_equal '/usr/share/assets/stylesheet.css', @resolver.system_path('assets/stylesheet.css', '/usr/share')
         | 
| 151 161 | 
             
                end
         | 
| 152 162 |  | 
| 163 | 
            +
                test 'resolves absolute UNC path if start is absolute and target is relative' do
         | 
| 164 | 
            +
                  assert_equal '//QA/c$/users/asciidoctor/assets/stylesheet.css', @resolver.system_path('assets/stylesheet.css', '//QA/c$/users/asciidoctor')
         | 
| 165 | 
            +
                end
         | 
| 166 | 
            +
             | 
| 153 167 | 
             
                test 'resolves relative target relative to current directory if start is empty' do
         | 
| 154 168 | 
             
                  pwd = File.expand_path(Dir.pwd)
         | 
| 155 169 | 
             
                  assert_equal "#{pwd}/images/tiger.png", @resolver.system_path('images/tiger.png', '')
         | 
| 156 170 | 
             
                  assert_equal "#{pwd}/images/tiger.png", @resolver.system_path('images/tiger.png', nil)
         | 
| 157 171 | 
             
                end
         | 
| 158 172 |  | 
| 173 | 
            +
                test 'resolves relative hidden target relative to current directory if start is empty' do
         | 
| 174 | 
            +
                  pwd = File.expand_path(Dir.pwd)
         | 
| 175 | 
            +
                  assert_equal "#{pwd}/.images/tiger.png", @resolver.system_path('.images/tiger.png', '')
         | 
| 176 | 
            +
                  assert_equal "#{pwd}/.images/tiger.png", @resolver.system_path('.images/tiger.png', nil)
         | 
| 177 | 
            +
                end
         | 
| 178 | 
            +
             | 
| 159 179 | 
             
                test 'resolves and normalizes start with target is empty' do
         | 
| 160 180 | 
             
                  pwd = File.expand_path(Dir.pwd)
         | 
| 161 181 | 
             
                  assert_equal '/home/doctor/docs', @resolver.system_path('', '/home/doctor/docs')
         | 
| @@ -180,6 +200,21 @@ context 'Path Resolver' do | |
| 180 200 | 
             
                  assert_equal "#{JAIL}/part1/chapter1/section1.adoc", filename
         | 
| 181 201 | 
             
                  assert_equal 'part1/chapter1/section1.adoc', @resolver.relative_path(filename, JAIL)
         | 
| 182 202 | 
             
                end
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                test 'should resolve relative path relative to base dir in unsafe mode' do
         | 
| 205 | 
            +
                  base_dir = fixture_path 'base'
         | 
| 206 | 
            +
                  doc = empty_document :base_dir => base_dir, :safe => Asciidoctor::SafeMode::UNSAFE
         | 
| 207 | 
            +
                  expected = ::File.join base_dir, 'images', 'tiger.png'
         | 
| 208 | 
            +
                  actual = doc.normalize_system_path 'tiger.png', 'images'
         | 
| 209 | 
            +
                  assert_equal expected, actual
         | 
| 210 | 
            +
                end
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                test 'should resolve absolute path as absolute in unsafe mode' do
         | 
| 213 | 
            +
                  base_dir = fixture_path 'base'
         | 
| 214 | 
            +
                  doc = empty_document :base_dir => base_dir, :safe => Asciidoctor::SafeMode::UNSAFE
         | 
| 215 | 
            +
                  actual = doc.normalize_system_path 'tiger.png', '/etc/images'
         | 
| 216 | 
            +
                  assert_equal '/etc/images/tiger.png', actual
         | 
| 217 | 
            +
                end
         | 
| 183 218 | 
             
              end
         | 
| 184 219 |  | 
| 185 220 | 
             
              context 'Helpers' do
         | 
    
        data/test/preamble_test.rb
    CHANGED
    
    | @@ -1,11 +1,14 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
            unless defined? ASCIIDOCTOR_PROJECT_DIR
         | 
| 3 | 
            +
              $: << File.dirname(__FILE__); $:.uniq!
         | 
| 4 | 
            +
              require 'test_helper'
         | 
| 5 | 
            +
            end
         | 
| 2 6 |  | 
| 3 7 | 
             
            context 'Preamble' do
         | 
| 4 8 |  | 
| 5 9 | 
             
              test 'title and single paragraph preamble before section' do
         | 
| 6 10 | 
             
                input = <<-EOS
         | 
| 7 | 
            -
            Title
         | 
| 8 | 
            -
            =====
         | 
| 11 | 
            +
            = Title
         | 
| 9 12 |  | 
| 10 13 | 
             
            Preamble paragraph 1.
         | 
| 11 14 |  | 
| @@ -23,8 +26,7 @@ Section paragraph 1. | |
| 23 26 |  | 
| 24 27 | 
             
              test 'title and multi-paragraph preamble before section' do
         | 
| 25 28 | 
             
                input = <<-EOS
         | 
| 26 | 
            -
            Title
         | 
| 27 | 
            -
            =====
         | 
| 29 | 
            +
            = Title
         | 
| 28 30 |  | 
| 29 31 | 
             
            Preamble paragraph 1.
         | 
| 30 32 |  | 
| @@ -42,24 +44,21 @@ Section paragraph 1. | |
| 42 44 | 
             
                assert_xpath '//*[@id="preamble"]/following-sibling::*//p', result, 1
         | 
| 43 45 | 
             
              end
         | 
| 44 46 |  | 
| 45 | 
            -
              test ' | 
| 47 | 
            +
              test 'should not wrap content in preamble if document has title but no sections' do
         | 
| 46 48 | 
             
                input = <<-EOS
         | 
| 47 | 
            -
            Title
         | 
| 48 | 
            -
            =====
         | 
| 49 | 
            +
            = Title
         | 
| 49 50 |  | 
| 50 | 
            -
             | 
| 51 | 
            +
            paragraph
         | 
| 51 52 | 
             
                EOS
         | 
| 52 53 | 
             
                result = render_string(input)
         | 
| 53 54 | 
             
                assert_xpath '//p', result, 1
         | 
| 54 | 
            -
                assert_xpath '//*[@id=" | 
| 55 | 
            -
                assert_xpath '//*[@id=" | 
| 56 | 
            -
                assert_xpath '//*[@id="preamble"]/following-sibling::*', result, 0
         | 
| 55 | 
            +
                assert_xpath '//*[@id="content"]/*[@class="paragraph"]/p', result, 1
         | 
| 56 | 
            +
                assert_xpath '//*[@id="content"]/*[@class="paragraph"]/following-sibling::*', result, 0
         | 
| 57 57 | 
             
              end
         | 
| 58 58 |  | 
| 59 59 | 
             
              test 'title and section without preamble' do
         | 
| 60 60 | 
             
                input = <<-EOS
         | 
| 61 | 
            -
            Title
         | 
| 62 | 
            -
            =====
         | 
| 61 | 
            +
            = Title
         | 
| 63 62 |  | 
| 64 63 | 
             
            == First Section
         | 
| 65 64 |  | 
| @@ -87,26 +86,35 @@ Section paragraph 1. | |
| 87 86 |  | 
| 88 87 | 
             
              test 'preamble in book doctype' do
         | 
| 89 88 | 
             
                  input = <<-EOS
         | 
| 90 | 
            -
            Book
         | 
| 91 | 
            -
            ====
         | 
| 89 | 
            +
            = Book
         | 
| 92 90 | 
             
            :doctype: book
         | 
| 93 91 |  | 
| 94 92 | 
             
            Back then...
         | 
| 95 93 |  | 
| 96 94 | 
             
            = Chapter One
         | 
| 97 95 |  | 
| 96 | 
            +
            [partintro]
         | 
| 98 97 | 
             
            It was a dark and stormy night...
         | 
| 99 98 |  | 
| 99 | 
            +
            == Scene One
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            Someone's gonna get axed.
         | 
| 102 | 
            +
             | 
| 100 103 | 
             
            = Chapter Two
         | 
| 101 104 |  | 
| 105 | 
            +
            [partintro]
         | 
| 102 106 | 
             
            They couldn't believe their eyes when...
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            == Scene One
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            The axe came swinging.
         | 
| 103 111 | 
             
                  EOS
         | 
| 104 112 |  | 
| 105 113 | 
             
                  d = document_from_string(input)
         | 
| 106 114 | 
             
                  assert_equal 'book', d.doctype 
         | 
| 107 115 | 
             
                  output = d.render
         | 
| 108 116 | 
             
                  assert_xpath '//h1', output, 3
         | 
| 109 | 
            -
                  assert_xpath %{//*[@id="preamble"]//p[text() = "Back then#{ | 
| 117 | 
            +
                  assert_xpath %{//*[@id="preamble"]//p[text() = "Back then#{expand_entity 8230}#{expand_entity 8203}"]}, output, 1
         | 
| 110 118 | 
             
              end
         | 
| 111 119 |  | 
| 112 120 | 
             
              test 'should render table of contents in preamble if toc-placement attribute value is preamble' do
         | 
    
        data/test/reader_test.rb
    CHANGED
    
    | @@ -1,9 +1,13 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
            unless defined? ASCIIDOCTOR_PROJECT_DIR
         | 
| 3 | 
            +
              $: << File.dirname(__FILE__); $:.uniq!
         | 
| 4 | 
            +
              require 'test_helper'
         | 
| 5 | 
            +
            end
         | 
| 2 6 |  | 
| 3 | 
            -
            class ReaderTest < Test | 
| 7 | 
            +
            class ReaderTest < Minitest::Test
         | 
| 4 8 | 
             
              DIRNAME = File.expand_path(File.dirname(__FILE__))
         | 
| 5 9 |  | 
| 6 | 
            -
              SAMPLE_DATA = <<-EOS. | 
| 10 | 
            +
              SAMPLE_DATA = <<-EOS.chomp.split(::Asciidoctor::EOL)
         | 
| 7 11 | 
             
            first line
         | 
| 8 12 | 
             
            second line
         | 
| 9 13 | 
             
            third line
         | 
| @@ -20,6 +24,51 @@ third line | |
| 20 24 | 
             
                    reader = Asciidoctor::Reader.new SAMPLE_DATA
         | 
| 21 25 | 
             
                    assert_equal SAMPLE_DATA, reader.lines
         | 
| 22 26 | 
             
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  test 'should remove UTF-8 BOM from first line of String data' do
         | 
| 29 | 
            +
                    data = "\xef\xbb\xbf#{SAMPLE_DATA.join ::Asciidoctor::EOL}"
         | 
| 30 | 
            +
                    reader = Asciidoctor::Reader.new data, nil, :normalize => true
         | 
| 31 | 
            +
                    assert_equal 'f', reader.lines.first[0..0]
         | 
| 32 | 
            +
                    assert_equal SAMPLE_DATA, reader.lines
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  test 'should remove UTF-8 BOM from first line of Array data' do
         | 
| 36 | 
            +
                    data = SAMPLE_DATA.dup
         | 
| 37 | 
            +
                    data[0] = "\xef\xbb\xbf#{data.first}"
         | 
| 38 | 
            +
                    reader = Asciidoctor::Reader.new data, nil, :normalize => true
         | 
| 39 | 
            +
                    assert_equal 'f', reader.lines.first[0..0]
         | 
| 40 | 
            +
                    assert_equal SAMPLE_DATA, reader.lines
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  if Asciidoctor::COERCE_ENCODING
         | 
| 44 | 
            +
                    test 'should encode UTF-16LE string to UTF-8 when BOM is found' do
         | 
| 45 | 
            +
                      data = "\uFEFF#{SAMPLE_DATA.join ::Asciidoctor::EOL}".encode('UTF-16LE').force_encoding('UTF-8')
         | 
| 46 | 
            +
                      reader = Asciidoctor::Reader.new data, nil, :normalize => true
         | 
| 47 | 
            +
                      assert_equal 'f', reader.lines.first[0..0]
         | 
| 48 | 
            +
                      assert_equal SAMPLE_DATA, reader.lines
         | 
| 49 | 
            +
                    end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                    test 'should encode UTF-16LE string array to UTF-8 when BOM is found' do
         | 
| 52 | 
            +
                      data = "\uFEFF#{SAMPLE_DATA.join ::Asciidoctor::EOL}".encode('UTF-16LE').force_encoding('UTF-8').lines.to_a
         | 
| 53 | 
            +
                      reader = Asciidoctor::Reader.new data, nil, :normalize => true
         | 
| 54 | 
            +
                      assert_equal 'f', reader.lines.first[0..0]
         | 
| 55 | 
            +
                      assert_equal SAMPLE_DATA, reader.lines
         | 
| 56 | 
            +
                    end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                    test 'should encode UTF-16BE string to UTF-8 when BOM is found' do
         | 
| 59 | 
            +
                      data = "\uFEFF#{SAMPLE_DATA.join ::Asciidoctor::EOL}".encode('UTF-16BE').force_encoding('UTF-8')
         | 
| 60 | 
            +
                      reader = Asciidoctor::Reader.new data, nil, :normalize => true
         | 
| 61 | 
            +
                      assert_equal 'f', reader.lines.first[0..0]
         | 
| 62 | 
            +
                      assert_equal SAMPLE_DATA, reader.lines
         | 
| 63 | 
            +
                    end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    test 'should encode UTF-16BE string array to UTF-8 when BOM is found' do
         | 
| 66 | 
            +
                      data = "\uFEFF#{SAMPLE_DATA.join ::Asciidoctor::EOL}".encode('UTF-16BE').force_encoding('UTF-8').lines.to_a
         | 
| 67 | 
            +
                      reader = Asciidoctor::Reader.new data, nil, :normalize => true
         | 
| 68 | 
            +
                      assert_equal 'f', reader.lines.first[0..0]
         | 
| 69 | 
            +
                      assert_equal SAMPLE_DATA, reader.lines
         | 
| 70 | 
            +
                    end
         | 
| 71 | 
            +
                  end
         | 
| 23 72 | 
             
                end
         | 
| 24 73 |  | 
| 25 74 | 
             
                context 'With empty data' do
         | 
| @@ -73,7 +122,7 @@ third line | |
| 73 122 | 
             
                  end
         | 
| 74 123 |  | 
| 75 124 | 
             
                  test 'next_line_empty? should return true if next line is blank' do
         | 
| 76 | 
            -
                    reader = Asciidoctor::Reader.new [ | 
| 125 | 
            +
                    reader = Asciidoctor::Reader.new ['', 'second line']
         | 
| 77 126 | 
             
                    assert reader.next_line_empty?
         | 
| 78 127 | 
             
                  end
         | 
| 79 128 |  | 
| @@ -135,7 +184,7 @@ third line | |
| 135 184 |  | 
| 136 185 | 
             
                  test 'read should return all lines joined as String' do
         | 
| 137 186 | 
             
                    reader = Asciidoctor::Reader.new SAMPLE_DATA
         | 
| 138 | 
            -
                    assert_equal SAMPLE_DATA.join, reader.read
         | 
| 187 | 
            +
                    assert_equal SAMPLE_DATA.join(::Asciidoctor::EOL), reader.read
         | 
| 139 188 | 
             
                  end
         | 
| 140 189 |  | 
| 141 190 | 
             
                  test 'has_more_lines? should return false after read_lines is invoked' do
         | 
| @@ -145,10 +194,10 @@ third line | |
| 145 194 | 
             
                  end
         | 
| 146 195 |  | 
| 147 196 | 
             
                  test 'unshift puts line onto Reader as next line to read' do
         | 
| 148 | 
            -
                    reader = Asciidoctor::Reader.new SAMPLE_DATA
         | 
| 149 | 
            -
                    reader.unshift  | 
| 150 | 
            -
                    assert_equal  | 
| 151 | 
            -
                    assert_equal  | 
| 197 | 
            +
                    reader = Asciidoctor::Reader.new SAMPLE_DATA, nil, :normalize => true
         | 
| 198 | 
            +
                    reader.unshift 'line zero'
         | 
| 199 | 
            +
                    assert_equal 'line zero', reader.peek_line
         | 
| 200 | 
            +
                    assert_equal 'line zero', reader.read_line
         | 
| 152 201 | 
             
                    assert_equal 1, reader.lineno
         | 
| 153 202 | 
             
                  end
         | 
| 154 203 |  | 
| @@ -160,7 +209,7 @@ third line | |
| 160 209 | 
             
                  end
         | 
| 161 210 |  | 
| 162 211 | 
             
                  test 'skip_blank_lines should skip blank lines' do
         | 
| 163 | 
            -
                    reader = Asciidoctor::Reader.new [ | 
| 212 | 
            +
                    reader = Asciidoctor::Reader.new ['', ''].concat(SAMPLE_DATA)
         | 
| 164 213 | 
             
                    reader.skip_blank_lines
         | 
| 165 214 | 
             
                    assert_equal SAMPLE_DATA.first, reader.peek_line
         | 
| 166 215 | 
             
                  end
         | 
| @@ -180,64 +229,64 @@ third line | |
| 180 229 | 
             
                  test 'source should return original data Array joined as String' do
         | 
| 181 230 | 
             
                    reader = Asciidoctor::Reader.new SAMPLE_DATA
         | 
| 182 231 | 
             
                    reader.read_lines
         | 
| 183 | 
            -
                    assert_equal SAMPLE_DATA.join, reader.source
         | 
| 232 | 
            +
                    assert_equal SAMPLE_DATA.join(::Asciidoctor::EOL), reader.source
         | 
| 184 233 | 
             
                  end
         | 
| 185 234 |  | 
| 186 235 | 
             
                end
         | 
| 187 236 |  | 
| 188 237 | 
             
                context 'Line context' do
         | 
| 189 238 | 
             
                  test 'to_s should return file name and line number of current line' do
         | 
| 190 | 
            -
                    reader = Asciidoctor::Reader.new SAMPLE_DATA, 'sample. | 
| 239 | 
            +
                    reader = Asciidoctor::Reader.new SAMPLE_DATA, 'sample.adoc'
         | 
| 191 240 | 
             
                    reader.read_line
         | 
| 192 | 
            -
                    assert_equal 'sample. | 
| 241 | 
            +
                    assert_equal 'sample.adoc: line 2', reader.to_s
         | 
| 193 242 | 
             
                  end
         | 
| 194 243 |  | 
| 195 244 | 
             
                  test 'line_info should return file name and line number of current line' do
         | 
| 196 | 
            -
                    reader = Asciidoctor::Reader.new SAMPLE_DATA, 'sample. | 
| 245 | 
            +
                    reader = Asciidoctor::Reader.new SAMPLE_DATA, 'sample.adoc'
         | 
| 197 246 | 
             
                    reader.read_line
         | 
| 198 | 
            -
                    assert_equal 'sample. | 
| 199 | 
            -
                    assert_equal 'sample. | 
| 247 | 
            +
                    assert_equal 'sample.adoc: line 2', reader.line_info
         | 
| 248 | 
            +
                    assert_equal 'sample.adoc: line 2', reader.next_line_info
         | 
| 200 249 | 
             
                  end
         | 
| 201 250 |  | 
| 202 251 | 
             
                  test 'prev_line_info should return file name and line number of previous line read' do
         | 
| 203 | 
            -
                    reader = Asciidoctor::Reader.new SAMPLE_DATA, 'sample. | 
| 252 | 
            +
                    reader = Asciidoctor::Reader.new SAMPLE_DATA, 'sample.adoc'
         | 
| 204 253 | 
             
                    reader.read_line
         | 
| 205 | 
            -
                    assert_equal 'sample. | 
| 254 | 
            +
                    assert_equal 'sample.adoc: line 1', reader.prev_line_info
         | 
| 206 255 | 
             
                  end
         | 
| 207 256 | 
             
                end
         | 
| 208 257 |  | 
| 209 258 | 
             
                context 'Read lines until' do
         | 
| 210 259 | 
             
                  test 'Read lines until until end' do
         | 
| 211 | 
            -
                    lines = <<-EOS. | 
| 260 | 
            +
                    lines = <<-EOS.lines.entries
         | 
| 212 261 | 
             
            This is one paragraph.
         | 
| 213 262 |  | 
| 214 263 | 
             
            This is another paragraph.
         | 
| 215 264 | 
             
                    EOS
         | 
| 216 265 |  | 
| 217 | 
            -
                    reader = Asciidoctor::Reader.new lines
         | 
| 266 | 
            +
                    reader = Asciidoctor::Reader.new lines, nil, :normalize => true
         | 
| 218 267 | 
             
                    result = reader.read_lines_until
         | 
| 219 268 | 
             
                    assert_equal 3, result.size
         | 
| 220 | 
            -
                    assert_equal lines, result
         | 
| 269 | 
            +
                    assert_equal lines.map {|l| l.chomp }, result
         | 
| 221 270 | 
             
                    assert !reader.has_more_lines?
         | 
| 222 271 | 
             
                    assert reader.eof?
         | 
| 223 272 | 
             
                  end
         | 
| 224 273 |  | 
| 225 274 | 
             
                  test 'Read lines until until blank line' do
         | 
| 226 | 
            -
                    lines = <<-EOS. | 
| 275 | 
            +
                    lines = <<-EOS.lines.entries
         | 
| 227 276 | 
             
            This is one paragraph.
         | 
| 228 277 |  | 
| 229 278 | 
             
            This is another paragraph.
         | 
| 230 279 | 
             
                    EOS
         | 
| 231 280 |  | 
| 232 | 
            -
                    reader = Asciidoctor::Reader.new lines
         | 
| 281 | 
            +
                    reader = Asciidoctor::Reader.new lines, nil, :normalize => true
         | 
| 233 282 | 
             
                    result = reader.read_lines_until :break_on_blank_lines => true
         | 
| 234 283 | 
             
                    assert_equal 1, result.size
         | 
| 235 284 | 
             
                    assert_equal lines.first.chomp, result.first
         | 
| 236 | 
            -
                    assert_equal lines.last, reader.peek_line
         | 
| 285 | 
            +
                    assert_equal lines.last.chomp, reader.peek_line
         | 
| 237 286 | 
             
                  end
         | 
| 238 287 |  | 
| 239 288 | 
             
                  test 'Read lines until until blank line preserving last line' do
         | 
| 240 | 
            -
                    lines = <<-EOS. | 
| 289 | 
            +
                    lines = <<-EOS.chomp.split(::Asciidoctor::EOL)
         | 
| 241 290 | 
             
            This is one paragraph.
         | 
| 242 291 |  | 
| 243 292 | 
             
            This is another paragraph.
         | 
| @@ -251,7 +300,7 @@ This is another paragraph. | |
| 251 300 | 
             
                  end
         | 
| 252 301 |  | 
| 253 302 | 
             
                  test 'Read lines until until condition is true' do
         | 
| 254 | 
            -
                    lines = <<-EOS. | 
| 303 | 
            +
                    lines = <<-EOS.chomp.split(::Asciidoctor::EOL)
         | 
| 255 304 | 
             
            --
         | 
| 256 305 | 
             
            This is one paragraph inside the block.
         | 
| 257 306 |  | 
| @@ -263,14 +312,14 @@ This is a paragraph outside the block. | |
| 263 312 |  | 
| 264 313 | 
             
                    reader = Asciidoctor::Reader.new lines
         | 
| 265 314 | 
             
                    reader.read_line
         | 
| 266 | 
            -
                    result = reader.read_lines_until {|line| line | 
| 315 | 
            +
                    result = reader.read_lines_until {|line| line == '--' }
         | 
| 267 316 | 
             
                    assert_equal 3, result.size
         | 
| 268 317 | 
             
                    assert_equal lines[1, 3], result
         | 
| 269 318 | 
             
                    assert reader.next_line_empty?
         | 
| 270 319 | 
             
                  end
         | 
| 271 320 |  | 
| 272 321 | 
             
                  test 'Read lines until until condition is true, taking last line' do
         | 
| 273 | 
            -
                    lines = <<-EOS. | 
| 322 | 
            +
                    lines = <<-EOS.chomp.split(::Asciidoctor::EOL)
         | 
| 274 323 | 
             
            --
         | 
| 275 324 | 
             
            This is one paragraph inside the block.
         | 
| 276 325 |  | 
| @@ -282,14 +331,14 @@ This is a paragraph outside the block. | |
| 282 331 |  | 
| 283 332 | 
             
                    reader = Asciidoctor::Reader.new lines
         | 
| 284 333 | 
             
                    reader.read_line
         | 
| 285 | 
            -
                    result = reader.read_lines_until(:read_last_line => true) {|line| line | 
| 334 | 
            +
                    result = reader.read_lines_until(:read_last_line => true) {|line| line == '--' }
         | 
| 286 335 | 
             
                    assert_equal 4, result.size
         | 
| 287 336 | 
             
                    assert_equal lines[1, 4], result
         | 
| 288 337 | 
             
                    assert reader.next_line_empty?
         | 
| 289 338 | 
             
                  end
         | 
| 290 339 |  | 
| 291 340 | 
             
                  test 'Read lines until until condition is true, taking and preserving last line' do
         | 
| 292 | 
            -
                    lines = <<-EOS. | 
| 341 | 
            +
                    lines = <<-EOS.chomp.split(::Asciidoctor::EOL)
         | 
| 293 342 | 
             
            --
         | 
| 294 343 | 
             
            This is one paragraph inside the block.
         | 
| 295 344 |  | 
| @@ -301,10 +350,10 @@ This is a paragraph outside the block. | |
| 301 350 |  | 
| 302 351 | 
             
                    reader = Asciidoctor::Reader.new lines
         | 
| 303 352 | 
             
                    reader.read_line
         | 
| 304 | 
            -
                    result = reader.read_lines_until(:read_last_line => true, :preserve_last_line => true) {|line| line | 
| 353 | 
            +
                    result = reader.read_lines_until(:read_last_line => true, :preserve_last_line => true) {|line| line == '--' }
         | 
| 305 354 | 
             
                    assert_equal 4, result.size
         | 
| 306 355 | 
             
                    assert_equal lines[1, 4], result
         | 
| 307 | 
            -
                    assert_equal  | 
| 356 | 
            +
                    assert_equal '--', reader.peek_line
         | 
| 308 357 | 
             
                  end
         | 
| 309 358 | 
             
                end
         | 
| 310 359 | 
             
              end
         | 
| @@ -312,14 +361,13 @@ This is a paragraph outside the block. | |
| 312 361 | 
             
              context 'PreprocessorReader' do
         | 
| 313 362 | 
             
                context 'Type hierarchy' do
         | 
| 314 363 | 
             
                  test 'PreprocessorReader should extend from Reader' do
         | 
| 315 | 
            -
                     | 
| 316 | 
            -
                    reader = Asciidoctor::PreprocessorReader.new doc
         | 
| 364 | 
            +
                    reader = empty_document.reader
         | 
| 317 365 | 
             
                    assert reader.is_a?(Asciidoctor::Reader)
         | 
| 318 366 | 
             
                  end
         | 
| 319 367 |  | 
| 320 368 | 
             
                  test 'PreprocessorReader should invoke or emulate Reader initializer' do
         | 
| 321 | 
            -
                    doc = Asciidoctor::Document.new
         | 
| 322 | 
            -
                    reader =  | 
| 369 | 
            +
                    doc = Asciidoctor::Document.new SAMPLE_DATA
         | 
| 370 | 
            +
                    reader = doc.reader
         | 
| 323 371 | 
             
                    assert_equal SAMPLE_DATA, reader.lines
         | 
| 324 372 | 
             
                    assert_equal 1, reader.lineno
         | 
| 325 373 | 
             
                  end
         | 
| @@ -327,21 +375,21 @@ This is a paragraph outside the block. | |
| 327 375 |  | 
| 328 376 | 
             
                context 'Prepare lines' do
         | 
| 329 377 | 
             
                  test 'should prepare and normalize lines from Array data' do
         | 
| 330 | 
            -
                    doc = Asciidoctor::Document.new
         | 
| 331 378 | 
             
                    data = SAMPLE_DATA.map {|line| line.chomp}
         | 
| 332 379 | 
             
                    data.unshift ''
         | 
| 333 380 | 
             
                    data.push ''
         | 
| 334 | 
            -
                     | 
| 381 | 
            +
                    doc = Asciidoctor::Document.new data
         | 
| 382 | 
            +
                    reader = doc.reader
         | 
| 335 383 | 
             
                    assert_equal SAMPLE_DATA, reader.lines
         | 
| 336 384 | 
             
                  end
         | 
| 337 385 |  | 
| 338 386 | 
             
                  test 'should prepare and normalize lines from String data' do
         | 
| 339 | 
            -
                    doc = Asciidoctor::Document.new
         | 
| 340 387 | 
             
                    data = SAMPLE_DATA.map {|line| line.chomp}
         | 
| 341 388 | 
             
                    data.unshift ' '
         | 
| 342 389 | 
             
                    data.push ' '
         | 
| 343 | 
            -
                    data_as_string = data *  | 
| 344 | 
            -
                     | 
| 390 | 
            +
                    data_as_string = data * ::Asciidoctor::EOL
         | 
| 391 | 
            +
                    doc = Asciidoctor::Document.new data_as_string
         | 
| 392 | 
            +
                    reader = doc.reader
         | 
| 345 393 | 
             
                    assert_equal SAMPLE_DATA, reader.lines
         | 
| 346 394 | 
             
                  end
         | 
| 347 395 |  | 
| @@ -353,13 +401,13 @@ CRLF\r | |
| 353 401 | 
             
            endlines\r
         | 
| 354 402 | 
             
                  EOS
         | 
| 355 403 |  | 
| 356 | 
            -
                     | 
| 357 | 
            -
             | 
| 358 | 
            -
                      reader =  | 
| 404 | 
            +
                    [input, input.lines.to_a, input.split(::Asciidoctor::EOL), input.split(::Asciidoctor::EOL).join(::Asciidoctor::EOL)].each do |lines|
         | 
| 405 | 
            +
                      doc = Asciidoctor::Document.new lines
         | 
| 406 | 
            +
                      reader = doc.reader
         | 
| 359 407 | 
             
                      reader.lines.each do |line|
         | 
| 360 408 | 
             
                        assert !line.end_with?("\r"), "CRLF not properly cleaned for source lines: #{lines.inspect}"
         | 
| 361 409 | 
             
                        assert !line.end_with?("\r\n"), "CRLF not properly cleaned for source lines: #{lines.inspect}"
         | 
| 362 | 
            -
                        assert line.end_with?("\n"), "CRLF not properly cleaned for source lines: #{lines.inspect}"
         | 
| 410 | 
            +
                        assert !line.end_with?("\n"), "CRLF not properly cleaned for source lines: #{lines.inspect}"
         | 
| 363 411 | 
             
                      end
         | 
| 364 412 | 
             
                    end
         | 
| 365 413 | 
             
                  end
         | 
| @@ -378,9 +426,10 @@ Author Name | |
| 378 426 | 
             
            preamble
         | 
| 379 427 | 
             
                    EOS
         | 
| 380 428 |  | 
| 381 | 
            -
                    doc = Asciidoctor::Document.new
         | 
| 382 | 
            -
                    reader =  | 
| 383 | 
            -
                     | 
| 429 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 430 | 
            +
                    reader = doc.reader
         | 
| 431 | 
            +
                    assert !doc.attributes.key?('front-matter')
         | 
| 432 | 
            +
                    assert_equal '---', reader.peek_line
         | 
| 384 433 | 
             
                end
         | 
| 385 434 |  | 
| 386 435 | 
             
                test 'should skip front matter if specified by skip-front-matter attribute' do
         | 
| @@ -398,24 +447,55 @@ Author Name | |
| 398 447 | 
             
            preamble
         | 
| 399 448 | 
             
                    EOS
         | 
| 400 449 |  | 
| 401 | 
            -
                    doc = Asciidoctor::Document.new  | 
| 402 | 
            -
                    reader =  | 
| 403 | 
            -
                    assert_equal '= Document Title', reader.peek_line | 
| 450 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => {'skip-front-matter' => ''}
         | 
| 451 | 
            +
                    reader = doc.reader
         | 
| 452 | 
            +
                    assert_equal '= Document Title', reader.peek_line
         | 
| 404 453 | 
             
                    assert_equal front_matter, doc.attributes['front-matter']
         | 
| 405 454 | 
             
                  end
         | 
| 406 455 | 
             
                end
         | 
| 407 456 |  | 
| 408 | 
            -
                context 'Include  | 
| 409 | 
            -
                  test ' | 
| 457 | 
            +
                context 'Include Stack' do
         | 
| 458 | 
            +
                  test 'PreprocessorReader#push_include method should return nil' do
         | 
| 459 | 
            +
                    reader = empty_document.reader
         | 
| 460 | 
            +
                    append_lines = %w(one two three)
         | 
| 461 | 
            +
                    result = reader.push_include append_lines, '<stdin>', '<stdin>'
         | 
| 462 | 
            +
                    assert_nil result
         | 
| 463 | 
            +
                  end
         | 
| 464 | 
            +
             | 
| 465 | 
            +
                  test 'PreprocessorReader#push_include method should put lines on top of stack' do
         | 
| 466 | 
            +
                    lines = %w(a b c)
         | 
| 467 | 
            +
                    doc = Asciidoctor::Document.new lines
         | 
| 468 | 
            +
                    reader = doc.reader
         | 
| 469 | 
            +
                    append_lines = %w(one two three)
         | 
| 470 | 
            +
                    reader.push_include append_lines, '', '<stdin>'
         | 
| 471 | 
            +
                    assert_equal 1, reader.include_stack.size
         | 
| 472 | 
            +
                    assert_equal 'one', reader.read_line.rstrip
         | 
| 473 | 
            +
                  end
         | 
| 474 | 
            +
             | 
| 475 | 
            +
                  test 'PreprocessorReader#push_include method should gracefully handle file and path' do
         | 
| 476 | 
            +
                    lines = %w(a b c)
         | 
| 477 | 
            +
                    doc = Asciidoctor::Document.new lines
         | 
| 478 | 
            +
                    reader = doc.reader
         | 
| 479 | 
            +
                    append_lines = %w(one two three)
         | 
| 480 | 
            +
                    reader.push_include append_lines
         | 
| 481 | 
            +
                    assert_equal 1, reader.include_stack.size
         | 
| 482 | 
            +
                    assert_equal 'one', reader.read_line.rstrip
         | 
| 483 | 
            +
                    assert_nil reader.file
         | 
| 484 | 
            +
                    assert_equal '<stdin>', reader.path
         | 
| 485 | 
            +
                  end
         | 
| 486 | 
            +
                end
         | 
| 487 | 
            +
             | 
| 488 | 
            +
                context 'Include Directive' do
         | 
| 489 | 
            +
                  test 'include directive is disabled by default and becomes a link' do
         | 
| 410 490 | 
             
                    input = <<-EOS
         | 
| 411 491 | 
             
            include::include-file.asciidoc[]
         | 
| 412 492 | 
             
                    EOS
         | 
| 413 | 
            -
                    doc =  | 
| 414 | 
            -
                    reader =  | 
| 415 | 
            -
                    assert_equal 'link:include-file.asciidoc[]', reader.read_line | 
| 493 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 494 | 
            +
                    reader = doc.reader
         | 
| 495 | 
            +
                    assert_equal 'link:include-file.asciidoc[]', reader.read_line
         | 
| 416 496 | 
             
                  end
         | 
| 417 497 |  | 
| 418 | 
            -
                  test 'include  | 
| 498 | 
            +
                  test 'include directive is enabled when safe mode is less than SECURE' do
         | 
| 419 499 | 
             
                    input = <<-EOS
         | 
| 420 500 | 
             
            include::fixtures/include-file.asciidoc[]
         | 
| 421 501 | 
             
                    EOS
         | 
| @@ -425,7 +505,41 @@ include::fixtures/include-file.asciidoc[] | |
| 425 505 | 
             
                    assert_match(/included content/, output)
         | 
| 426 506 | 
             
                  end
         | 
| 427 507 |  | 
| 428 | 
            -
                  test 'include  | 
| 508 | 
            +
                  test 'include directive should resolve file with spaces in name' do
         | 
| 509 | 
            +
                    input = <<-EOS
         | 
| 510 | 
            +
            include::fixtures/include file.asciidoc[]
         | 
| 511 | 
            +
                    EOS
         | 
| 512 | 
            +
              
         | 
| 513 | 
            +
                    include_file = File.join DIRNAME, 'fixtures', 'include-file.asciidoc'
         | 
| 514 | 
            +
                    include_file_with_sp = File.join DIRNAME, 'fixtures', 'include file.asciidoc'
         | 
| 515 | 
            +
                    begin
         | 
| 516 | 
            +
                      FileUtils.cp include_file, include_file_with_sp
         | 
| 517 | 
            +
                      doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 518 | 
            +
                      output = doc.render
         | 
| 519 | 
            +
                      assert_match(/included content/, output)
         | 
| 520 | 
            +
                    ensure
         | 
| 521 | 
            +
                      FileUtils.rm include_file_with_sp
         | 
| 522 | 
            +
                    end
         | 
| 523 | 
            +
                  end
         | 
| 524 | 
            +
             | 
| 525 | 
            +
                  test 'include directive should resolve file with {sp} in name' do
         | 
| 526 | 
            +
                    input = <<-EOS
         | 
| 527 | 
            +
            include::fixtures/include{sp}file.asciidoc[]
         | 
| 528 | 
            +
                    EOS
         | 
| 529 | 
            +
              
         | 
| 530 | 
            +
                    include_file = File.join DIRNAME, 'fixtures', 'include-file.asciidoc'
         | 
| 531 | 
            +
                    include_file_with_sp = File.join DIRNAME, 'fixtures', 'include file.asciidoc'
         | 
| 532 | 
            +
                    begin
         | 
| 533 | 
            +
                      FileUtils.cp include_file, include_file_with_sp
         | 
| 534 | 
            +
                      doc = document_from_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 535 | 
            +
                      output = doc.render
         | 
| 536 | 
            +
                      assert_match(/included content/, output)
         | 
| 537 | 
            +
                    ensure
         | 
| 538 | 
            +
                      FileUtils.rm include_file_with_sp
         | 
| 539 | 
            +
                    end
         | 
| 540 | 
            +
                  end
         | 
| 541 | 
            +
             | 
| 542 | 
            +
                  test 'include directive should resolve file relative to current include' do
         | 
| 429 543 | 
             
                    input = <<-EOS
         | 
| 430 544 | 
             
            include::fixtures/parent-include.adoc[]
         | 
| 431 545 | 
             
                    EOS
         | 
| @@ -443,7 +557,7 @@ include::fixtures/parent-include.adoc[] | |
| 443 557 | 
             
                    assert_equal DIRNAME, reader.dir
         | 
| 444 558 | 
             
                    assert_equal 'include-master.adoc', reader.path
         | 
| 445 559 |  | 
| 446 | 
            -
                    assert_equal  | 
| 560 | 
            +
                    assert_equal 'first line of parent', reader.read_line
         | 
| 447 561 |  | 
| 448 562 | 
             
                    assert_equal 'fixtures/parent-include.adoc: line 1', reader.prev_line_info
         | 
| 449 563 | 
             
                    assert_equal parent_include_docfile, reader.file
         | 
| @@ -452,7 +566,7 @@ include::fixtures/parent-include.adoc[] | |
| 452 566 |  | 
| 453 567 | 
             
                    reader.skip_blank_lines
         | 
| 454 568 |  | 
| 455 | 
            -
                    assert_equal  | 
| 569 | 
            +
                    assert_equal 'first line of child', reader.read_line
         | 
| 456 570 |  | 
| 457 571 | 
             
                    assert_equal 'fixtures/child-include.adoc: line 1', reader.prev_line_info
         | 
| 458 572 | 
             
                    assert_equal child_include_docfile, reader.file
         | 
| @@ -461,7 +575,7 @@ include::fixtures/parent-include.adoc[] | |
| 461 575 |  | 
| 462 576 | 
             
                    reader.skip_blank_lines
         | 
| 463 577 |  | 
| 464 | 
            -
                    assert_equal  | 
| 578 | 
            +
                    assert_equal 'first line of grandchild', reader.read_line
         | 
| 465 579 |  | 
| 466 580 | 
             
                    assert_equal 'fixtures/grandchild-include.adoc: line 1', reader.prev_line_info
         | 
| 467 581 | 
             
                    assert_equal grandchild_include_docfile, reader.file
         | 
| @@ -470,15 +584,15 @@ include::fixtures/parent-include.adoc[] | |
| 470 584 |  | 
| 471 585 | 
             
                    reader.skip_blank_lines
         | 
| 472 586 |  | 
| 473 | 
            -
                    assert_equal  | 
| 587 | 
            +
                    assert_equal 'last line of grandchild', reader.read_line
         | 
| 474 588 |  | 
| 475 589 | 
             
                    reader.skip_blank_lines
         | 
| 476 590 |  | 
| 477 | 
            -
                    assert_equal  | 
| 591 | 
            +
                    assert_equal 'last line of child', reader.read_line
         | 
| 478 592 |  | 
| 479 593 | 
             
                    reader.skip_blank_lines
         | 
| 480 594 |  | 
| 481 | 
            -
                    assert_equal  | 
| 595 | 
            +
                    assert_equal 'last line of parent', reader.read_line
         | 
| 482 596 |  | 
| 483 597 | 
             
                    assert_equal 'fixtures/parent-include.adoc: line 5', reader.prev_line_info
         | 
| 484 598 | 
             
                    assert_equal parent_include_docfile, reader.file
         | 
| @@ -486,92 +600,103 @@ include::fixtures/parent-include.adoc[] | |
| 486 600 | 
             
                    assert_equal 'fixtures/parent-include.adoc', reader.path
         | 
| 487 601 | 
             
                  end
         | 
| 488 602 |  | 
| 489 | 
            -
                  test 'missing file referenced by include  | 
| 603 | 
            +
                  test 'missing file referenced by include directive does not crash processor' do
         | 
| 490 604 | 
             
                    input = <<-EOS
         | 
| 491 | 
            -
            include::fixtures/no-such-file. | 
| 605 | 
            +
            include::fixtures/no-such-file.adoc[]
         | 
| 492 606 | 
             
                    EOS
         | 
| 493 607 |  | 
| 494 608 | 
             
                    begin
         | 
| 495 609 | 
             
                      doc = document_from_string input, :safe => :safe, :base_dir => DIRNAME
         | 
| 496 | 
            -
                      assert_equal  | 
| 610 | 
            +
                      assert_equal 1, doc.blocks.size
         | 
| 611 | 
            +
                      assert_equal ['Unresolved directive in <stdin> - include::fixtures/no-such-file.adoc[]'], doc.blocks[0].lines
         | 
| 497 612 | 
             
                    rescue
         | 
| 498 | 
            -
                      flunk 'include  | 
| 613 | 
            +
                      flunk 'include directive should not raise exception on missing file'
         | 
| 499 614 | 
             
                    end
         | 
| 500 615 | 
             
                  end
         | 
| 501 616 |  | 
| 502 | 
            -
                  test 'include  | 
| 617 | 
            +
                  test 'include directive can retrieve data from uri' do
         | 
| 618 | 
            +
                    #url = 'http://echo.jsontest.com/name/asciidoctor'
         | 
| 619 | 
            +
                    url = %(http://#{resolve_localhost}:9876/name/asciidoctor)
         | 
| 503 620 | 
             
                    input = <<-EOS
         | 
| 504 621 | 
             
            ....
         | 
| 505 | 
            -
            include | 
| 622 | 
            +
            include::#{url}[]
         | 
| 506 623 | 
             
            ....
         | 
| 507 624 | 
             
                    EOS
         | 
| 508 | 
            -
             | 
| 509 | 
            -
                    output =  | 
| 510 | 
            -
             | 
| 625 | 
            +
                    expect = /\{"name": "asciidoctor"\}/
         | 
| 626 | 
            +
                    output = using_test_webserver do
         | 
| 627 | 
            +
                      render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
         | 
| 628 | 
            +
                    end
         | 
| 629 | 
            +
             | 
| 630 | 
            +
                    refute_nil output
         | 
| 631 | 
            +
                    assert_match(expect, output)
         | 
| 511 632 | 
             
                  end
         | 
| 512 633 |  | 
| 513 | 
            -
                  test 'inaccessible uri referenced by include  | 
| 634 | 
            +
                  test 'inaccessible uri referenced by include directive does not crash processor' do
         | 
| 635 | 
            +
                    url = %(http://#{resolve_localhost}:9876/no_such_file)
         | 
| 514 636 | 
             
                    input = <<-EOS
         | 
| 515 637 | 
             
            ....
         | 
| 516 | 
            -
            include | 
| 638 | 
            +
            include::#{url}[]
         | 
| 517 639 | 
             
            ....
         | 
| 518 640 | 
             
                    EOS
         | 
| 519 | 
            -
             | 
| 520 | 
            -
                    begin
         | 
| 521 | 
            -
                       | 
| 522 | 
            -
             | 
| 641 | 
            +
             | 
| 642 | 
            +
                    output = begin
         | 
| 643 | 
            +
                      using_test_webserver do
         | 
| 644 | 
            +
                        render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
         | 
| 645 | 
            +
                      end
         | 
| 523 646 | 
             
                    rescue
         | 
| 524 | 
            -
                      flunk 'include  | 
| 647 | 
            +
                      flunk 'include directive should not raise exception on inaccessible uri'
         | 
| 525 648 | 
             
                    end
         | 
| 649 | 
            +
                    refute_nil output
         | 
| 650 | 
            +
                    assert_match(/Unresolved directive/, output)
         | 
| 526 651 | 
             
                  end
         | 
| 527 652 |  | 
| 528 | 
            -
                  test 'include  | 
| 653 | 
            +
                  test 'include directive supports line selection' do
         | 
| 529 654 | 
             
                    input = <<-EOS
         | 
| 530 655 | 
             
            include::fixtures/include-file.asciidoc[lines=1;3..4;6..-1]
         | 
| 531 656 | 
             
                    EOS
         | 
| 532 657 |  | 
| 533 658 | 
             
                    output = render_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 534 659 | 
             
                    assert_match(/first line/, output)
         | 
| 535 | 
            -
                     | 
| 660 | 
            +
                    refute_match(/second line/, output)
         | 
| 536 661 | 
             
                    assert_match(/third line/, output)
         | 
| 537 662 | 
             
                    assert_match(/fourth line/, output)
         | 
| 538 | 
            -
                     | 
| 663 | 
            +
                    refute_match(/fifth line/, output)
         | 
| 539 664 | 
             
                    assert_match(/sixth line/, output)
         | 
| 540 665 | 
             
                    assert_match(/seventh line/, output)
         | 
| 541 666 | 
             
                    assert_match(/eighth line/, output)
         | 
| 542 667 | 
             
                    assert_match(/last line of included content/, output)
         | 
| 543 668 | 
             
                  end
         | 
| 544 669 |  | 
| 545 | 
            -
                  test 'include  | 
| 670 | 
            +
                  test 'include directive supports line selection using quoted attribute value' do
         | 
| 546 671 | 
             
                    input = <<-EOS
         | 
| 547 672 | 
             
            include::fixtures/include-file.asciidoc[lines="1, 3..4 , 6 .. -1"]
         | 
| 548 673 | 
             
                    EOS
         | 
| 549 674 |  | 
| 550 675 | 
             
                    output = render_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 551 676 | 
             
                    assert_match(/first line/, output)
         | 
| 552 | 
            -
                     | 
| 677 | 
            +
                    refute_match(/second line/, output)
         | 
| 553 678 | 
             
                    assert_match(/third line/, output)
         | 
| 554 679 | 
             
                    assert_match(/fourth line/, output)
         | 
| 555 | 
            -
                     | 
| 680 | 
            +
                    refute_match(/fifth line/, output)
         | 
| 556 681 | 
             
                    assert_match(/sixth line/, output)
         | 
| 557 682 | 
             
                    assert_match(/seventh line/, output)
         | 
| 558 683 | 
             
                    assert_match(/eighth line/, output)
         | 
| 559 684 | 
             
                    assert_match(/last line of included content/, output)
         | 
| 560 685 | 
             
                  end
         | 
| 561 686 |  | 
| 562 | 
            -
                  test 'include  | 
| 687 | 
            +
                  test 'include directive supports tagged selection' do
         | 
| 563 688 | 
             
                    input = <<-EOS
         | 
| 564 689 | 
             
            include::fixtures/include-file.asciidoc[tag=snippetA]
         | 
| 565 690 | 
             
                    EOS
         | 
| 566 691 |  | 
| 567 692 | 
             
                    output = render_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 568 693 | 
             
                    assert_match(/snippetA content/, output)
         | 
| 569 | 
            -
                     | 
| 570 | 
            -
                     | 
| 571 | 
            -
                     | 
| 694 | 
            +
                    refute_match(/snippetB content/, output)
         | 
| 695 | 
            +
                    refute_match(/non-tagged content/, output)
         | 
| 696 | 
            +
                    refute_match(/included content/, output)
         | 
| 572 697 | 
             
                  end
         | 
| 573 698 |  | 
| 574 | 
            -
                  test 'include  | 
| 699 | 
            +
                  test 'include directive supports multiple tagged selection' do
         | 
| 575 700 | 
             
                    input = <<-EOS
         | 
| 576 701 | 
             
            include::fixtures/include-file.asciidoc[tags=snippetA;snippetB]
         | 
| 577 702 | 
             
                    EOS
         | 
| @@ -579,19 +704,52 @@ include::fixtures/include-file.asciidoc[tags=snippetA;snippetB] | |
| 579 704 | 
             
                    output = render_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 580 705 | 
             
                    assert_match(/snippetA content/, output)
         | 
| 581 706 | 
             
                    assert_match(/snippetB content/, output)
         | 
| 582 | 
            -
                     | 
| 583 | 
            -
                     | 
| 707 | 
            +
                    refute_match(/non-tagged content/, output)
         | 
| 708 | 
            +
                    refute_match(/included content/, output)
         | 
| 709 | 
            +
                  end
         | 
| 710 | 
            +
             | 
| 711 | 
            +
                  test 'include directive does not select tagged lines inside tagged selection' do
         | 
| 712 | 
            +
                    input = <<-EOS
         | 
| 713 | 
            +
            ++++
         | 
| 714 | 
            +
            include::fixtures/include-file.asciidoc[tags=snippet]
         | 
| 715 | 
            +
            ++++
         | 
| 716 | 
            +
                    EOS
         | 
| 717 | 
            +
             | 
| 718 | 
            +
                    output = render_embedded_string input, :safe => :safe, :base_dir => DIRNAME
         | 
| 719 | 
            +
                    expect = %(snippetA content
         | 
| 720 | 
            +
             | 
| 721 | 
            +
            non-tagged content
         | 
| 722 | 
            +
             | 
| 723 | 
            +
            snippetB content)
         | 
| 724 | 
            +
                    assert_equal expect, output
         | 
| 725 | 
            +
                  end
         | 
| 726 | 
            +
             | 
| 727 | 
            +
                  test 'should warn if tag is not found in include file' do
         | 
| 728 | 
            +
                    input = <<-EOS
         | 
| 729 | 
            +
            include::fixtures/include-file.asciidoc[tag=snippetZ]
         | 
| 730 | 
            +
                    EOS
         | 
| 731 | 
            +
              
         | 
| 732 | 
            +
                    old_stderr = $stderr
         | 
| 733 | 
            +
                    $stderr = StringIO.new
         | 
| 734 | 
            +
                    begin
         | 
| 735 | 
            +
                      render_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 736 | 
            +
                      warning = $stderr.tap(&:rewind).read
         | 
| 737 | 
            +
                      refute_nil warning
         | 
| 738 | 
            +
                      assert_match(/WARNING.*snippetZ/, warning)
         | 
| 739 | 
            +
                    ensure
         | 
| 740 | 
            +
                      $stderr = old_stderr
         | 
| 741 | 
            +
                    end
         | 
| 584 742 | 
             
                  end
         | 
| 585 743 |  | 
| 586 | 
            -
                  test 'lines attribute takes precedence over tags attribute in include  | 
| 744 | 
            +
                  test 'lines attribute takes precedence over tags attribute in include directive' do
         | 
| 587 745 | 
             
                    input = <<-EOS
         | 
| 588 746 | 
             
            include::fixtures/include-file.asciidoc[lines=1, tags=snippetA;snippetB]
         | 
| 589 747 | 
             
                    EOS
         | 
| 590 748 |  | 
| 591 749 | 
             
                    output = render_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 592 750 | 
             
                    assert_match(/first line of included content/, output)
         | 
| 593 | 
            -
                     | 
| 594 | 
            -
                     | 
| 751 | 
            +
                    refute_match(/snippetA content/, output)
         | 
| 752 | 
            +
                    refute_match(/snippetB content/, output)
         | 
| 595 753 | 
             
                  end
         | 
| 596 754 |  | 
| 597 755 | 
             
                  test 'indent of included file can be reset to size of indent attribute' do
         | 
| @@ -604,51 +762,10 @@ include::fixtures/basic-docinfo.xml[lines=2..3, indent=0] | |
| 604 762 |  | 
| 605 763 | 
             
                    output = render_string input, :safe => :safe, :header_footer => false, :base_dir => DIRNAME
         | 
| 606 764 | 
             
                    result = xmlnodes_at_xpath('//pre', output, 1).text
         | 
| 607 | 
            -
                    assert_equal "<year>2013</year>\n<holder>Acme | 
| 765 | 
            +
                    assert_equal "<year>2013</year>\n<holder>Acme™, Inc.</holder>", result
         | 
| 608 766 | 
             
                  end
         | 
| 609 | 
            -
              
         | 
| 610 | 
            -
                  test 'include processor is called to process include directive' do
         | 
| 611 | 
            -
                    input = <<-EOS
         | 
| 612 | 
            -
            first line
         | 
| 613 767 |  | 
| 614 | 
            -
            include | 
| 615 | 
            -
             | 
| 616 | 
            -
            last line
         | 
| 617 | 
            -
                    EOS
         | 
| 618 | 
            -
             | 
| 619 | 
            -
                    include_processor = Class.new {
         | 
| 620 | 
            -
                      def initialize document
         | 
| 621 | 
            -
                      end
         | 
| 622 | 
            -
             | 
| 623 | 
            -
                      def handles? target
         | 
| 624 | 
            -
                        true
         | 
| 625 | 
            -
                      end
         | 
| 626 | 
            -
             | 
| 627 | 
            -
                      def process reader, target, attributes
         | 
| 628 | 
            -
                        content = ["include target:: #{target}\n", "\n", "middle line\n"]
         | 
| 629 | 
            -
                        reader.push_include content, target, target, 1, attributes
         | 
| 630 | 
            -
                      end
         | 
| 631 | 
            -
                    }
         | 
| 632 | 
            -
             | 
| 633 | 
            -
                    # Safe Mode is not required
         | 
| 634 | 
            -
                    document = empty_document :base_dir => DIRNAME
         | 
| 635 | 
            -
                    reader = Asciidoctor::PreprocessorReader.new document, input
         | 
| 636 | 
            -
                    reader.instance_variable_set '@include_processors', [include_processor.new(document)]
         | 
| 637 | 
            -
                    lines = []
         | 
| 638 | 
            -
                    lines << reader.read_line
         | 
| 639 | 
            -
                    lines << reader.read_line
         | 
| 640 | 
            -
                    lines << reader.read_line
         | 
| 641 | 
            -
                    assert_equal "include target:: include-file.asciidoc\n", lines.last
         | 
| 642 | 
            -
                    assert_equal 'include-file.asciidoc: line 2', reader.line_info
         | 
| 643 | 
            -
                    while reader.has_more_lines?
         | 
| 644 | 
            -
                      lines << reader.read_line
         | 
| 645 | 
            -
                    end
         | 
| 646 | 
            -
                    source = lines.join
         | 
| 647 | 
            -
                    assert_match(/^include target:: include-file.asciidoc$/, source)
         | 
| 648 | 
            -
                    assert_match(/^middle line$/, source)
         | 
| 649 | 
            -
                  end
         | 
| 650 | 
            -
             | 
| 651 | 
            -
                  test 'should fall back to built-in include macro behavior when not handled by include processor' do
         | 
| 768 | 
            +
                  test 'should fall back to built-in include directive behavior when not handled by include processor' do
         | 
| 652 769 | 
             
                    input = <<-EOS
         | 
| 653 770 | 
             
            include::fixtures/include-file.asciidoc[]
         | 
| 654 771 | 
             
                    EOS
         | 
| @@ -670,11 +787,34 @@ include::fixtures/include-file.asciidoc[] | |
| 670 787 | 
             
                    reader = Asciidoctor::PreprocessorReader.new document, input
         | 
| 671 788 | 
             
                    reader.instance_variable_set '@include_processors', [include_processor.new(document)]
         | 
| 672 789 | 
             
                    lines = reader.read_lines
         | 
| 673 | 
            -
                    source = lines | 
| 790 | 
            +
                    source = lines * ::Asciidoctor::EOL
         | 
| 674 791 | 
             
                    assert_match(/included content/, source)
         | 
| 675 792 | 
             
                  end
         | 
| 793 | 
            +
             | 
| 794 | 
            +
                  test 'leveloffset attribute entries should be added to content if leveloffset attribute is specified' do
         | 
| 795 | 
            +
                    input = <<-EOS
         | 
| 796 | 
            +
            include::fixtures/master.adoc[]
         | 
| 797 | 
            +
                    EOS
         | 
| 798 | 
            +
             | 
| 799 | 
            +
                    expected = <<-EOS.chomp.split(::Asciidoctor::EOL)
         | 
| 800 | 
            +
            = Master Document
         | 
| 801 | 
            +
             | 
| 802 | 
            +
            preamble
         | 
| 803 | 
            +
             | 
| 804 | 
            +
            :leveloffset: +1
         | 
| 805 | 
            +
             | 
| 806 | 
            +
            = Chapter A
         | 
| 807 | 
            +
             | 
| 808 | 
            +
            content
         | 
| 809 | 
            +
             | 
| 810 | 
            +
            :leveloffset!:
         | 
| 811 | 
            +
                    EOS
         | 
| 812 | 
            +
             | 
| 813 | 
            +
                    document = Asciidoctor.load input, :safe => :safe, :base_dir => DIRNAME, :parse => false
         | 
| 814 | 
            +
                    assert_equal expected, document.reader.read_lines
         | 
| 815 | 
            +
                  end
         | 
| 676 816 |  | 
| 677 | 
            -
                  test 'attributes are substituted in target of include  | 
| 817 | 
            +
                  test 'attributes are substituted in target of include directive' do
         | 
| 678 818 | 
             
                    input = <<-EOS
         | 
| 679 819 | 
             
            :fixturesdir: fixtures
         | 
| 680 820 | 
             
            :ext: asciidoc
         | 
| @@ -687,17 +827,17 @@ include::{fixturesdir}/include-file.{ext}[] | |
| 687 827 | 
             
                    assert_match(/included content/, output)
         | 
| 688 828 | 
             
                  end
         | 
| 689 829 |  | 
| 690 | 
            -
                  test 'line is skipped by default if target of include  | 
| 830 | 
            +
                  test 'line is skipped by default if target of include directive resolves to empty' do
         | 
| 691 831 | 
             
                    input = <<-EOS
         | 
| 692 832 | 
             
            include::{foodir}/include-file.asciidoc[]
         | 
| 693 833 | 
             
                    EOS
         | 
| 694 834 |  | 
| 695 835 | 
             
                    doc = empty_safe_document :base_dir => DIRNAME
         | 
| 696 836 | 
             
                    reader = Asciidoctor::PreprocessorReader.new doc, input
         | 
| 697 | 
            -
                    assert_equal  | 
| 837 | 
            +
                    assert_equal 'Unresolved directive in <stdin> - include::{foodir}/include-file.asciidoc[]', reader.read_line
         | 
| 698 838 | 
             
                  end
         | 
| 699 839 |  | 
| 700 | 
            -
                  test 'line is dropped if target of include  | 
| 840 | 
            +
                  test 'line is dropped if target of include directive resolves to empty and attribute-missing attribute is not skip' do
         | 
| 701 841 | 
             
                    input = <<-EOS
         | 
| 702 842 | 
             
            include::{foodir}/include-file.asciidoc[]
         | 
| 703 843 | 
             
                    EOS
         | 
| @@ -715,10 +855,10 @@ yo | |
| 715 855 |  | 
| 716 856 | 
             
                    doc = empty_safe_document :base_dir => DIRNAME, :attributes => {'attribute-missing' => 'drop'}
         | 
| 717 857 | 
             
                    reader = Asciidoctor::PreprocessorReader.new doc, input
         | 
| 718 | 
            -
                    assert_equal  | 
| 858 | 
            +
                    assert_equal 'yo', reader.read_line
         | 
| 719 859 | 
             
                  end
         | 
| 720 860 |  | 
| 721 | 
            -
                  test 'escaped include  | 
| 861 | 
            +
                  test 'escaped include directive is left unprocessed' do
         | 
| 722 862 | 
             
                    input = <<-EOS
         | 
| 723 863 | 
             
            \\include::fixtures/include-file.asciidoc[]
         | 
| 724 864 | 
             
            \\escape preserved here
         | 
| @@ -727,13 +867,13 @@ yo | |
| 727 867 | 
             
                    reader = Asciidoctor::PreprocessorReader.new doc, input
         | 
| 728 868 | 
             
                    # we should be able to peek it multiple times and still have the backslash preserved
         | 
| 729 869 | 
             
                    # this is the test for @unescape_next_line
         | 
| 730 | 
            -
                    assert_equal 'include::fixtures/include-file.asciidoc[]', reader.peek_line | 
| 731 | 
            -
                    assert_equal 'include::fixtures/include-file.asciidoc[]', reader.peek_line | 
| 732 | 
            -
                    assert_equal 'include::fixtures/include-file.asciidoc[]', reader.read_line | 
| 733 | 
            -
                    assert_equal '\\escape preserved here', reader.read_line | 
| 870 | 
            +
                    assert_equal 'include::fixtures/include-file.asciidoc[]', reader.peek_line
         | 
| 871 | 
            +
                    assert_equal 'include::fixtures/include-file.asciidoc[]', reader.peek_line
         | 
| 872 | 
            +
                    assert_equal 'include::fixtures/include-file.asciidoc[]', reader.read_line
         | 
| 873 | 
            +
                    assert_equal '\\escape preserved here', reader.read_line
         | 
| 734 874 | 
             
                  end
         | 
| 735 875 |  | 
| 736 | 
            -
                  test 'include  | 
| 876 | 
            +
                  test 'include directive not at start of line is ignored' do
         | 
| 737 877 | 
             
                    input = <<-EOS
         | 
| 738 878 | 
             
             include::include-file.asciidoc[]
         | 
| 739 879 | 
             
                    EOS
         | 
| @@ -744,7 +884,7 @@ yo | |
| 744 884 | 
             
                    assert_equal 'include::include-file.asciidoc[]', para.source
         | 
| 745 885 | 
             
                  end
         | 
| 746 886 |  | 
| 747 | 
            -
                  test 'include  | 
| 887 | 
            +
                  test 'include directive is disabled when max-include-depth attribute is 0' do
         | 
| 748 888 | 
             
                    input = <<-EOS
         | 
| 749 889 | 
             
            include::include-file.asciidoc[]
         | 
| 750 890 | 
             
                    EOS
         | 
| @@ -764,7 +904,7 @@ include::include-file.asciidoc[] | |
| 764 904 | 
             
                    assert_equal 'include::include-file.asciidoc[]', para.source
         | 
| 765 905 | 
             
                  end
         | 
| 766 906 |  | 
| 767 | 
            -
                  test 'include  | 
| 907 | 
            +
                  test 'include directive should be disabled if max include depth has been exceeded' do
         | 
| 768 908 | 
             
                    input = <<-EOS
         | 
| 769 909 | 
             
            include::fixtures/parent-include.adoc[depth=1]
         | 
| 770 910 | 
             
                    EOS
         | 
| @@ -775,10 +915,10 @@ include::fixtures/parent-include.adoc[depth=1] | |
| 775 915 | 
             
                    reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile)
         | 
| 776 916 |  | 
| 777 917 | 
             
                    lines = reader.readlines
         | 
| 778 | 
            -
                    assert lines.include?( | 
| 918 | 
            +
                    assert lines.include?('include::child-include.adoc[]')
         | 
| 779 919 | 
             
                  end
         | 
| 780 920 |  | 
| 781 | 
            -
                  test 'include  | 
| 921 | 
            +
                  test 'include directive should be disabled if max include depth set in nested context has been exceeded' do
         | 
| 782 922 | 
             
                    input = <<-EOS
         | 
| 783 923 | 
             
            include::fixtures/parent-include-restricted.adoc[depth=3]
         | 
| 784 924 | 
             
                    EOS
         | 
| @@ -789,14 +929,14 @@ include::fixtures/parent-include-restricted.adoc[depth=3] | |
| 789 929 | 
             
                    reader = Asciidoctor::PreprocessorReader.new doc, input, Asciidoctor::Reader::Cursor.new(pseudo_docfile)
         | 
| 790 930 |  | 
| 791 931 | 
             
                    lines = reader.readlines
         | 
| 792 | 
            -
                    assert lines.include?( | 
| 793 | 
            -
                    assert lines.include?( | 
| 932 | 
            +
                    assert lines.include?('first line of child')
         | 
| 933 | 
            +
                    assert lines.include?('include::grandchild-include.adoc[]')
         | 
| 794 934 | 
             
                  end
         | 
| 795 935 |  | 
| 796 936 | 
             
                  test 'read_lines_until should not process lines if process option is false' do
         | 
| 797 937 | 
             
                    lines = <<-EOS.each_line.to_a
         | 
| 798 938 | 
             
            ////
         | 
| 799 | 
            -
            include::fixtures/no-such-file. | 
| 939 | 
            +
            include::fixtures/no-such-file.adoc[]
         | 
| 800 940 | 
             
            ////
         | 
| 801 941 | 
             
                    EOS
         | 
| 802 942 |  | 
| @@ -804,25 +944,24 @@ include::fixtures/no-such-file.asciidoc[] | |
| 804 944 | 
             
                    reader = Asciidoctor::PreprocessorReader.new doc, lines
         | 
| 805 945 | 
             
                    reader.read_line
         | 
| 806 946 | 
             
                    result = reader.read_lines_until(:terminator => '////', :skip_processing => true)
         | 
| 807 | 
            -
                    assert_equal lines[1..1], result
         | 
| 947 | 
            +
                    assert_equal lines.map {|l| l.chomp}[1..1], result
         | 
| 808 948 | 
             
                  end
         | 
| 809 949 |  | 
| 810 950 | 
             
                  test 'skip_comment_lines should not process lines read' do
         | 
| 811 951 | 
             
                    lines = <<-EOS.each_line.to_a
         | 
| 812 952 | 
             
            ////
         | 
| 813 | 
            -
            include::fixtures/no-such-file. | 
| 953 | 
            +
            include::fixtures/no-such-file.adoc[]
         | 
| 814 954 | 
             
            ////
         | 
| 815 955 | 
             
                    EOS
         | 
| 816 956 |  | 
| 817 957 | 
             
                    doc = empty_safe_document :base_dir => DIRNAME
         | 
| 818 958 | 
             
                    reader = Asciidoctor::PreprocessorReader.new doc, lines
         | 
| 819 959 | 
             
                    result = reader.skip_comment_lines
         | 
| 820 | 
            -
                    assert_equal lines, result
         | 
| 960 | 
            +
                    assert_equal lines.map {|l| l.chomp}, result
         | 
| 821 961 | 
             
                  end
         | 
| 822 962 | 
             
                end
         | 
| 823 963 |  | 
| 824 964 | 
             
                context 'Conditional Inclusions' do
         | 
| 825 | 
            -
                  #test 'process_line returns next line of content' do
         | 
| 826 965 | 
             
                  test 'process_line returns nil if cursor advanced' do
         | 
| 827 966 | 
             
                    input = <<-EOS
         | 
| 828 967 | 
             
            ifdef::asciidoctor[]
         | 
| @@ -830,8 +969,8 @@ Asciidoctor! | |
| 830 969 | 
             
            endif::asciidoctor[]
         | 
| 831 970 | 
             
                    EOS
         | 
| 832 971 |  | 
| 833 | 
            -
                     | 
| 834 | 
            -
                     | 
| 972 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 973 | 
            +
                    reader = doc.reader
         | 
| 835 974 | 
             
                    assert_nil reader.process_line(reader.lines.first)
         | 
| 836 975 | 
             
                  end
         | 
| 837 976 |  | 
| @@ -842,9 +981,10 @@ Asciidoctor! | |
| 842 981 | 
             
            endif::asciidoctor[]
         | 
| 843 982 | 
             
                    EOS
         | 
| 844 983 |  | 
| 845 | 
            -
                     | 
| 984 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 985 | 
            +
                    reader = doc.reader
         | 
| 846 986 | 
             
                    assert_equal 1, reader.lineno
         | 
| 847 | 
            -
                    assert_equal  | 
| 987 | 
            +
                    assert_equal 'Asciidoctor!', reader.peek_line
         | 
| 848 988 | 
             
                    assert_equal 2, reader.lineno
         | 
| 849 989 | 
             
                  end
         | 
| 850 990 |  | 
| @@ -856,8 +996,9 @@ Asciidoctor! | |
| 856 996 | 
             
            endif::asciidoctor[]
         | 
| 857 997 | 
             
                    EOS
         | 
| 858 998 |  | 
| 859 | 
            -
                     | 
| 860 | 
            -
                     | 
| 999 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1000 | 
            +
                    reader = doc.reader
         | 
| 1001 | 
            +
                    refute_nil reader.process_line(reader.lines.first)
         | 
| 861 1002 | 
             
                  end
         | 
| 862 1003 |  | 
| 863 1004 | 
             
                  test 'peek_line does not advance cursor when on a regular content line' do
         | 
| @@ -868,9 +1009,10 @@ Asciidoctor! | |
| 868 1009 | 
             
            endif::asciidoctor[]
         | 
| 869 1010 | 
             
                    EOS
         | 
| 870 1011 |  | 
| 871 | 
            -
                     | 
| 1012 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1013 | 
            +
                    reader = doc.reader
         | 
| 872 1014 | 
             
                    assert_equal 1, reader.lineno
         | 
| 873 | 
            -
                    assert_equal  | 
| 1015 | 
            +
                    assert_equal 'content', reader.peek_line
         | 
| 874 1016 | 
             
                    assert_equal 1, reader.lineno
         | 
| 875 1017 | 
             
                  end
         | 
| 876 1018 |  | 
| @@ -881,7 +1023,8 @@ swallowed content | |
| 881 1023 | 
             
            endif::foobar[]
         | 
| 882 1024 | 
             
                    EOS
         | 
| 883 1025 |  | 
| 884 | 
            -
                     | 
| 1026 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1027 | 
            +
                    reader = doc.reader
         | 
| 885 1028 | 
             
                    assert_equal 1, reader.lineno
         | 
| 886 1029 | 
             
                    assert_nil reader.peek_line
         | 
| 887 1030 | 
             
                    assert_equal 4, reader.lineno
         | 
| @@ -894,13 +1037,13 @@ There is a holy grail! | |
| 894 1037 | 
             
            endif::holygrail[]
         | 
| 895 1038 | 
             
                    EOS
         | 
| 896 1039 |  | 
| 897 | 
            -
                    doc =  | 
| 898 | 
            -
                    reader =  | 
| 1040 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' }
         | 
| 1041 | 
            +
                    reader = doc.reader
         | 
| 899 1042 | 
             
                    lines = []
         | 
| 900 1043 | 
             
                    while reader.has_more_lines?
         | 
| 901 1044 | 
             
                      lines << reader.read_line
         | 
| 902 1045 | 
             
                    end
         | 
| 903 | 
            -
                    assert_equal 'There is a holy grail!', lines | 
| 1046 | 
            +
                    assert_equal 'There is a holy grail!', (lines * ::Asciidoctor::EOL)
         | 
| 904 1047 | 
             
                  end
         | 
| 905 1048 |  | 
| 906 1049 | 
             
                  test 'ifdef with defined attribute includes text in brackets' do
         | 
| @@ -910,13 +1053,25 @@ ifdef::holygrail[There is a holy grail!] | |
| 910 1053 | 
             
            There was much rejoicing.
         | 
| 911 1054 | 
             
                    EOS
         | 
| 912 1055 |  | 
| 913 | 
            -
                    doc =  | 
| 914 | 
            -
                    reader =  | 
| 1056 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' }
         | 
| 1057 | 
            +
                    reader = doc.reader
         | 
| 915 1058 | 
             
                    lines = []
         | 
| 916 1059 | 
             
                    while reader.has_more_lines?
         | 
| 917 1060 | 
             
                      lines << reader.read_line
         | 
| 918 1061 | 
             
                    end
         | 
| 919 | 
            -
                    assert_equal "On our quest we go...\nThere is a holy grail!\nThere was much rejoicing.", lines | 
| 1062 | 
            +
                    assert_equal "On our quest we go...\nThere is a holy grail!\nThere was much rejoicing.", (lines * ::Asciidoctor::EOL)
         | 
| 1063 | 
            +
                  end
         | 
| 1064 | 
            +
             | 
| 1065 | 
            +
                  test 'ifdef attribute name is not case sensitive' do
         | 
| 1066 | 
            +
                    input = <<-EOS
         | 
| 1067 | 
            +
            ifdef::showScript[]
         | 
| 1068 | 
            +
            The script is shown!
         | 
| 1069 | 
            +
            endif::showScript[]
         | 
| 1070 | 
            +
                    EOS
         | 
| 1071 | 
            +
             | 
| 1072 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'showscript' => '' }
         | 
| 1073 | 
            +
                    result = doc.reader.read
         | 
| 1074 | 
            +
                    assert_equal 'The script is shown!', result
         | 
| 920 1075 | 
             
                  end
         | 
| 921 1076 |  | 
| 922 1077 | 
             
                  test 'ifndef with defined attribute does not include text in brackets' do
         | 
| @@ -926,13 +1081,13 @@ ifndef::hardships[There is a holy grail!] | |
| 926 1081 | 
             
            There was no rejoicing.
         | 
| 927 1082 | 
             
                    EOS
         | 
| 928 1083 |  | 
| 929 | 
            -
                    doc =  | 
| 930 | 
            -
                    reader =  | 
| 1084 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'hardships' => '' }
         | 
| 1085 | 
            +
                    reader = doc.reader
         | 
| 931 1086 | 
             
                    lines = []
         | 
| 932 1087 | 
             
                    while reader.has_more_lines?
         | 
| 933 1088 | 
             
                      lines << reader.read_line
         | 
| 934 1089 | 
             
                    end
         | 
| 935 | 
            -
                    assert_equal "On our quest we go...\nThere was no rejoicing.", lines | 
| 1090 | 
            +
                    assert_equal "On our quest we go...\nThere was no rejoicing.", (lines * ::Asciidoctor::EOL)
         | 
| 936 1091 | 
             
                  end
         | 
| 937 1092 |  | 
| 938 1093 | 
             
                  test 'include with non-matching nested exclude' do
         | 
| @@ -946,13 +1101,13 @@ grail | |
| 946 1101 | 
             
            endif::grail[]
         | 
| 947 1102 | 
             
                    EOS
         | 
| 948 1103 |  | 
| 949 | 
            -
                    doc =  | 
| 950 | 
            -
                    reader =  | 
| 1104 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
         | 
| 1105 | 
            +
                    reader = doc.reader
         | 
| 951 1106 | 
             
                    lines = []
         | 
| 952 1107 | 
             
                    while reader.has_more_lines?
         | 
| 953 1108 | 
             
                      lines << reader.read_line
         | 
| 954 1109 | 
             
                    end
         | 
| 955 | 
            -
                    assert_equal "holy\ngrail", lines | 
| 1110 | 
            +
                    assert_equal "holy\ngrail", (lines * ::Asciidoctor::EOL)
         | 
| 956 1111 | 
             
                  end
         | 
| 957 1112 |  | 
| 958 1113 | 
             
                  test 'nested excludes with same condition' do
         | 
| @@ -964,13 +1119,13 @@ endif::grail[] | |
| 964 1119 | 
             
            endif::grail[]
         | 
| 965 1120 | 
             
                    EOS
         | 
| 966 1121 |  | 
| 967 | 
            -
                    doc =  | 
| 968 | 
            -
                    reader =  | 
| 1122 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
         | 
| 1123 | 
            +
                    reader = doc.reader
         | 
| 969 1124 | 
             
                    lines = []
         | 
| 970 1125 | 
             
                    while reader.has_more_lines?
         | 
| 971 1126 | 
             
                      lines << reader.read_line
         | 
| 972 1127 | 
             
                    end
         | 
| 973 | 
            -
                    assert_equal '', lines | 
| 1128 | 
            +
                    assert_equal '', (lines * ::Asciidoctor::EOL)
         | 
| 974 1129 | 
             
                  end
         | 
| 975 1130 |  | 
| 976 1131 | 
             
                  test 'include with nested exclude of inverted condition' do
         | 
| @@ -984,13 +1139,13 @@ grail | |
| 984 1139 | 
             
            endif::grail[]
         | 
| 985 1140 | 
             
                    EOS
         | 
| 986 1141 |  | 
| 987 | 
            -
                    doc =  | 
| 988 | 
            -
                    reader =  | 
| 1142 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
         | 
| 1143 | 
            +
                    reader = doc.reader
         | 
| 989 1144 | 
             
                    lines = []
         | 
| 990 1145 | 
             
                    while reader.has_more_lines?
         | 
| 991 1146 | 
             
                      lines << reader.read_line
         | 
| 992 1147 | 
             
                    end
         | 
| 993 | 
            -
                    assert_equal "holy\ngrail", lines | 
| 1148 | 
            +
                    assert_equal "holy\ngrail", (lines * ::Asciidoctor::EOL)
         | 
| 994 1149 | 
             
                  end
         | 
| 995 1150 |  | 
| 996 1151 | 
             
                  test 'exclude with matching nested exclude' do
         | 
| @@ -1006,13 +1161,13 @@ endif::swallow[] | |
| 1006 1161 | 
             
            gone
         | 
| 1007 1162 | 
             
                    EOS
         | 
| 1008 1163 |  | 
| 1009 | 
            -
                    doc =  | 
| 1010 | 
            -
                    reader =  | 
| 1164 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
         | 
| 1165 | 
            +
                    reader = doc.reader
         | 
| 1011 1166 | 
             
                    lines = []
         | 
| 1012 1167 | 
             
                    while reader.has_more_lines?
         | 
| 1013 1168 | 
             
                      lines << reader.read_line
         | 
| 1014 1169 | 
             
                    end
         | 
| 1015 | 
            -
                    assert_equal "poof\ngone", lines | 
| 1170 | 
            +
                    assert_equal "poof\ngone", (lines * ::Asciidoctor::EOL)
         | 
| 1016 1171 | 
             
                  end
         | 
| 1017 1172 |  | 
| 1018 1173 | 
             
                  test 'exclude with nested include using shorthand end' do
         | 
| @@ -1028,13 +1183,13 @@ endif::[] | |
| 1028 1183 | 
             
            gone
         | 
| 1029 1184 | 
             
                    EOS
         | 
| 1030 1185 |  | 
| 1031 | 
            -
                    doc =  | 
| 1032 | 
            -
                    reader =  | 
| 1186 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'grail' => '' }
         | 
| 1187 | 
            +
                    reader = doc.reader
         | 
| 1033 1188 | 
             
                    lines = []
         | 
| 1034 1189 | 
             
                    while reader.has_more_lines?
         | 
| 1035 1190 | 
             
                      lines << reader.read_line
         | 
| 1036 1191 | 
             
                    end
         | 
| 1037 | 
            -
                    assert_equal "poof\ngone", lines | 
| 1192 | 
            +
                    assert_equal "poof\ngone", (lines * ::Asciidoctor::EOL)
         | 
| 1038 1193 | 
             
                  end
         | 
| 1039 1194 |  | 
| 1040 1195 | 
             
                  test 'ifdef with one alternative attribute set includes content' do
         | 
| @@ -1044,13 +1199,13 @@ Our quest is complete! | |
| 1044 1199 | 
             
            endif::holygrail,swallow[]
         | 
| 1045 1200 | 
             
                    EOS
         | 
| 1046 1201 |  | 
| 1047 | 
            -
                    doc =  | 
| 1048 | 
            -
                    reader =  | 
| 1202 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'swallow' => '' }
         | 
| 1203 | 
            +
                    reader = doc.reader
         | 
| 1049 1204 | 
             
                    lines = []
         | 
| 1050 1205 | 
             
                    while reader.has_more_lines?
         | 
| 1051 1206 | 
             
                      lines << reader.read_line
         | 
| 1052 1207 | 
             
                    end
         | 
| 1053 | 
            -
                    assert_equal 'Our quest is complete!', lines | 
| 1208 | 
            +
                    assert_equal 'Our quest is complete!', (lines * ::Asciidoctor::EOL)
         | 
| 1054 1209 | 
             
                  end
         | 
| 1055 1210 |  | 
| 1056 1211 | 
             
                  test 'ifdef with no alternative attributes set does not include content' do
         | 
| @@ -1060,13 +1215,13 @@ Our quest is complete! | |
| 1060 1215 | 
             
            endif::holygrail,swallow[]
         | 
| 1061 1216 | 
             
                    EOS
         | 
| 1062 1217 |  | 
| 1063 | 
            -
                    doc =  | 
| 1064 | 
            -
                    reader =  | 
| 1218 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1219 | 
            +
                    reader = doc.reader
         | 
| 1065 1220 | 
             
                    lines = []
         | 
| 1066 1221 | 
             
                    while reader.has_more_lines?
         | 
| 1067 1222 | 
             
                      lines << reader.read_line
         | 
| 1068 1223 | 
             
                    end
         | 
| 1069 | 
            -
                    assert_equal '', lines | 
| 1224 | 
            +
                    assert_equal '', (lines * ::Asciidoctor::EOL)
         | 
| 1070 1225 | 
             
                  end
         | 
| 1071 1226 |  | 
| 1072 1227 | 
             
                  test 'ifdef with all required attributes set includes content' do
         | 
| @@ -1076,13 +1231,13 @@ Our quest is complete! | |
| 1076 1231 | 
             
            endif::holygrail+swallow[]
         | 
| 1077 1232 | 
             
                    EOS
         | 
| 1078 1233 |  | 
| 1079 | 
            -
                    doc =  | 
| 1080 | 
            -
                    reader =  | 
| 1234 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '', 'swallow' => '' }
         | 
| 1235 | 
            +
                    reader = doc.reader
         | 
| 1081 1236 | 
             
                    lines = []
         | 
| 1082 1237 | 
             
                    while reader.has_more_lines?
         | 
| 1083 1238 | 
             
                      lines << reader.read_line
         | 
| 1084 1239 | 
             
                    end
         | 
| 1085 | 
            -
                    assert_equal 'Our quest is complete!', lines | 
| 1240 | 
            +
                    assert_equal 'Our quest is complete!', (lines * ::Asciidoctor::EOL)
         | 
| 1086 1241 | 
             
                  end
         | 
| 1087 1242 |  | 
| 1088 1243 | 
             
                  test 'ifdef with missing required attributes does not include content' do
         | 
| @@ -1092,13 +1247,13 @@ Our quest is complete! | |
| 1092 1247 | 
             
            endif::holygrail+swallow[]
         | 
| 1093 1248 | 
             
                    EOS
         | 
| 1094 1249 |  | 
| 1095 | 
            -
                    doc =  | 
| 1096 | 
            -
                    reader =  | 
| 1250 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'holygrail' => '' }
         | 
| 1251 | 
            +
                    reader = doc.reader
         | 
| 1097 1252 | 
             
                    lines = []
         | 
| 1098 1253 | 
             
                    while reader.has_more_lines?
         | 
| 1099 1254 | 
             
                      lines << reader.read_line
         | 
| 1100 1255 | 
             
                    end
         | 
| 1101 | 
            -
                    assert_equal '', lines | 
| 1256 | 
            +
                    assert_equal '', (lines * ::Asciidoctor::EOL)
         | 
| 1102 1257 | 
             
                  end
         | 
| 1103 1258 |  | 
| 1104 1259 | 
             
                  test 'ifndef with undefined attribute includes block' do
         | 
| @@ -1108,13 +1263,13 @@ Our quest continues to find the holy grail! | |
| 1108 1263 | 
             
            endif::holygrail[]
         | 
| 1109 1264 | 
             
                    EOS
         | 
| 1110 1265 |  | 
| 1111 | 
            -
                    doc =  | 
| 1112 | 
            -
                    reader =  | 
| 1266 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1267 | 
            +
                    reader = doc.reader
         | 
| 1113 1268 | 
             
                    lines = []
         | 
| 1114 1269 | 
             
                    while reader.has_more_lines?
         | 
| 1115 1270 | 
             
                      lines << reader.read_line
         | 
| 1116 1271 | 
             
                    end
         | 
| 1117 | 
            -
                    assert_equal 'Our quest continues to find the holy grail!', lines | 
| 1272 | 
            +
                    assert_equal 'Our quest continues to find the holy grail!', (lines * ::Asciidoctor::EOL)
         | 
| 1118 1273 | 
             
                  end
         | 
| 1119 1274 |  | 
| 1120 1275 | 
             
                  test 'ifndef with one alternative attribute set includes content' do
         | 
| @@ -1124,13 +1279,13 @@ Our quest is complete! | |
| 1124 1279 | 
             
            endif::holygrail,swallow[]
         | 
| 1125 1280 | 
             
                    EOS
         | 
| 1126 1281 |  | 
| 1127 | 
            -
                    doc =  | 
| 1128 | 
            -
                    reader =  | 
| 1282 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'swallow' => '' }
         | 
| 1283 | 
            +
                    reader = doc.reader
         | 
| 1129 1284 | 
             
                    lines = []
         | 
| 1130 1285 | 
             
                    while reader.has_more_lines?
         | 
| 1131 1286 | 
             
                      lines << reader.read_line
         | 
| 1132 1287 | 
             
                    end
         | 
| 1133 | 
            -
                    assert_equal 'Our quest is complete!', lines | 
| 1288 | 
            +
                    assert_equal 'Our quest is complete!', (lines * ::Asciidoctor::EOL)
         | 
| 1134 1289 | 
             
                  end
         | 
| 1135 1290 |  | 
| 1136 1291 | 
             
                  test 'ifndef with no alternative attributes set includes content' do
         | 
| @@ -1140,13 +1295,13 @@ Our quest is complete! | |
| 1140 1295 | 
             
            endif::holygrail,swallow[]
         | 
| 1141 1296 | 
             
                    EOS
         | 
| 1142 1297 |  | 
| 1143 | 
            -
                    doc =  | 
| 1144 | 
            -
                    reader =  | 
| 1298 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1299 | 
            +
                    reader = doc.reader
         | 
| 1145 1300 | 
             
                    lines = []
         | 
| 1146 1301 | 
             
                    while reader.has_more_lines?
         | 
| 1147 1302 | 
             
                      lines << reader.read_line
         | 
| 1148 1303 | 
             
                    end
         | 
| 1149 | 
            -
                    assert_equal 'Our quest is complete!', lines | 
| 1304 | 
            +
                    assert_equal 'Our quest is complete!', (lines * ::Asciidoctor::EOL)
         | 
| 1150 1305 | 
             
                  end
         | 
| 1151 1306 |  | 
| 1152 1307 | 
             
                  test 'ifndef with any required attributes set does not include content' do
         | 
| @@ -1156,13 +1311,13 @@ Our quest is complete! | |
| 1156 1311 | 
             
            endif::holygrail+swallow[]
         | 
| 1157 1312 | 
             
                    EOS
         | 
| 1158 1313 |  | 
| 1159 | 
            -
                    doc =  | 
| 1160 | 
            -
                    reader =  | 
| 1314 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'swallow' => '' }
         | 
| 1315 | 
            +
                    reader = doc.reader
         | 
| 1161 1316 | 
             
                    lines = []
         | 
| 1162 1317 | 
             
                    while reader.has_more_lines?
         | 
| 1163 1318 | 
             
                      lines << reader.read_line
         | 
| 1164 1319 | 
             
                    end
         | 
| 1165 | 
            -
                    assert_equal '', lines | 
| 1320 | 
            +
                    assert_equal '', (lines * ::Asciidoctor::EOL)
         | 
| 1166 1321 | 
             
                  end
         | 
| 1167 1322 |  | 
| 1168 1323 | 
             
                  test 'ifndef with no required attributes set includes content' do
         | 
| @@ -1172,13 +1327,13 @@ Our quest is complete! | |
| 1172 1327 | 
             
            endif::holygrail+swallow[]
         | 
| 1173 1328 | 
             
                    EOS
         | 
| 1174 1329 |  | 
| 1175 | 
            -
                    doc =  | 
| 1176 | 
            -
                    reader =  | 
| 1330 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1331 | 
            +
                    reader = doc.reader
         | 
| 1177 1332 | 
             
                    lines = []
         | 
| 1178 1333 | 
             
                    while reader.has_more_lines?
         | 
| 1179 1334 | 
             
                      lines << reader.read_line
         | 
| 1180 1335 | 
             
                    end
         | 
| 1181 | 
            -
                    assert_equal 'Our quest is complete!', lines | 
| 1336 | 
            +
                    assert_equal 'Our quest is complete!', (lines * ::Asciidoctor::EOL)
         | 
| 1182 1337 | 
             
                  end
         | 
| 1183 1338 |  | 
| 1184 1339 | 
             
                  test 'escaped ifdef is unescaped and ignored' do
         | 
| @@ -1188,13 +1343,13 @@ content | |
| 1188 1343 | 
             
            \\endif::holygrail[]
         | 
| 1189 1344 | 
             
                    EOS
         | 
| 1190 1345 |  | 
| 1191 | 
            -
                    doc =  | 
| 1192 | 
            -
                    reader =  | 
| 1346 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1347 | 
            +
                    reader = doc.reader
         | 
| 1193 1348 | 
             
                    lines = []
         | 
| 1194 1349 | 
             
                    while reader.has_more_lines?
         | 
| 1195 1350 | 
             
                      lines << reader.read_line
         | 
| 1196 1351 | 
             
                    end
         | 
| 1197 | 
            -
                    assert_equal "ifdef::holygrail[]\ncontent\nendif::holygrail[]", lines | 
| 1352 | 
            +
                    assert_equal "ifdef::holygrail[]\ncontent\nendif::holygrail[]", (lines * ::Asciidoctor::EOL)
         | 
| 1198 1353 | 
             
                  end
         | 
| 1199 1354 |  | 
| 1200 1355 | 
             
                  test 'ifeval comparing double-quoted attribute to matching string is included' do
         | 
| @@ -1204,13 +1359,13 @@ Asciidoctor it is! | |
| 1204 1359 | 
             
            endif::[]
         | 
| 1205 1360 | 
             
                    EOS
         | 
| 1206 1361 |  | 
| 1207 | 
            -
                    doc =  | 
| 1208 | 
            -
                    reader =  | 
| 1362 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'asciidoctor' }
         | 
| 1363 | 
            +
                    reader = doc.reader
         | 
| 1209 1364 | 
             
                    lines = []
         | 
| 1210 1365 | 
             
                    while reader.has_more_lines?
         | 
| 1211 1366 | 
             
                      lines << reader.read_line
         | 
| 1212 1367 | 
             
                    end
         | 
| 1213 | 
            -
                    assert_equal 'Asciidoctor it is!', lines | 
| 1368 | 
            +
                    assert_equal 'Asciidoctor it is!', (lines * ::Asciidoctor::EOL)
         | 
| 1214 1369 | 
             
                  end
         | 
| 1215 1370 |  | 
| 1216 1371 | 
             
                  test 'ifeval comparing single-quoted attribute to matching string is included' do
         | 
| @@ -1220,13 +1375,13 @@ Asciidoctor it is! | |
| 1220 1375 | 
             
            endif::[]
         | 
| 1221 1376 | 
             
                    EOS
         | 
| 1222 1377 |  | 
| 1223 | 
            -
                    doc =  | 
| 1224 | 
            -
                    reader =  | 
| 1378 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'asciidoctor' }
         | 
| 1379 | 
            +
                    reader = doc.reader
         | 
| 1225 1380 | 
             
                    lines = []
         | 
| 1226 1381 | 
             
                    while reader.has_more_lines?
         | 
| 1227 1382 | 
             
                      lines << reader.read_line
         | 
| 1228 1383 | 
             
                    end
         | 
| 1229 | 
            -
                    assert_equal 'Asciidoctor it is!', lines | 
| 1384 | 
            +
                    assert_equal 'Asciidoctor it is!', (lines * ::Asciidoctor::EOL)
         | 
| 1230 1385 | 
             
                  end
         | 
| 1231 1386 |  | 
| 1232 1387 | 
             
                  test 'ifeval comparing quoted attribute to non-matching string is ignored' do
         | 
| @@ -1236,13 +1391,13 @@ Asciidoctor it is! | |
| 1236 1391 | 
             
            endif::[]
         | 
| 1237 1392 | 
             
                    EOS
         | 
| 1238 1393 |  | 
| 1239 | 
            -
                    doc =  | 
| 1240 | 
            -
                    reader =  | 
| 1394 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'gem' => 'tilt' }
         | 
| 1395 | 
            +
                    reader = doc.reader
         | 
| 1241 1396 | 
             
                    lines = []
         | 
| 1242 1397 | 
             
                    while reader.has_more_lines?
         | 
| 1243 1398 | 
             
                      lines << reader.read_line
         | 
| 1244 1399 | 
             
                    end
         | 
| 1245 | 
            -
                    assert_equal '', lines | 
| 1400 | 
            +
                    assert_equal '', (lines * ::Asciidoctor::EOL)
         | 
| 1246 1401 | 
             
                  end
         | 
| 1247 1402 |  | 
| 1248 1403 | 
             
                  test 'ifeval comparing attribute to lower version number is included' do
         | 
| @@ -1252,13 +1407,13 @@ That version will do! | |
| 1252 1407 | 
             
            endif::[]
         | 
| 1253 1408 | 
             
                    EOS
         | 
| 1254 1409 |  | 
| 1255 | 
            -
                    doc =  | 
| 1256 | 
            -
                    reader =  | 
| 1410 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1411 | 
            +
                    reader = doc.reader
         | 
| 1257 1412 | 
             
                    lines = []
         | 
| 1258 1413 | 
             
                    while reader.has_more_lines?
         | 
| 1259 1414 | 
             
                      lines << reader.read_line
         | 
| 1260 1415 | 
             
                    end
         | 
| 1261 | 
            -
                    assert_equal 'That version will do!', lines | 
| 1416 | 
            +
                    assert_equal 'That version will do!', (lines * ::Asciidoctor::EOL)
         | 
| 1262 1417 | 
             
                  end
         | 
| 1263 1418 |  | 
| 1264 1419 | 
             
                  test 'ifeval comparing attribute to self is included' do
         | 
| @@ -1268,13 +1423,13 @@ Of course it's the same! | |
| 1268 1423 | 
             
            endif::[]
         | 
| 1269 1424 | 
             
                    EOS
         | 
| 1270 1425 |  | 
| 1271 | 
            -
                    doc =  | 
| 1272 | 
            -
                    reader =  | 
| 1426 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1427 | 
            +
                    reader = doc.reader
         | 
| 1273 1428 | 
             
                    lines = []
         | 
| 1274 1429 | 
             
                    while reader.has_more_lines?
         | 
| 1275 1430 | 
             
                      lines << reader.read_line
         | 
| 1276 1431 | 
             
                    end
         | 
| 1277 | 
            -
                    assert_equal 'Of course it\'s the same!', lines | 
| 1432 | 
            +
                    assert_equal 'Of course it\'s the same!', (lines * ::Asciidoctor::EOL)
         | 
| 1278 1433 | 
             
                  end
         | 
| 1279 1434 |  | 
| 1280 1435 | 
             
                  test 'ifeval arguments can be transposed' do
         | 
| @@ -1284,13 +1439,13 @@ That version will do! | |
| 1284 1439 | 
             
            endif::[]
         | 
| 1285 1440 | 
             
                    EOS
         | 
| 1286 1441 |  | 
| 1287 | 
            -
                    doc =  | 
| 1288 | 
            -
                    reader =  | 
| 1442 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1443 | 
            +
                    reader = doc.reader
         | 
| 1289 1444 | 
             
                    lines = []
         | 
| 1290 1445 | 
             
                    while reader.has_more_lines?
         | 
| 1291 1446 | 
             
                      lines << reader.read_line
         | 
| 1292 1447 | 
             
                    end
         | 
| 1293 | 
            -
                    assert_equal 'That version will do!', lines | 
| 1448 | 
            +
                    assert_equal 'That version will do!', (lines * ::Asciidoctor::EOL)
         | 
| 1294 1449 | 
             
                  end
         | 
| 1295 1450 |  | 
| 1296 1451 | 
             
                  test 'ifeval matching numeric comparison is included' do
         | 
| @@ -1300,13 +1455,13 @@ One ring to rule them all! | |
| 1300 1455 | 
             
            endif::[]
         | 
| 1301 1456 | 
             
                    EOS
         | 
| 1302 1457 |  | 
| 1303 | 
            -
                    doc =  | 
| 1304 | 
            -
                    reader =  | 
| 1458 | 
            +
                    doc = Asciidoctor::Document.new input, :attributes => { 'rings' => 1 }
         | 
| 1459 | 
            +
                    reader = doc.reader
         | 
| 1305 1460 | 
             
                    lines = []
         | 
| 1306 1461 | 
             
                    while reader.has_more_lines?
         | 
| 1307 1462 | 
             
                      lines << reader.read_line
         | 
| 1308 1463 | 
             
                    end
         | 
| 1309 | 
            -
                    assert_equal 'One ring to rule them all!', lines | 
| 1464 | 
            +
                    assert_equal 'One ring to rule them all!', (lines * ::Asciidoctor::EOL)
         | 
| 1310 1465 | 
             
                  end
         | 
| 1311 1466 |  | 
| 1312 1467 | 
             
                  test 'ifdef with no target is ignored' do
         | 
| @@ -1315,13 +1470,13 @@ ifdef::[] | |
| 1315 1470 | 
             
            content
         | 
| 1316 1471 | 
             
                    EOS
         | 
| 1317 1472 |  | 
| 1318 | 
            -
                    doc =  | 
| 1319 | 
            -
                    reader =  | 
| 1473 | 
            +
                    doc = Asciidoctor::Document.new input
         | 
| 1474 | 
            +
                    reader = doc.reader
         | 
| 1320 1475 | 
             
                    lines = []
         | 
| 1321 1476 | 
             
                    while reader.has_more_lines?
         | 
| 1322 1477 | 
             
                      lines << reader.read_line
         | 
| 1323 1478 | 
             
                    end
         | 
| 1324 | 
            -
                    assert_equal "ifdef::[]\ncontent", lines | 
| 1479 | 
            +
                    assert_equal "ifdef::[]\ncontent", (lines * ::Asciidoctor::EOL)
         | 
| 1325 1480 | 
             
                  end
         | 
| 1326 1481 | 
             
                end
         | 
| 1327 1482 | 
             
              end
         |