diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2014-07-04 02:16:03 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2014-07-04 17:07:28 -0600 |
| commit | 27067c4d05a072bb8b603ca81637fcff4897bc4f (patch) | |
| tree | bafc39b6a14f79b2f9d924871cadea5ee606f9df /test | |
| parent | 6da62e23c856ff00ab318ed9ed986d6de2349002 (diff) | |
resolves #530 support leveloffset on include directive and relative values
Diffstat (limited to 'test')
| -rw-r--r-- | test/fixtures/chapter-a.adoc | 3 | ||||
| -rw-r--r-- | test/fixtures/master.adoc | 5 | ||||
| -rw-r--r-- | test/reader_test.rb | 23 | ||||
| -rw-r--r-- | test/sections_test.rb | 25 |
4 files changed, 56 insertions, 0 deletions
diff --git a/test/fixtures/chapter-a.adoc b/test/fixtures/chapter-a.adoc new file mode 100644 index 00000000..a66a1bee --- /dev/null +++ b/test/fixtures/chapter-a.adoc @@ -0,0 +1,3 @@ += Chapter A + +content diff --git a/test/fixtures/master.adoc b/test/fixtures/master.adoc new file mode 100644 index 00000000..5793b145 --- /dev/null +++ b/test/fixtures/master.adoc @@ -0,0 +1,5 @@ += Master Document + +preamble + +include::chapter-a.adoc[leveloffset=+1] diff --git a/test/reader_test.rb b/test/reader_test.rb index 145f0a7b..77ba006b 100644 --- a/test/reader_test.rb +++ b/test/reader_test.rb @@ -774,6 +774,29 @@ include::fixtures/include-file.asciidoc[] source = lines * ::Asciidoctor::EOL assert_match(/included content/, source) end + + test 'leveloffset attribute entries should be added to content if leveloffset attribute is specified' do + input = <<-EOS +include::fixtures/master.adoc[] + EOS + + expected = <<-EOS.chomp.split(::Asciidoctor::EOL) += Master Document + +preamble + +:leveloffset: +1 + += Chapter A + +content + +:leveloffset!: + EOS + + document = Asciidoctor.load input, :safe => :safe, :base_dir => DIRNAME, :parse => false + assert_equal expected, document.reader.read_lines + end test 'attributes are substituted in target of include directive' do input = <<-EOS diff --git a/test/sections_test.rb b/test/sections_test.rb index 6f4adb7e..7df0bba9 100644 --- a/test/sections_test.rb +++ b/test/sections_test.rb @@ -667,6 +667,31 @@ Standalone preamble. assert_xpath '//*[@class = "sect1"]/h2[text() = "Standalone Document"]', output, 1 assert_xpath '//*[@class = "sect1"]/h2[text() = "Level 1 Section"]', output, 1 end + + test 'should add relative offset value to current leveloffset' do + input = <<-EOS += Master Document +Doc Writer + +Master preamble. + +:leveloffset: 1 + += Chapter 1 + +content + +:leveloffset: +1 + += Standalone Section + +content + EOS + + output = render_string input + assert_xpath '//*[@class = "sect1"]/h2[text() = "Chapter 1"]', output, 1 + assert_xpath '//*[@class = "sect2"]/h3[text() = "Standalone Section"]', output, 1 + end end context 'Section Numbering' do |
