asciidoctor 1.5.5 → 1.5.6
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 +216 -1
- data/CONTRIBUTING.adoc +2 -2
- data/Gemfile +20 -1
- data/LICENSE.adoc +1 -1
- data/README-fr.adoc +4 -3
- data/README-jp.adoc +11 -10
- data/README-zh_CN.adoc +4 -3
- data/README.adoc +17 -202
- data/Rakefile +41 -25
- data/asciidoctor.gemspec +9 -10
- data/data/locale/attributes.adoc +216 -34
- data/data/stylesheets/asciidoctor-default.css +23 -16
- data/features/step_definitions.rb +15 -19
- data/features/xref.feature +584 -20
- data/lib/asciidoctor.rb +292 -278
- data/lib/asciidoctor/abstract_block.rb +155 -94
- data/lib/asciidoctor/abstract_node.rb +108 -94
- data/lib/asciidoctor/attribute_list.rb +30 -22
- data/lib/asciidoctor/block.rb +7 -7
- data/lib/asciidoctor/cli/invoker.rb +47 -34
- data/lib/asciidoctor/cli/options.rb +22 -11
- data/lib/asciidoctor/converter.rb +3 -3
- data/lib/asciidoctor/converter/base.rb +2 -2
- data/lib/asciidoctor/converter/composite.rb +1 -1
- data/lib/asciidoctor/converter/docbook45.rb +2 -2
- data/lib/asciidoctor/converter/docbook5.rb +132 -87
- data/lib/asciidoctor/converter/factory.rb +0 -1
- data/lib/asciidoctor/converter/html5.rb +116 -98
- data/lib/asciidoctor/converter/manpage.rb +51 -52
- data/lib/asciidoctor/converter/template.rb +47 -36
- data/lib/asciidoctor/core_ext.rb +8 -2
- data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +4 -0
- data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +6 -0
- data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +5 -0
- data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +1 -1
- data/lib/asciidoctor/core_ext/1.8.7/string/{limit.rb → limit_bytesize.rb} +7 -6
- data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +6 -0
- data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +1 -1
- data/lib/asciidoctor/core_ext/nil_or_empty.rb +5 -5
- data/lib/asciidoctor/core_ext/regexp/is_match.rb +3 -0
- data/lib/asciidoctor/core_ext/string/{limit.rb → limit_bytesize.rb} +2 -2
- data/lib/asciidoctor/document.rb +216 -213
- data/lib/asciidoctor/extensions.rb +318 -185
- data/lib/asciidoctor/helpers.rb +35 -35
- data/lib/asciidoctor/inline.rb +32 -1
- data/lib/asciidoctor/list.rb +22 -6
- data/lib/asciidoctor/parser.rb +1008 -1038
- data/lib/asciidoctor/path_resolver.rb +46 -50
- data/lib/asciidoctor/reader.rb +275 -251
- data/lib/asciidoctor/section.rb +86 -58
- data/lib/asciidoctor/stylesheets.rb +6 -6
- data/lib/asciidoctor/substitutors.rb +567 -649
- data/lib/asciidoctor/table.rb +163 -108
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +18 -16
- data/man/asciidoctor.adoc +15 -13
- data/test/attributes_test.rb +138 -22
- data/test/blocks_test.rb +377 -97
- data/test/converter_test.rb +13 -0
- data/test/document_test.rb +244 -34
- data/test/extensions_test.rb +409 -42
- data/test/fixtures/asciidoc_index.txt +521 -0
- data/test/fixtures/basic-docinfo-footer.html +6 -0
- data/test/fixtures/basic-docinfo-footer.xml +8 -0
- data/test/fixtures/basic-docinfo.html +1 -0
- data/test/fixtures/basic-docinfo.xml +4 -0
- data/test/fixtures/basic.asciidoc +5 -0
- data/test/fixtures/chapter-a.adoc +3 -0
- data/test/fixtures/child-include.adoc +5 -0
- data/test/fixtures/circle.svg +9 -0
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
- data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +6 -0
- data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +1 -0
- data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +3 -0
- data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +5 -0
- data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +6 -0
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +3 -0
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +5 -0
- data/test/fixtures/custom-docinfodir/basic-docinfo.html +1 -0
- data/test/fixtures/custom-docinfodir/docinfo.html +1 -0
- data/test/fixtures/docinfo-footer.html +1 -0
- data/test/fixtures/docinfo-footer.xml +9 -0
- data/test/fixtures/docinfo.html +1 -0
- data/test/fixtures/docinfo.xml +3 -0
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +13 -0
- data/test/fixtures/grandchild-include.adoc +3 -0
- data/test/fixtures/hello-asciidoctor.pdf +69 -0
- data/test/fixtures/include-file.asciidoc +24 -0
- data/test/fixtures/include-file.ml +3 -0
- data/test/fixtures/include-file.xml +5 -0
- data/test/fixtures/master.adoc +5 -0
- data/test/fixtures/mismatched-end-tag.adoc +7 -0
- data/test/fixtures/parent-include-restricted.adoc +5 -0
- data/test/fixtures/parent-include.adoc +5 -0
- data/test/fixtures/sample.asciidoc +26 -0
- data/test/fixtures/stylesheets/custom.css +3 -0
- data/test/fixtures/subs-docinfo.html +2 -0
- data/test/fixtures/subs.adoc +7 -0
- data/test/fixtures/tagged-class-enclosed.rb +26 -0
- data/test/fixtures/tagged-class.rb +23 -0
- data/test/fixtures/tip.gif +0 -0
- data/test/invoker_test.rb +82 -4
- data/test/links_test.rb +312 -37
- data/test/lists_test.rb +204 -25
- data/test/manpage_test.rb +191 -4
- data/test/options_test.rb +18 -1
- data/test/paragraphs_test.rb +32 -7
- data/test/parser_test.rb +150 -30
- data/test/paths_test.rb +47 -13
- data/test/preamble_test.rb +1 -1
- data/test/reader_test.rb +366 -126
- data/test/sections_test.rb +203 -56
- data/test/substitutions_test.rb +339 -131
- data/test/tables_test.rb +315 -15
- data/test/test_helper.rb +400 -0
- data/test/text_test.rb +5 -5
- metadata +110 -22
    
        data/test/sections_test.rb
    CHANGED
    
    | @@ -22,10 +22,15 @@ context 'Sections' do | |
| 22 22 | 
             
                end
         | 
| 23 23 |  | 
| 24 24 | 
             
                test 'synthetic id removes entities' do
         | 
| 25 | 
            -
                  sec = block_from_string('== Ben & Jerry & Company "Ice Cream Brothers" &# | 
| 25 | 
            +
                  sec = block_from_string('== Ben & Jerry & Company¹ "Ice Cream Brothers" あ')
         | 
| 26 26 | 
             
                  assert_equal '_ben_jerry_company_ice_cream_brothers', sec.id
         | 
| 27 27 | 
             
                end
         | 
| 28 28 |  | 
| 29 | 
            +
                test 'synthetic id removes adjacent entities with mixed case' do
         | 
| 30 | 
            +
                  sec = block_from_string('== a ®&© b')
         | 
| 31 | 
            +
                  assert_equal '_a_b', sec.id
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 29 34 | 
             
                test 'synthetic id prefix can be customized' do
         | 
| 30 35 | 
             
                  sec = block_from_string(":idprefix: id_\n\n== Section One")
         | 
| 31 36 | 
             
                  assert_equal 'id_section_one', sec.id
         | 
| @@ -77,6 +82,17 @@ context 'Sections' do | |
| 77 82 | 
             
                  assert_equal 'Section One', sec.title
         | 
| 78 83 | 
             
                end
         | 
| 79 84 |  | 
| 85 | 
            +
                test 'explicit id can be defined using an embedded anchor when using setext section titles' do
         | 
| 86 | 
            +
                  input = <<-EOS
         | 
| 87 | 
            +
            Section Title [[refid,reftext]]
         | 
| 88 | 
            +
            -------------------------------
         | 
| 89 | 
            +
                  EOS
         | 
| 90 | 
            +
                  sec = block_from_string input
         | 
| 91 | 
            +
                  assert_equal 'Section Title', sec.title
         | 
| 92 | 
            +
                  assert_equal 'refid', sec.id
         | 
| 93 | 
            +
                  assert_equal 'reftext', (sec.attr 'reftext')
         | 
| 94 | 
            +
                end
         | 
| 95 | 
            +
             | 
| 80 96 | 
             
                test 'explicit id can be defined using an embedded anchor with reftext' do
         | 
| 81 97 | 
             
                  sec = block_from_string("== Section One [[one,Section Uno]] ==")
         | 
| 82 98 | 
             
                  assert_equal 'one', sec.id
         | 
| @@ -155,7 +171,7 @@ content | |
| 155 171 | 
             
                  EOS
         | 
| 156 172 |  | 
| 157 173 | 
             
                  doc = document_from_string input
         | 
| 158 | 
            -
                  reftext = doc. | 
| 174 | 
            +
                  reftext = doc.catalog[:ids]['install']
         | 
| 159 175 | 
             
                  refute_nil reftext
         | 
| 160 176 | 
             
                  assert_equal 'Install Procedure', reftext
         | 
| 161 177 | 
             
                end
         | 
| @@ -169,12 +185,28 @@ content | |
| 169 185 | 
             
                  EOS
         | 
| 170 186 |  | 
| 171 187 | 
             
                  doc = document_from_string input
         | 
| 172 | 
            -
                  reftext = doc. | 
| 188 | 
            +
                  reftext = doc.catalog[:ids]['_install']
         | 
| 173 189 | 
             
                  refute_nil reftext
         | 
| 174 190 | 
             
                  assert_equal 'Install Procedure', reftext
         | 
| 175 191 | 
             
                end
         | 
| 176 192 |  | 
| 177 | 
            -
                test 'should  | 
| 193 | 
            +
                test 'should substitute attributes when registering reftext for section' do
         | 
| 194 | 
            +
                  input = <<-EOS
         | 
| 195 | 
            +
            :platform-name: Linux
         | 
| 196 | 
            +
             | 
| 197 | 
            +
            [[install,install on {platform-name}]]
         | 
| 198 | 
            +
            == Install
         | 
| 199 | 
            +
             | 
| 200 | 
            +
            content
         | 
| 201 | 
            +
                  EOS
         | 
| 202 | 
            +
             | 
| 203 | 
            +
                  doc = document_from_string input
         | 
| 204 | 
            +
                  reftext = doc.catalog[:ids]['install']
         | 
| 205 | 
            +
                  refute_nil reftext
         | 
| 206 | 
            +
                  assert_equal 'install on Linux', reftext
         | 
| 207 | 
            +
                end
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                test 'duplicate section id should not overwrite existing section id entry in references table' do
         | 
| 178 210 | 
             
                  input = <<-EOS
         | 
| 179 211 | 
             
            [#install]
         | 
| 180 212 | 
             
            == First Install
         | 
| @@ -187,13 +219,14 @@ content | |
| 187 219 | 
             
            content
         | 
| 188 220 | 
             
                  EOS
         | 
| 189 221 |  | 
| 190 | 
            -
                  doc = document_from_string input
         | 
| 191 | 
            -
                  reftext = doc. | 
| 222 | 
            +
                  doc, warnings = redirect_streams {|_, err| [(document_from_string input), err.string]}
         | 
| 223 | 
            +
                  reftext = doc.catalog[:ids]['install']
         | 
| 192 224 | 
             
                  refute_nil reftext
         | 
| 193 225 | 
             
                  assert_equal 'First Install', reftext
         | 
| 226 | 
            +
                  assert_includes warnings, 'line 7: id assigned to section already in use: install'
         | 
| 194 227 | 
             
                end
         | 
| 195 228 |  | 
| 196 | 
            -
                test 'should not overwrite existing id entry  | 
| 229 | 
            +
                test 'duplicate block id should not overwrite existing section id entry in references table' do
         | 
| 197 230 | 
             
                  input = <<-EOS
         | 
| 198 231 | 
             
            [#install]
         | 
| 199 232 | 
             
            == First Install
         | 
| @@ -204,10 +237,11 @@ content | |
| 204 237 | 
             
            content
         | 
| 205 238 | 
             
                  EOS
         | 
| 206 239 |  | 
| 207 | 
            -
                  doc = document_from_string input
         | 
| 208 | 
            -
                  reftext = doc. | 
| 240 | 
            +
                  doc, warnings = redirect_streams {|_, err| [(document_from_string input), err.string] }
         | 
| 241 | 
            +
                  reftext = doc.catalog[:ids]['install']
         | 
| 209 242 | 
             
                  refute_nil reftext
         | 
| 210 243 | 
             
                  assert_equal 'First Install', reftext
         | 
| 244 | 
            +
                  assert_includes warnings, 'line 7: id assigned to block already in use: install'
         | 
| 211 245 | 
             
                end
         | 
| 212 246 | 
             
              end
         | 
| 213 247 |  | 
| @@ -275,6 +309,14 @@ preamble | |
| 275 309 | 
             
                  assert_xpath "//h1[not(@id)][text() = 'My Title']", render_string("= My Title =")
         | 
| 276 310 | 
             
                end
         | 
| 277 311 |  | 
| 312 | 
            +
                test 'document title created from leveloffset shift defined in document' do
         | 
| 313 | 
            +
                  assert_xpath "//h1[not(@id)][text() = 'Document Title']", render_string(%(:leveloffset: -1\n== Document Title))
         | 
| 314 | 
            +
                end
         | 
| 315 | 
            +
             | 
| 316 | 
            +
                test 'document title created from leveloffset shift defined in API' do
         | 
| 317 | 
            +
                  assert_xpath "//h1[not(@id)][text() = 'Document Title']", render_string('== Document Title', :attributes => { 'leveloffset' => '-1@' })
         | 
| 318 | 
            +
                end
         | 
| 319 | 
            +
             | 
| 278 320 | 
             
                test 'should assign id on document title to body' do
         | 
| 279 321 | 
             
                  input = <<-EOS
         | 
| 280 322 | 
             
            [[idname]]
         | 
| @@ -343,6 +385,17 @@ content | |
| 343 385 | 
             
                  assert_xpath "//h2[@id='_my_section'][text() = 'My Section']", render_string("My Section\n-----------")
         | 
| 344 386 | 
             
                end
         | 
| 345 387 |  | 
| 388 | 
            +
                test 'should not recognize underline containing a mix of characters' do
         | 
| 389 | 
            +
                  input = <<-EOS
         | 
| 390 | 
            +
            My Section
         | 
| 391 | 
            +
            ----^^----
         | 
| 392 | 
            +
                  EOS
         | 
| 393 | 
            +
             | 
| 394 | 
            +
                  result = render_embedded_string input
         | 
| 395 | 
            +
                  assert_xpath '//h2[@id="_my_section"][text() = "My Section"]', result, 0
         | 
| 396 | 
            +
                  assert_includes result, '----^^----'
         | 
| 397 | 
            +
                end
         | 
| 398 | 
            +
             | 
| 346 399 | 
             
                test "heading title with multiline syntax cannot begin with a dot" do
         | 
| 347 400 | 
             
                  title = ".My Title"
         | 
| 348 401 | 
             
                  chars = "-" * title.length
         | 
| @@ -362,7 +415,7 @@ content | |
| 362 415 | 
             
                end
         | 
| 363 416 |  | 
| 364 417 | 
             
                test "with XML entity" do
         | 
| 365 | 
            -
                  assert_xpath "//h2[@id='_where_s_the_love'][text() = \"Where#{ | 
| 418 | 
            +
                  assert_xpath "//h2[@id='_where_s_the_love'][text() = \"Where#{decode_char 8217}s the love?\"]", render_string("== Where's the love?")
         | 
| 366 419 | 
             
                end
         | 
| 367 420 |  | 
| 368 421 | 
             
                test "with non-word character" do
         | 
| @@ -495,6 +548,15 @@ blah blah | |
| 495 548 | 
             
                  output = render_string input
         | 
| 496 549 | 
             
                  assert_xpath "//h2[@id='_section_one'][text() = 'Section One']", output, 1
         | 
| 497 550 | 
             
                end
         | 
| 551 | 
            +
             | 
| 552 | 
            +
                test 'should not match mixed single-line syntax' do
         | 
| 553 | 
            +
                  input = <<-EOS
         | 
| 554 | 
            +
            =#= My Title
         | 
| 555 | 
            +
                  EOS
         | 
| 556 | 
            +
                  output = render_embedded_string input
         | 
| 557 | 
            +
                  assert_xpath "//h3[@id='_my_title'][text() = 'My Title']", output, 0
         | 
| 558 | 
            +
                  assert_includes output, '<p>=#= My Title</p>'
         | 
| 559 | 
            +
                end
         | 
| 498 560 | 
             
              end
         | 
| 499 561 |  | 
| 500 562 | 
             
              context 'Floating Title' do
         | 
| @@ -533,6 +595,20 @@ not in section | |
| 533 595 | 
             
                  assert_xpath '/h3/following-sibling::*[@class="paragraph"]/p[text()="not in section"]', output, 1
         | 
| 534 596 | 
             
                end
         | 
| 535 597 |  | 
| 598 | 
            +
                test 'should generate id for floating title from converted title' do
         | 
| 599 | 
            +
                  input = <<-EOS
         | 
| 600 | 
            +
            [discrete]
         | 
| 601 | 
            +
            === {sp}Heading{sp}
         | 
| 602 | 
            +
             | 
| 603 | 
            +
            not in section
         | 
| 604 | 
            +
                  EOS
         | 
| 605 | 
            +
             | 
| 606 | 
            +
                  output = render_embedded_string input
         | 
| 607 | 
            +
                  assert_xpath '/h3', output, 1
         | 
| 608 | 
            +
                  assert_xpath '/h3[@class="discrete"][@id="_heading"]', output, 1
         | 
| 609 | 
            +
                  assert_xpath '/h3[@class="discrete"][@id="_heading"][text()=" Heading "]', output, 1
         | 
| 610 | 
            +
                end
         | 
| 611 | 
            +
             | 
| 536 612 | 
             
                test 'should create floating title if style is float with shorthand role and id' do
         | 
| 537 613 | 
             
                  input = <<-EOS
         | 
| 538 614 | 
             
            [float.independent#first]
         | 
| @@ -581,7 +657,7 @@ not in section | |
| 581 657 | 
             
                  assert floatingtitle.context != :section
         | 
| 582 658 | 
             
                  assert_equal :floating_title, floatingtitle.context
         | 
| 583 659 | 
             
                  assert_equal '_independent_heading', floatingtitle.id
         | 
| 584 | 
            -
                  assert doc. | 
| 660 | 
            +
                  assert doc.catalog[:ids].has_key?('_independent_heading')
         | 
| 585 661 | 
             
                end
         | 
| 586 662 |  | 
| 587 663 | 
             
                test 'can assign explicit id to floating title' do
         | 
| @@ -596,7 +672,7 @@ not in section | |
| 596 672 | 
             
                  doc = document_from_string input
         | 
| 597 673 | 
             
                  floating_title = doc.blocks.first
         | 
| 598 674 | 
             
                  assert_equal 'unchained', floating_title.id
         | 
| 599 | 
            -
                  assert doc. | 
| 675 | 
            +
                  assert doc.catalog[:ids].has_key?('unchained')
         | 
| 600 676 | 
             
                end
         | 
| 601 677 |  | 
| 602 678 | 
             
                test 'should not include floating title in toc' do
         | 
| @@ -660,6 +736,20 @@ not in section | |
| 660 736 | 
             
                  assert_xpath '/h2[@class="float isolated"]', output, 1
         | 
| 661 737 | 
             
                end
         | 
| 662 738 |  | 
| 739 | 
            +
                test 'should ignore title attribute on discrete heading' do
         | 
| 740 | 
            +
                  input = <<-EOS
         | 
| 741 | 
            +
            [discrete,title="Captured!"]
         | 
| 742 | 
            +
            == Independent Heading!
         | 
| 743 | 
            +
             | 
| 744 | 
            +
            not in section
         | 
| 745 | 
            +
                  EOS
         | 
| 746 | 
            +
             | 
| 747 | 
            +
                  doc = document_from_string input
         | 
| 748 | 
            +
                  heading = doc.blocks[0]
         | 
| 749 | 
            +
                  assert_equal 'Independent Heading!', heading.title
         | 
| 750 | 
            +
                  refute heading.attributes.key? 'title'
         | 
| 751 | 
            +
                end
         | 
| 752 | 
            +
             | 
| 663 753 | 
             
                test 'should use specified id and reftext when registering discrete section reference' do
         | 
| 664 754 | 
             
                  input = <<-EOS
         | 
| 665 755 | 
             
            [[install,Install Procedure]]
         | 
| @@ -670,7 +760,7 @@ content | |
| 670 760 | 
             
                  EOS
         | 
| 671 761 |  | 
| 672 762 | 
             
                  doc = document_from_string input
         | 
| 673 | 
            -
                  reftext = doc. | 
| 763 | 
            +
                  reftext = doc.catalog[:ids]['install']
         | 
| 674 764 | 
             
                  refute_nil reftext
         | 
| 675 765 | 
             
                  assert_equal 'Install Procedure', reftext
         | 
| 676 766 | 
             
                end
         | 
| @@ -685,7 +775,7 @@ content | |
| 685 775 | 
             
                  EOS
         | 
| 686 776 |  | 
| 687 777 | 
             
                  doc = document_from_string input
         | 
| 688 | 
            -
                  reftext = doc. | 
| 778 | 
            +
                  reftext = doc.catalog[:ids]['_install']
         | 
| 689 779 | 
             
                  refute_nil reftext
         | 
| 690 780 | 
             
                  assert_equal 'Install Procedure', reftext
         | 
| 691 781 | 
             
                end
         | 
| @@ -1186,6 +1276,30 @@ content | |
| 1186 1276 | 
             
                    assert_xpath %(//h2[@id="_chapter_#{num}"][text()="#{num}. Chapter #{num}"]), result, 1
         | 
| 1187 1277 | 
             
                  end
         | 
| 1188 1278 | 
             
                end
         | 
| 1279 | 
            +
             | 
| 1280 | 
            +
                test 'reindex_sections should correct section enumeration after sections are modified' do
         | 
| 1281 | 
            +
                  input = <<-EOS
         | 
| 1282 | 
            +
            :sectnums:
         | 
| 1283 | 
            +
             | 
| 1284 | 
            +
            == First Section
         | 
| 1285 | 
            +
             | 
| 1286 | 
            +
            content
         | 
| 1287 | 
            +
             | 
| 1288 | 
            +
            == Last Section
         | 
| 1289 | 
            +
             | 
| 1290 | 
            +
            content
         | 
| 1291 | 
            +
                  EOS
         | 
| 1292 | 
            +
             | 
| 1293 | 
            +
                  doc = document_from_string input
         | 
| 1294 | 
            +
                  second_section = Asciidoctor::Section.new doc
         | 
| 1295 | 
            +
                  doc.blocks.insert 1, second_section
         | 
| 1296 | 
            +
                  doc.reindex_sections
         | 
| 1297 | 
            +
                  sections = doc.sections
         | 
| 1298 | 
            +
                  [0, 1, 2].each do |index|
         | 
| 1299 | 
            +
                    assert_equal index, sections[index].index
         | 
| 1300 | 
            +
                    assert_equal index + 1, sections[index].number
         | 
| 1301 | 
            +
                  end
         | 
| 1302 | 
            +
                end
         | 
| 1189 1303 | 
             
              end
         | 
| 1190 1304 |  | 
| 1191 1305 | 
             
              context 'Links and anchors' do
         | 
| @@ -1231,20 +1345,7 @@ Linux installation instructions. | |
| 1231 1345 | 
             
              end
         | 
| 1232 1346 |  | 
| 1233 1347 | 
             
              context 'Special sections' do
         | 
| 1234 | 
            -
                test 'should assign sectname and  | 
| 1235 | 
            -
                  input = <<-EOS
         | 
| 1236 | 
            -
            [appendix]
         | 
| 1237 | 
            -
            == Attribute Options
         | 
| 1238 | 
            -
             | 
| 1239 | 
            -
            Details
         | 
| 1240 | 
            -
                  EOS
         | 
| 1241 | 
            -
             | 
| 1242 | 
            -
                  output = block_from_string input
         | 
| 1243 | 
            -
                  assert_equal 'appendix', output.sectname
         | 
| 1244 | 
            -
                  assert_equal 'Appendix A: ', output.caption
         | 
| 1245 | 
            -
                end
         | 
| 1246 | 
            -
             | 
| 1247 | 
            -
                test 'should render appendix title prefixed with caption' do
         | 
| 1348 | 
            +
                test 'should assign sectname, caption, and numeral to appendix section by default' do
         | 
| 1248 1349 | 
             
                  input = <<-EOS
         | 
| 1249 1350 | 
             
            [appendix]
         | 
| 1250 1351 | 
             
            == Attribute Options
         | 
| @@ -1252,14 +1353,15 @@ Details | |
| 1252 1353 | 
             
            Details
         | 
| 1253 1354 | 
             
                  EOS
         | 
| 1254 1355 |  | 
| 1255 | 
            -
                   | 
| 1256 | 
            -
                   | 
| 1356 | 
            +
                  appendix = block_from_string input
         | 
| 1357 | 
            +
                  assert_equal 'appendix', appendix.sectname
         | 
| 1358 | 
            +
                  assert_equal 'Appendix A: ', appendix.caption
         | 
| 1359 | 
            +
                  assert_equal 'A', appendix.number
         | 
| 1360 | 
            +
                  assert_equal true, appendix.numbered
         | 
| 1257 1361 | 
             
                end
         | 
| 1258 1362 |  | 
| 1259 | 
            -
                test 'should prefix appendix title by label  | 
| 1363 | 
            +
                test 'should prefix appendix title by numbered label even when section numbering is disabled' do
         | 
| 1260 1364 | 
             
                  input = <<-EOS
         | 
| 1261 | 
            -
            :numbered:
         | 
| 1262 | 
            -
             | 
| 1263 1365 | 
             
            [appendix]
         | 
| 1264 1366 | 
             
            == Attribute Options
         | 
| 1265 1367 |  | 
| @@ -1284,10 +1386,10 @@ Details | |
| 1284 1386 | 
             
                  assert_xpath '//h2[text()="App A: Attribute Options"]', output, 1
         | 
| 1285 1387 | 
             
                end
         | 
| 1286 1388 |  | 
| 1287 | 
            -
                test 'should only assign letter to appendix when numbered is enabled and appendix caption is  | 
| 1389 | 
            +
                test 'should only assign letter to appendix when numbered is enabled and appendix caption is not set' do
         | 
| 1288 1390 | 
             
                  input = <<-EOS
         | 
| 1289 1391 | 
             
            :numbered:
         | 
| 1290 | 
            -
             | 
| 1392 | 
            +
            :!appendix-caption:
         | 
| 1291 1393 |  | 
| 1292 1394 | 
             
            [appendix]
         | 
| 1293 1395 | 
             
            == Attribute Options
         | 
| @@ -1498,12 +1600,16 @@ Terms | |
| 1498 1600 | 
             
                  assert_xpath '//*[@id="toc"]//a[@href="#_level_3"][text()="Level 3"]', output, 1
         | 
| 1499 1601 | 
             
                end
         | 
| 1500 1602 |  | 
| 1501 | 
            -
                 | 
| 1502 | 
            -
            =begin
         | 
| 1503 | 
            -
                test 'should not number special sections or subsections' do
         | 
| 1603 | 
            +
                test 'should not number special sections or their subsections by default except for appendices' do
         | 
| 1504 1604 | 
             
                  input = <<-EOS
         | 
| 1505 | 
            -
            : | 
| 1506 | 
            -
             | 
| 1605 | 
            +
            :sectnums:
         | 
| 1606 | 
            +
             | 
| 1607 | 
            +
            [dedication]
         | 
| 1608 | 
            +
            == Dedication
         | 
| 1609 | 
            +
             | 
| 1610 | 
            +
            === Dedication Subsection
         | 
| 1611 | 
            +
             | 
| 1612 | 
            +
            content
         | 
| 1507 1613 |  | 
| 1508 1614 | 
             
            == Section One
         | 
| 1509 1615 |  | 
| @@ -1528,19 +1634,27 @@ Terms | |
| 1528 1634 | 
             
                  EOS
         | 
| 1529 1635 |  | 
| 1530 1636 | 
             
                  output = render_embedded_string input
         | 
| 1531 | 
            -
                  assert_xpath '(//h2)[1][text()=" | 
| 1532 | 
            -
                  assert_xpath '(// | 
| 1533 | 
            -
                  assert_xpath '(//h2)[ | 
| 1534 | 
            -
                  assert_xpath '(// | 
| 1535 | 
            -
                  assert_xpath '(//h2)[4][text()=" | 
| 1637 | 
            +
                  assert_xpath '(//h2)[1][text()="Dedication"]', output, 1
         | 
| 1638 | 
            +
                  assert_xpath '(//h3)[1][text()="Dedication Subsection"]', output, 1
         | 
| 1639 | 
            +
                  assert_xpath '(//h2)[2][text()="1. Section One"]', output, 1
         | 
| 1640 | 
            +
                  assert_xpath '(//h2)[3][text()="Appendix A: Attribute Options"]', output, 1
         | 
| 1641 | 
            +
                  assert_xpath '(//h2)[4][text()="Appendix B: Migration"]', output, 1
         | 
| 1642 | 
            +
                  assert_xpath '(//h3)[2][text()="B.1. Gotchas"]', output, 1
         | 
| 1643 | 
            +
                  assert_xpath '(//h2)[5][text()="Glossary"]', output, 1
         | 
| 1536 1644 | 
             
                end
         | 
| 1537 1645 |  | 
| 1538 | 
            -
                test 'should not number special sections or subsections in toc' do
         | 
| 1646 | 
            +
                test 'should not number special sections or their subsections in toc by default except for appendices' do
         | 
| 1539 1647 | 
             
                  input = <<-EOS
         | 
| 1540 | 
            -
            : | 
| 1541 | 
            -
            :specialnumbered!:
         | 
| 1648 | 
            +
            :sectnums:
         | 
| 1542 1649 | 
             
            :toc:
         | 
| 1543 1650 |  | 
| 1651 | 
            +
            [dedication]
         | 
| 1652 | 
            +
            == Dedication
         | 
| 1653 | 
            +
             | 
| 1654 | 
            +
            === Dedication Subsection
         | 
| 1655 | 
            +
             | 
| 1656 | 
            +
            content
         | 
| 1657 | 
            +
             | 
| 1544 1658 | 
             
            == Section One
         | 
| 1545 1659 |  | 
| 1546 1660 | 
             
            [appendix]
         | 
| @@ -1564,13 +1678,14 @@ Terms | |
| 1564 1678 | 
             
                  EOS
         | 
| 1565 1679 |  | 
| 1566 1680 | 
             
                  output = render_string input
         | 
| 1681 | 
            +
                  assert_xpath '//*[@id="toc"]/ul//li/a[text()="Dedication"]', output, 1
         | 
| 1682 | 
            +
                  assert_xpath '//*[@id="toc"]/ul//li/a[text()="Dedication Subsection"]', output, 1
         | 
| 1567 1683 | 
             
                  assert_xpath '//*[@id="toc"]/ul//li/a[text()="1. Section One"]', output, 1
         | 
| 1568 1684 | 
             
                  assert_xpath '//*[@id="toc"]/ul//li/a[text()="Appendix A: Attribute Options"]', output, 1
         | 
| 1569 1685 | 
             
                  assert_xpath '//*[@id="toc"]/ul//li/a[text()="Appendix B: Migration"]', output, 1
         | 
| 1570 | 
            -
                  assert_xpath '//*[@id="toc"]/ul//li/a[text()="Gotchas"]', output, 1
         | 
| 1686 | 
            +
                  assert_xpath '//*[@id="toc"]/ul//li/a[text()="B.1. Gotchas"]', output, 1
         | 
| 1571 1687 | 
             
                  assert_xpath '//*[@id="toc"]/ul//li/a[text()="Glossary"]', output, 1
         | 
| 1572 1688 | 
             
                end
         | 
| 1573 | 
            -
            =end
         | 
| 1574 1689 |  | 
| 1575 1690 | 
             
                test 'level 0 special sections in multipart book should be rendered as level 1' do
         | 
| 1576 1691 | 
             
                  input = <<-EOS
         | 
| @@ -1594,7 +1709,7 @@ Appendix text | |
| 1594 1709 | 
             
                  assert_xpath '//h2[@id = "_appendix"]', output, 1
         | 
| 1595 1710 | 
             
                end
         | 
| 1596 1711 |  | 
| 1597 | 
            -
                test 'should output docbook elements that  | 
| 1712 | 
            +
                test 'should output docbook elements that correspond to special sections in book doctype' do
         | 
| 1598 1713 | 
             
                  input = <<-EOS
         | 
| 1599 1714 | 
             
            = Multipart Book
         | 
| 1600 1715 | 
             
            :doctype: book
         | 
| @@ -1730,7 +1845,7 @@ Abstract content | |
| 1730 1845 | 
             
            === Glossary A
         | 
| 1731 1846 |  | 
| 1732 1847 | 
             
            Glossaries are optional.
         | 
| 1733 | 
            -
            Glossaries entries are an example of a style of AsciiDoc  | 
| 1848 | 
            +
            Glossaries entries are an example of a style of AsciiDoc description lists.
         | 
| 1734 1849 |  | 
| 1735 1850 | 
             
            [glossary]
         | 
| 1736 1851 | 
             
            A glossary term::
         | 
| @@ -1795,7 +1910,7 @@ This should be a tip, not a heading. | |
| 1795 1910 | 
             
                  assert_xpath "//*[@class='admonitionblock tip']//p[text() = 'This should be a tip, not a heading.']", output, 1
         | 
| 1796 1911 | 
             
                end
         | 
| 1797 1912 |  | 
| 1798 | 
            -
                test "should not match a heading in a  | 
| 1913 | 
            +
                test "should not match a heading in a description list" do
         | 
| 1799 1914 | 
             
                  input = <<-EOS
         | 
| 1800 1915 | 
             
            Section
         | 
| 1801 1916 | 
             
            -------
         | 
| @@ -2216,7 +2331,7 @@ It was a dark and stormy night... | |
| 2216 2331 | 
             
            They couldn't believe their eyes when...
         | 
| 2217 2332 | 
             
                  EOS
         | 
| 2218 2333 |  | 
| 2219 | 
            -
                  output =  | 
| 2334 | 
            +
                  output = render_embedded_string input
         | 
| 2220 2335 | 
             
                  assert_css '#preamble:root #toc', output, 1
         | 
| 2221 2336 | 
             
                  assert_css '#preamble:root .paragraph + #toc', output, 1
         | 
| 2222 2337 | 
             
                end
         | 
| @@ -2238,7 +2353,7 @@ It was a dark and stormy night... | |
| 2238 2353 | 
             
            They couldn't believe their eyes when...
         | 
| 2239 2354 | 
             
                  EOS
         | 
| 2240 2355 |  | 
| 2241 | 
            -
                  output =  | 
| 2356 | 
            +
                  output = render_embedded_string input
         | 
| 2242 2357 | 
             
                  assert_css 'h1:root', output, 1
         | 
| 2243 2358 | 
             
                  assert_css 'h1:root + #toc:root', output, 1
         | 
| 2244 2359 | 
             
                  assert_css 'h1:root + #toc:root + #preamble:root', output, 1
         | 
| @@ -2433,7 +2548,7 @@ It only has content. | |
| 2433 2548 | 
             
              end
         | 
| 2434 2549 |  | 
| 2435 2550 | 
             
              context 'article doctype' do
         | 
| 2436 | 
            -
                test 'should create sections  | 
| 2551 | 
            +
                test 'should create only sections in docbook backend' do
         | 
| 2437 2552 | 
             
                  input = <<-EOS
         | 
| 2438 2553 | 
             
            = Article
         | 
| 2439 2554 | 
             
            Doc Writer
         | 
| @@ -2520,6 +2635,38 @@ That's all she wrote! | |
| 2520 2635 | 
             
                  assert_xpath '//h1[@id="_chapter_three"][text() = "Chapter Three"]', output, 1
         | 
| 2521 2636 | 
             
                end
         | 
| 2522 2637 |  | 
| 2638 | 
            +
                test 'should assign appropriate sectname for section type' do
         | 
| 2639 | 
            +
                  input = <<-EOS
         | 
| 2640 | 
            +
            = Book Title
         | 
| 2641 | 
            +
            :doctype: book
         | 
| 2642 | 
            +
            :idprefix:
         | 
| 2643 | 
            +
            :idseparator: -
         | 
| 2644 | 
            +
             | 
| 2645 | 
            +
            = Part Title
         | 
| 2646 | 
            +
             | 
| 2647 | 
            +
            == Chapter Title
         | 
| 2648 | 
            +
             | 
| 2649 | 
            +
            === Section Title
         | 
| 2650 | 
            +
             | 
| 2651 | 
            +
            content
         | 
| 2652 | 
            +
             | 
| 2653 | 
            +
            [appendix]
         | 
| 2654 | 
            +
            == Appendix Title
         | 
| 2655 | 
            +
             | 
| 2656 | 
            +
            === Appendix Section Title
         | 
| 2657 | 
            +
             | 
| 2658 | 
            +
            content
         | 
| 2659 | 
            +
                  EOS
         | 
| 2660 | 
            +
             | 
| 2661 | 
            +
                  doc = document_from_string input
         | 
| 2662 | 
            +
                  assert_equal 'header', doc.header.sectname
         | 
| 2663 | 
            +
                  assert_equal 'part', (doc.find_by :id => 'part-title')[0].sectname
         | 
| 2664 | 
            +
                  assert_equal 'chapter', (doc.find_by :id => 'chapter-title')[0].sectname
         | 
| 2665 | 
            +
                  assert_equal 'section', (doc.find_by :id => 'section-title')[0].sectname
         | 
| 2666 | 
            +
                  assert_equal 'appendix', (doc.find_by :id => 'appendix-title')[0].sectname
         | 
| 2667 | 
            +
                  assert_equal 'section', (doc.find_by :id => 'appendix-section-title')[0].sectname
         | 
| 2668 | 
            +
                end
         | 
| 2669 | 
            +
             | 
| 2523 2670 | 
             
                test 'should add partintro style to child paragraph of part' do
         | 
| 2524 2671 | 
             
                  input = <<-EOS
         | 
| 2525 2672 | 
             
            = Book
         |