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/tables_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 'Tables' do
         | 
| 4 8 |  | 
| @@ -14,8 +18,8 @@ context 'Tables' do | |
| 14 18 | 
             
                  cells = [%w(A B C), %w(a b c), %w(1 2 3)]
         | 
| 15 19 | 
             
                  output = render_embedded_string input
         | 
| 16 20 | 
             
                  assert_css 'table', output, 1
         | 
| 17 | 
            -
                  assert_css 'table.tableblock.frame-all.grid-all | 
| 18 | 
            -
                  assert_css 'table > colgroup > col[style*="width:33%"]', output, 3
         | 
| 21 | 
            +
                  assert_css 'table.tableblock.frame-all.grid-all.spread', output, 1
         | 
| 22 | 
            +
                  assert_css 'table > colgroup > col[style*="width: 33%"]', output, 3
         | 
| 19 23 | 
             
                  assert_css 'table tr', output, 3
         | 
| 20 24 | 
             
                  assert_css 'table > tbody > tr', output, 3
         | 
| 21 25 | 
             
                  assert_css 'table td', output, 9
         | 
| @@ -124,7 +128,7 @@ A | here| a | there | |
| 124 128 | 
             
                  EOS
         | 
| 125 129 | 
             
                  output = render_embedded_string input
         | 
| 126 130 | 
             
                  assert_xpath '//tbody/tr/td[1]/p[text()="Cool new show"]', output, 1
         | 
| 127 | 
            -
                  assert_xpath %(//tbody/tr/td[2]/p[text()='Coming soon#{ | 
| 131 | 
            +
                  assert_xpath %(//tbody/tr/td[2]/p[text()='Coming soon#{expand_entity 8230}#{expand_entity 8203}']), output, 1
         | 
| 128 132 | 
             
                end
         | 
| 129 133 |  | 
| 130 134 | 
             
                test 'table and col width not assigned when autowidth option is specified' do
         | 
| @@ -223,6 +227,39 @@ A | here| a | there | |
| 223 227 | 
             
                  assert_css 'table > tbody > tr', output, 3
         | 
| 224 228 | 
             
                end
         | 
| 225 229 |  | 
| 230 | 
            +
                test 'table with header and footer docbook' do
         | 
| 231 | 
            +
                  input = <<-EOS
         | 
| 232 | 
            +
            .Table with header, body and footer
         | 
| 233 | 
            +
            [frame="topbot",options="header,footer"]
         | 
| 234 | 
            +
            |===
         | 
| 235 | 
            +
            |Item       |Quantity
         | 
| 236 | 
            +
            |Item 1     |1        
         | 
| 237 | 
            +
            |Item 2     |2        
         | 
| 238 | 
            +
            |Item 3     |3        
         | 
| 239 | 
            +
            |Total      |6        
         | 
| 240 | 
            +
            |===
         | 
| 241 | 
            +
                  EOS
         | 
| 242 | 
            +
                  output = render_embedded_string input, :backend => 'docbook'
         | 
| 243 | 
            +
                  assert_css 'table', output, 1
         | 
| 244 | 
            +
                  assert_css 'table[frame="topbot"]', output, 1
         | 
| 245 | 
            +
                  assert_css 'table > title', output, 1
         | 
| 246 | 
            +
                  assert_css 'table > tgroup', output, 1
         | 
| 247 | 
            +
                  assert_css 'table > tgroup[cols="2"]', output, 1
         | 
| 248 | 
            +
                  assert_css 'table > tgroup[cols="2"] > colspec', output, 2
         | 
| 249 | 
            +
                  assert_css 'table > tgroup[cols="2"] > colspec[colwidth="50*"]', output, 2
         | 
| 250 | 
            +
                  assert_css 'table > tgroup > thead', output, 1
         | 
| 251 | 
            +
                  assert_css 'table > tgroup > thead > row', output, 1
         | 
| 252 | 
            +
                  assert_css 'table > tgroup > thead > row > entry', output, 2
         | 
| 253 | 
            +
                  assert_css 'table > tgroup > thead > row > entry > simpara', output, 0
         | 
| 254 | 
            +
                  assert_css 'table > tgroup > tfoot', output, 1
         | 
| 255 | 
            +
                  assert_css 'table > tgroup > tfoot > row', output, 1
         | 
| 256 | 
            +
                  assert_css 'table > tgroup > tfoot > row > entry', output, 2
         | 
| 257 | 
            +
                  assert_css 'table > tgroup > tfoot > row > entry > simpara', output, 2
         | 
| 258 | 
            +
                  assert_css 'table > tgroup > tbody', output, 1
         | 
| 259 | 
            +
                  assert_css 'table > tgroup > tbody > row', output, 3
         | 
| 260 | 
            +
                  assert_css 'table > tgroup > tbody > row', output, 3
         | 
| 261 | 
            +
                end
         | 
| 262 | 
            +
             | 
| 226 263 | 
             
                test 'table with implicit header row' do
         | 
| 227 264 | 
             
                  input = <<-EOS
         | 
| 228 265 | 
             
            |===
         | 
| @@ -321,17 +358,41 @@ A | here| a | there | |
| 321 358 | 
             
                  assert_css 'table > thead > tr > th', output, 3
         | 
| 322 359 | 
             
                  assert_css 'table > thead > tr > th > *', output, 0
         | 
| 323 360 |  | 
| 324 | 
            -
                  assert_css 'table > tfoot > tr >  | 
| 325 | 
            -
                  assert_css 'table > tfoot > tr > td | 
| 361 | 
            +
                  assert_css 'table > tfoot > tr > th', output, 1
         | 
| 362 | 
            +
                  assert_css 'table > tfoot > tr > td', output, 2
         | 
| 326 363 | 
             
                  assert_css 'table > tfoot > tr > td > p > strong', output, 1
         | 
| 327 364 | 
             
                  assert_css 'table > tfoot > tr > td > p > em', output, 1
         | 
| 328 365 |  | 
| 329 | 
            -
                  assert_css 'table > tbody > tr >  | 
| 330 | 
            -
                  assert_css 'table > tbody > tr > td | 
| 366 | 
            +
                  assert_css 'table > tbody > tr > th', output, 1
         | 
| 367 | 
            +
                  assert_css 'table > tbody > tr > td', output, 2
         | 
| 368 | 
            +
                  assert_css 'table > tbody > tr > td > p.header', output, 0
         | 
| 331 369 | 
             
                  assert_css 'table > tbody > tr > td > p > strong', output, 1
         | 
| 332 370 | 
             
                  assert_css 'table > tbody > tr > td > p > em > a', output, 1
         | 
| 333 371 | 
             
                end
         | 
| 334 372 |  | 
| 373 | 
            +
                test 'vertical table headers use th element instead of header class' do
         | 
| 374 | 
            +
                  input = <<-EOS
         | 
| 375 | 
            +
            [cols="1h,1s,1e"]
         | 
| 376 | 
            +
            |====
         | 
| 377 | 
            +
             | 
| 378 | 
            +
            |Name |Occupation| Website
         | 
| 379 | 
            +
             | 
| 380 | 
            +
            |Octocat |Social coding| http://github.com
         | 
| 381 | 
            +
             | 
| 382 | 
            +
            |Name |Occupation| Website
         | 
| 383 | 
            +
             | 
| 384 | 
            +
            |====
         | 
| 385 | 
            +
                  EOS
         | 
| 386 | 
            +
                  output = render_embedded_string input
         | 
| 387 | 
            +
                  assert_css 'table', output, 1
         | 
| 388 | 
            +
                  assert_css 'table > tbody > tr > th', output, 3
         | 
| 389 | 
            +
                  assert_css 'table > tbody > tr > td', output, 6
         | 
| 390 | 
            +
                  assert_css 'table > tbody > tr .header', output, 0
         | 
| 391 | 
            +
                  assert_css 'table > tbody > tr > td > p > strong', output, 3
         | 
| 392 | 
            +
                  assert_css 'table > tbody > tr > td > p > em', output, 3
         | 
| 393 | 
            +
                  assert_css 'table > tbody > tr > td > p > em > a', output, 1
         | 
| 394 | 
            +
                end
         | 
| 395 | 
            +
             | 
| 335 396 | 
             
                test 'supports horizontal and vertical source data with blank lines and table header' do
         | 
| 336 397 | 
             
                  input = <<-EOS
         | 
| 337 398 | 
             
            .Horizontal and vertical source data
         | 
| @@ -356,13 +417,13 @@ I am getting in shape! | |
| 356 417 | 
             
                  EOS
         | 
| 357 418 | 
             
                  output = render_embedded_string input
         | 
| 358 419 | 
             
                  assert_css 'table', output, 1
         | 
| 359 | 
            -
                  assert_css 'table[style*="width:80%"]', output, 1
         | 
| 420 | 
            +
                  assert_css 'table[style*="width: 80%"]', output, 1
         | 
| 360 421 | 
             
                  assert_xpath '/table/caption[@class="title"][text()="Table 1. Horizontal and vertical source data"]', output, 1
         | 
| 361 422 | 
             
                  assert_css 'table > colgroup > col', output, 4
         | 
| 362 | 
            -
                  assert_css 'table > colgroup > col:nth-child(1)[@style*="width:17%"]', output, 1
         | 
| 363 | 
            -
                  assert_css 'table > colgroup > col:nth-child(2)[@style*="width:11%"]', output, 1
         | 
| 364 | 
            -
                  assert_css 'table > colgroup > col:nth-child(3)[@style*="width:11%"]', output, 1
         | 
| 365 | 
            -
                  assert_css 'table > colgroup > col:nth-child(4)[@style*="width:58%"]', output, 1
         | 
| 423 | 
            +
                  assert_css 'table > colgroup > col:nth-child(1)[@style*="width: 17%"]', output, 1
         | 
| 424 | 
            +
                  assert_css 'table > colgroup > col:nth-child(2)[@style*="width: 11%"]', output, 1
         | 
| 425 | 
            +
                  assert_css 'table > colgroup > col:nth-child(3)[@style*="width: 11%"]', output, 1
         | 
| 426 | 
            +
                  assert_css 'table > colgroup > col:nth-child(4)[@style*="width: 58%"]', output, 1
         | 
| 366 427 | 
             
                  assert_css 'table > thead', output, 1
         | 
| 367 428 | 
             
                  assert_css 'table > thead > tr', output, 1
         | 
| 368 429 | 
             
                  assert_css 'table > thead > tr > th', output, 4
         | 
| @@ -377,7 +438,7 @@ I am getting in shape! | |
| 377 438 |  | 
| 378 439 | 
             
                test 'percentages as column widths' do
         | 
| 379 440 | 
             
                  input = <<-EOS
         | 
| 380 | 
            -
            [ | 
| 441 | 
            +
            [cols="<.^10%,<90%"]
         | 
| 381 442 | 
             
            |===
         | 
| 382 443 | 
             
            |column A |column B
         | 
| 383 444 | 
             
            |===
         | 
| @@ -385,8 +446,8 @@ I am getting in shape! | |
| 385 446 |  | 
| 386 447 | 
             
                  output = render_embedded_string input
         | 
| 387 448 | 
             
                  assert_xpath '/table/colgroup/col', output, 2
         | 
| 388 | 
            -
                  assert_xpath '(/table/colgroup/col)[1][@style="width:10%;"]', output, 1
         | 
| 389 | 
            -
                  assert_xpath '(/table/colgroup/col)[2][@style="width:90%;"]', output, 1
         | 
| 449 | 
            +
                  assert_xpath '(/table/colgroup/col)[1][@style="width: 10%;"]', output, 1
         | 
| 450 | 
            +
                  assert_xpath '(/table/colgroup/col)[2][@style="width: 90%;"]', output, 1
         | 
| 390 451 | 
             
                end
         | 
| 391 452 |  | 
| 392 453 | 
             
                test 'spans, alignments and styles' do
         | 
| @@ -401,7 +462,7 @@ d|9 2+>|10 | |
| 401 462 | 
             
                  EOS
         | 
| 402 463 | 
             
                  output = render_embedded_string input
         | 
| 403 464 | 
             
                  assert_css 'table', output, 1
         | 
| 404 | 
            -
                  assert_css 'table > colgroup > col[style*="width:25%"]', output, 4
         | 
| 465 | 
            +
                  assert_css 'table > colgroup > col[style*="width: 25%"]', output, 4
         | 
| 405 466 | 
             
                  assert_css 'table > tbody > tr', output, 4
         | 
| 406 467 | 
             
                  assert_css 'table > tbody > tr > td', output, 10
         | 
| 407 468 | 
             
                  assert_css 'table > tbody > tr:nth-child(1) > td', output, 4
         | 
| @@ -426,6 +487,22 @@ d|9 2+>|10 | |
| 426 487 | 
             
                  assert_css 'table > tbody > tr:nth-child(4) > td:nth-child(2).halign-right.valign-top[colspan="2"] p code', output, 1
         | 
| 427 488 | 
             
                end
         | 
| 428 489 |  | 
| 490 | 
            +
                test 'sets up columns correctly if first row has cell that spans columns' do
         | 
| 491 | 
            +
                  input = <<-EOS
         | 
| 492 | 
            +
            |===
         | 
| 493 | 
            +
            2+^|AAA |CCC
         | 
| 494 | 
            +
            |AAA |BBB |CCC
         | 
| 495 | 
            +
            |AAA |BBB |CCC
         | 
| 496 | 
            +
            |===
         | 
| 497 | 
            +
                  EOS
         | 
| 498 | 
            +
                  output = render_embedded_string input 
         | 
| 499 | 
            +
                  assert_css 'table > tbody > tr:nth-child(1) > td', output, 2
         | 
| 500 | 
            +
                  assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(1)[colspan="2"]', output, 1
         | 
| 501 | 
            +
                  assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(2):not([colspan])', output, 1
         | 
| 502 | 
            +
                  assert_css 'table > tbody > tr:nth-child(2) > td:not([colspan])', output, 3
         | 
| 503 | 
            +
                  assert_css 'table > tbody > tr:nth-child(3) > td:not([colspan])', output, 3
         | 
| 504 | 
            +
                end
         | 
| 505 | 
            +
             | 
| 429 506 | 
             
                test 'supports repeating cells' do
         | 
| 430 507 | 
             
                  input = <<-EOS
         | 
| 431 508 | 
             
            |===
         | 
| @@ -506,6 +583,54 @@ I wouldn't have it any other way. | |
| 506 583 | 
             
                  assert_equal 26, literal.text.lines.entries.size
         | 
| 507 584 | 
             
                end
         | 
| 508 585 |  | 
| 586 | 
            +
                test 'basic asciidoc cell' do
         | 
| 587 | 
            +
                  input = <<-EOS
         | 
| 588 | 
            +
            |===
         | 
| 589 | 
            +
            a|--
         | 
| 590 | 
            +
            NOTE: content
         | 
| 591 | 
            +
             | 
| 592 | 
            +
            content
         | 
| 593 | 
            +
            --
         | 
| 594 | 
            +
            |===
         | 
| 595 | 
            +
                  EOS
         | 
| 596 | 
            +
             | 
| 597 | 
            +
                  result = render_embedded_string input
         | 
| 598 | 
            +
                  assert_css 'table.tableblock', result, 1
         | 
| 599 | 
            +
                  assert_css 'table.tableblock td.tableblock', result, 1
         | 
| 600 | 
            +
                  assert_css 'table.tableblock td.tableblock .openblock', result, 1
         | 
| 601 | 
            +
                  assert_css 'table.tableblock td.tableblock .openblock .admonitionblock', result, 1
         | 
| 602 | 
            +
                  assert_css 'table.tableblock td.tableblock .openblock .paragraph', result, 1
         | 
| 603 | 
            +
                end
         | 
| 604 | 
            +
             | 
| 605 | 
            +
                test 'doctype can be set in asciidoc table cell' do
         | 
| 606 | 
            +
                  input = <<-EOS
         | 
| 607 | 
            +
            |===
         | 
| 608 | 
            +
            a|
         | 
| 609 | 
            +
            :doctype: inline
         | 
| 610 | 
            +
             | 
| 611 | 
            +
            content
         | 
| 612 | 
            +
            |===
         | 
| 613 | 
            +
                  EOS
         | 
| 614 | 
            +
             | 
| 615 | 
            +
                  result = render_embedded_string input
         | 
| 616 | 
            +
                  assert_css 'table.tableblock', result, 1
         | 
| 617 | 
            +
                  assert_css 'table.tableblock .paragraph', result, 0
         | 
| 618 | 
            +
                end
         | 
| 619 | 
            +
             | 
| 620 | 
            +
                test 'compat mode can be activated in asciidoc table cell' do
         | 
| 621 | 
            +
                  input = <<-EOS
         | 
| 622 | 
            +
            |===
         | 
| 623 | 
            +
            a|
         | 
| 624 | 
            +
            :compat-mode:
         | 
| 625 | 
            +
             | 
| 626 | 
            +
            'italic'
         | 
| 627 | 
            +
            |===
         | 
| 628 | 
            +
                  EOS
         | 
| 629 | 
            +
             | 
| 630 | 
            +
                  result = render_embedded_string input
         | 
| 631 | 
            +
                  assert_css 'table.tableblock td em', result, 1
         | 
| 632 | 
            +
                end
         | 
| 633 | 
            +
             | 
| 509 634 | 
             
                test 'asciidoc content' do
         | 
| 510 635 | 
             
                  input = <<-EOS
         | 
| 511 636 | 
             
            [cols="1e,1,5a",frame="topbot",options="header"]
         | 
| @@ -541,7 +666,7 @@ output file name is used. | |
| 541 666 | 
             
                  assert !body_cell_1_3.inner_document.nil?
         | 
| 542 667 | 
             
                  assert body_cell_1_3.inner_document.nested?
         | 
| 543 668 | 
             
                  assert_equal doc, body_cell_1_3.inner_document.parent_document
         | 
| 544 | 
            -
                  assert_equal doc. | 
| 669 | 
            +
                  assert_equal doc.converter, body_cell_1_3.inner_document.converter
         | 
| 545 670 | 
             
                  output = doc.render
         | 
| 546 671 |  | 
| 547 672 | 
             
                  assert_css 'table > tbody > tr', output, 2
         | 
| @@ -560,6 +685,35 @@ a|include::fixtures/include-file.asciidoc[] | |
| 560 685 | 
             
                  assert_match(/included content/, output)
         | 
| 561 686 | 
             
                end
         | 
| 562 687 |  | 
| 688 | 
            +
                test 'cross reference link in AsciiDoc-style table cell should resolve to reference in main document' do
         | 
| 689 | 
            +
                  input = <<-EOS
         | 
| 690 | 
            +
            == Some
         | 
| 691 | 
            +
             | 
| 692 | 
            +
            |===
         | 
| 693 | 
            +
            a|See <<_more>>
         | 
| 694 | 
            +
            |===
         | 
| 695 | 
            +
             | 
| 696 | 
            +
            == More
         | 
| 697 | 
            +
             | 
| 698 | 
            +
            content
         | 
| 699 | 
            +
                  EOS
         | 
| 700 | 
            +
             | 
| 701 | 
            +
                  result = render_string input
         | 
| 702 | 
            +
                  assert_xpath '//a[@href="#_more"]', result, 1
         | 
| 703 | 
            +
                  assert_xpath '//a[@href="#_more"][text()="More"]', result, 1
         | 
| 704 | 
            +
                end
         | 
| 705 | 
            +
             | 
| 706 | 
            +
                test 'footnotes should not be shared between AsciiDoc-style table cell and main document' do
         | 
| 707 | 
            +
                  input = <<-EOS
         | 
| 708 | 
            +
            |===
         | 
| 709 | 
            +
            a|AsciiDoc footnote:[A lightweight markup language.]
         | 
| 710 | 
            +
            |===
         | 
| 711 | 
            +
                  EOS
         | 
| 712 | 
            +
             | 
| 713 | 
            +
                  result = render_string input
         | 
| 714 | 
            +
                  assert_css '#_footnote_1', result, 1
         | 
| 715 | 
            +
                end
         | 
| 716 | 
            +
             | 
| 563 717 | 
             
                test 'nested table' do
         | 
| 564 718 | 
             
                  input = <<-EOS
         | 
| 565 719 | 
             
            [cols="1,2a"]
         | 
| @@ -611,10 +765,10 @@ plain | |
| 611 765 | 
             
                  EOS
         | 
| 612 766 |  | 
| 613 767 | 
             
                  output = render_embedded_string input
         | 
| 614 | 
            -
                  assert_xpath '(/table/thead/tr/th)[1][@style="background-color:green;"]', output, 1
         | 
| 615 | 
            -
                  assert_xpath '(/table/thead/tr/th)[2][@style="background-color:green;"]', output, 0
         | 
| 616 | 
            -
                  assert_xpath '(/table/tbody/tr/td)[1][@style="background-color:red;"]', output, 1
         | 
| 617 | 
            -
                  assert_xpath '(/table/tbody/tr/td)[2][@style="background-color:green;"]', output, 0
         | 
| 768 | 
            +
                  assert_xpath '(/table/thead/tr/th)[1][@style="background-color: green;"]', output, 1
         | 
| 769 | 
            +
                  assert_xpath '(/table/thead/tr/th)[2][@style="background-color: green;"]', output, 0
         | 
| 770 | 
            +
                  assert_xpath '(/table/tbody/tr/td)[1][@style="background-color: red;"]', output, 1
         | 
| 771 | 
            +
                  assert_xpath '(/table/tbody/tr/td)[2][@style="background-color: green;"]', output, 0
         | 
| 618 772 | 
             
                end
         | 
| 619 773 | 
             
              end
         | 
| 620 774 |  | 
| @@ -634,7 +788,7 @@ nobody:x:99:99:Nobody:/:/sbin/nologin | |
| 634 788 | 
             
                  EOS
         | 
| 635 789 | 
             
                  output = render_embedded_string input
         | 
| 636 790 | 
             
                  assert_css 'table', output, 1
         | 
| 637 | 
            -
                  assert_css 'table > colgroup > col[style*="width:14%"]', output, 7
         | 
| 791 | 
            +
                  assert_css 'table > colgroup > col[style*="width: 14%"]', output, 7
         | 
| 638 792 | 
             
                  assert_css 'table > tbody > tr', output, 6
         | 
| 639 793 | 
             
                  assert_xpath '//tr[4]/td[5]/p/text()', output, 0
         | 
| 640 794 | 
             
                  assert_xpath '//tr[3]/td[5]/p[text()="MySQL:Server"]', output, 1
         | 
| @@ -672,7 +826,7 @@ air, moon roof, loaded",4799.00 | |
| 672 826 | 
             
                  EOS
         | 
| 673 827 | 
             
                  output = render_embedded_string input 
         | 
| 674 828 | 
             
                  assert_css 'table', output, 1
         | 
| 675 | 
            -
                  assert_css 'table > colgroup > col[style*="width:20%"]', output, 5
         | 
| 829 | 
            +
                  assert_css 'table > colgroup > col[style*="width: 20%"]', output, 5
         | 
| 676 830 | 
             
                  assert_css 'table > thead > tr', output, 1
         | 
| 677 831 | 
             
                  assert_css 'table > tbody > tr', output, 4
         | 
| 678 832 | 
             
                  assert_xpath '((//tbody/tr)[1]/td)[4]/p[text()="ac, abs, moon"]', output, 1
         | 
| @@ -710,5 +864,25 @@ a;b;c | |
| 710 864 | 
             
                  assert_css 'table > tbody > tr:nth-child(1) > td', output, 3
         | 
| 711 865 | 
             
                  assert_css 'table > tbody > tr:nth-child(2) > td', output, 3
         | 
| 712 866 | 
             
                end
         | 
| 867 | 
            +
             | 
| 868 | 
            +
                test 'custom separator on AsciiDoc table cell' do
         | 
| 869 | 
            +
                  input = <<-EOS
         | 
| 870 | 
            +
            [cols=2,separator=!]
         | 
| 871 | 
            +
            |===
         | 
| 872 | 
            +
            !Pipe output to vim
         | 
| 873 | 
            +
            a!
         | 
| 874 | 
            +
            ----
         | 
| 875 | 
            +
            asciidoctor -o - -s test.adoc | view -
         | 
| 876 | 
            +
            ----
         | 
| 877 | 
            +
            |===
         | 
| 878 | 
            +
                  EOS
         | 
| 879 | 
            +
                  output = render_embedded_string input
         | 
| 880 | 
            +
                  assert_css 'table', output, 1
         | 
| 881 | 
            +
                  assert_css 'table > colgroup > col', output, 2
         | 
| 882 | 
            +
                  assert_css 'table > tbody > tr', output, 1
         | 
| 883 | 
            +
                  assert_css 'table > tbody > tr:nth-child(1) > td', output, 2
         | 
| 884 | 
            +
                  assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(1) p', output, 1
         | 
| 885 | 
            +
                  assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(2) .listingblock', output, 1
         | 
| 886 | 
            +
                end
         | 
| 713 887 | 
             
              end
         | 
| 714 888 | 
             
            end
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -1,19 +1,32 @@ | |
| 1 | 
            +
            ASCIIDOCTOR_PROJECT_DIR = File.dirname File.dirname(__FILE__)
         | 
| 2 | 
            +
            Dir.chdir ASCIIDOCTOR_PROJECT_DIR
         | 
| 3 | 
            +
             | 
| 1 4 | 
             
            if RUBY_VERSION < '1.9'
         | 
| 2 5 | 
             
              require 'rubygems'
         | 
| 3 6 | 
             
            end
         | 
| 4 | 
            -
            require 'fileutils'
         | 
| 5 | 
            -
            require 'pathname'
         | 
| 6 | 
            -
            require 'test/unit'
         | 
| 7 7 |  | 
| 8 | 
            -
            require  | 
| 8 | 
            +
            require File.join(ASCIIDOCTOR_PROJECT_DIR, 'lib', 'asciidoctor')
         | 
| 9 9 |  | 
| 10 | 
            +
            require 'minitest/autorun'
         | 
| 11 | 
            +
            require 'socket'
         | 
| 10 12 | 
             
            require 'nokogiri'
         | 
| 11 13 |  | 
| 14 | 
            +
            autoload :FileUtils, 'fileutils'
         | 
| 15 | 
            +
            autoload :Pathname,  'pathname'
         | 
| 16 | 
            +
             | 
| 12 17 | 
             
            ENV['SUPPRESS_DEBUG'] ||= 'true'
         | 
| 13 18 |  | 
| 14 19 | 
             
            RE_XMLNS_ATTRIBUTE = / xmlns="[^"]+"/
         | 
| 20 | 
            +
            RE_DOCTYPE = /\s*<!DOCTYPE (.*)/
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            if defined? Minitest::Test
         | 
| 23 | 
            +
              # We're on Minitest 5+. Nothing to do here.
         | 
| 24 | 
            +
            else
         | 
| 25 | 
            +
              # Minitest 4 doesn't have Minitest::Test yet.
         | 
| 26 | 
            +
              Minitest::Test = MiniTest::Unit::TestCase
         | 
| 27 | 
            +
            end
         | 
| 15 28 |  | 
| 16 | 
            -
            class Test | 
| 29 | 
            +
            class Minitest::Test
         | 
| 17 30 | 
             
              def windows?
         | 
| 18 31 | 
             
                RbConfig::CONFIG['host_os'] =~ /win|ming/
         | 
| 19 32 | 
             
              end
         | 
| @@ -23,7 +36,11 @@ class Test::Unit::TestCase | |
| 23 36 | 
             
              end
         | 
| 24 37 |  | 
| 25 38 | 
             
              def empty_document options = {}
         | 
| 26 | 
            -
                 | 
| 39 | 
            +
                if options[:parse]
         | 
| 40 | 
            +
                  (Asciidoctor::Document.new [], options).parse
         | 
| 41 | 
            +
                else
         | 
| 42 | 
            +
                  Asciidoctor::Document.new [], options
         | 
| 43 | 
            +
                end
         | 
| 27 44 | 
             
              end
         | 
| 28 45 |  | 
| 29 46 | 
             
              def empty_safe_document options = {}
         | 
| @@ -128,13 +145,10 @@ class Test::Unit::TestCase | |
| 128 145 | 
             
              end
         | 
| 129 146 |  | 
| 130 147 | 
             
              def xmldoc_from_string(content)
         | 
| 131 | 
            -
                 | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
                  else
         | 
| 136 | 
            -
                    doc = Nokogiri::HTML::DocumentFragment.parse(content)
         | 
| 137 | 
            -
                  end
         | 
| 148 | 
            +
                if content.match(RE_XMLNS_ATTRIBUTE)
         | 
| 149 | 
            +
                  doc = Nokogiri::XML::Document.parse(content)
         | 
| 150 | 
            +
                elsif !(doctype_match = content.match(RE_DOCTYPE))
         | 
| 151 | 
            +
                  doc = Nokogiri::HTML::DocumentFragment.parse(content)
         | 
| 138 152 | 
             
                elsif doctype_match[1].start_with? 'html'
         | 
| 139 153 | 
             
                  doc = Nokogiri::HTML::Document.parse(content)
         | 
| 140 154 | 
             
                else
         | 
| @@ -144,7 +158,11 @@ class Test::Unit::TestCase | |
| 144 158 |  | 
| 145 159 | 
             
              def document_from_string(src, opts = {})
         | 
| 146 160 | 
             
                assign_default_test_options opts
         | 
| 147 | 
            -
                 | 
| 161 | 
            +
                if opts[:parse]
         | 
| 162 | 
            +
                  (Asciidoctor::Document.new src.lines.entries, opts).parse
         | 
| 163 | 
            +
                else
         | 
| 164 | 
            +
                  Asciidoctor::Document.new src.lines.entries, opts
         | 
| 165 | 
            +
                end
         | 
| 148 166 | 
             
              end
         | 
| 149 167 |  | 
| 150 168 | 
             
              def block_from_string(src, opts = {})
         | 
| @@ -171,12 +189,13 @@ class Test::Unit::TestCase | |
| 171 189 | 
             
              end
         | 
| 172 190 |  | 
| 173 191 | 
             
              def parse_header_metadata(source)
         | 
| 174 | 
            -
                reader = Asciidoctor::Reader.new source. | 
| 175 | 
            -
                [Asciidoctor:: | 
| 192 | 
            +
                reader = Asciidoctor::Reader.new source.split ::Asciidoctor::EOL
         | 
| 193 | 
            +
                [::Asciidoctor::Parser.parse_header_metadata(reader), reader]
         | 
| 176 194 | 
             
              end
         | 
| 177 195 |  | 
| 178 196 | 
             
              def assign_default_test_options(opts)
         | 
| 179 | 
            -
                opts[:header_footer] = true unless opts. | 
| 197 | 
            +
                opts[:header_footer] = true unless opts.key? :header_footer
         | 
| 198 | 
            +
                opts[:parse] = true unless opts.key? :parse
         | 
| 180 199 | 
             
                if opts[:header_footer]
         | 
| 181 200 | 
             
                  # don't embed stylesheet unless test requests the default behavior
         | 
| 182 201 | 
             
                  if opts.has_key? :linkcss_default
         | 
| @@ -186,7 +205,10 @@ class Test::Unit::TestCase | |
| 186 205 | 
             
                    opts[:attributes]['linkcss'] = ''
         | 
| 187 206 | 
             
                  end
         | 
| 188 207 | 
             
                end
         | 
| 189 | 
            -
                 | 
| 208 | 
            +
                if (template_dir = ENV['TEMPLATE_DIR'])
         | 
| 209 | 
            +
                  opts[:template_dir] = template_dir unless opts.has_key? :template_dir
         | 
| 210 | 
            +
                  #opts[:template_dir] = File.join(File.dirname(__FILE__), '..', '..', 'asciidoctor-backends', 'erb') unless opts.has_key? :template_dir
         | 
| 211 | 
            +
                end
         | 
| 190 212 | 
             
                nil
         | 
| 191 213 | 
             
              end
         | 
| 192 214 |  | 
| @@ -254,30 +276,78 @@ class Test::Unit::TestCase | |
| 254 276 | 
             
                  $stderr = old_stderr
         | 
| 255 277 | 
             
                end
         | 
| 256 278 | 
             
              end
         | 
| 279 | 
            +
             | 
| 280 | 
            +
              def resolve_localhost
         | 
| 281 | 
            +
                (RUBY_VERSION < '1.9' || RUBY_ENGINE == 'rbx') ? Socket.gethostname :
         | 
| 282 | 
            +
                    Socket.ip_address_list.find {|addr| addr.ipv4? }.ip_address
         | 
| 283 | 
            +
              end
         | 
| 284 | 
            +
             | 
| 285 | 
            +
              def using_test_webserver host = resolve_localhost, port = 9876
         | 
| 286 | 
            +
                server = TCPServer.new host, port
         | 
| 287 | 
            +
                base_dir = File.expand_path File.dirname __FILE__
         | 
| 288 | 
            +
                t = Thread.new do
         | 
| 289 | 
            +
                  while (session = server.accept)
         | 
| 290 | 
            +
                    request = session.gets
         | 
| 291 | 
            +
                    resource = nil
         | 
| 292 | 
            +
                    if (m = /GET (\S+) HTTP\/1\.1$/.match(request.chomp))
         | 
| 293 | 
            +
                      resource = (resource = m[1]) == '' ? '.' : resource
         | 
| 294 | 
            +
                    else
         | 
| 295 | 
            +
                      session.print %(HTTP/1.1 405 Method Not Allowed\r\nContent-Type: text/plain\r\n\r\n)
         | 
| 296 | 
            +
                      session.print %(405 - Method not allowed\n)
         | 
| 297 | 
            +
                      session.close
         | 
| 298 | 
            +
                      break
         | 
| 299 | 
            +
                    end
         | 
| 300 | 
            +
                  
         | 
| 301 | 
            +
                    if resource == '/name/asciidoctor'
         | 
| 302 | 
            +
                      session.print %(HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n)
         | 
| 303 | 
            +
                      session.print %({"name": "asciidoctor"}\n)
         | 
| 304 | 
            +
                    elsif File.file?(resource_file = (File.join base_dir, resource))
         | 
| 305 | 
            +
                      mimetype = if (ext = ::File.extname(resource_file)[1..-1])
         | 
| 306 | 
            +
                        ext == 'adoc' ? 'text/plain' : %(image/#{ext})
         | 
| 307 | 
            +
                      else
         | 
| 308 | 
            +
                        'text/plain'
         | 
| 309 | 
            +
                      end
         | 
| 310 | 
            +
                      session.print %(HTTP/1.1 200 OK\r\nContent-Type: #{mimetype}\r\n\r\n)
         | 
| 311 | 
            +
                      File.open resource_file, 'rb' do |fd|
         | 
| 312 | 
            +
                        until fd.eof? do
         | 
| 313 | 
            +
                          buffer = fd.read 256
         | 
| 314 | 
            +
                          session.write buffer
         | 
| 315 | 
            +
                        end
         | 
| 316 | 
            +
                      end
         | 
| 317 | 
            +
                    else
         | 
| 318 | 
            +
                      session.print %(HTTP/1.1 404 File Not Found\r\nContent-Type: text/plain\r\n\r\n)
         | 
| 319 | 
            +
                      session.print %(404 - Resource not found.\n)
         | 
| 320 | 
            +
                    end
         | 
| 321 | 
            +
                    session.close
         | 
| 322 | 
            +
                  end
         | 
| 323 | 
            +
                end
         | 
| 324 | 
            +
                begin
         | 
| 325 | 
            +
                  yield
         | 
| 326 | 
            +
                ensure
         | 
| 327 | 
            +
                  begin
         | 
| 328 | 
            +
                    server.shutdown
         | 
| 329 | 
            +
                  # "Errno::ENOTCONN: Socket is not connected' is reported on some platforms; call #close instead of #shutdown
         | 
| 330 | 
            +
                  rescue Errno::ENOTCONN
         | 
| 331 | 
            +
                    server.close
         | 
| 332 | 
            +
                  end
         | 
| 333 | 
            +
                  t.exit
         | 
| 334 | 
            +
                end
         | 
| 335 | 
            +
              end
         | 
| 257 336 | 
             
            end
         | 
| 258 337 |  | 
| 259 338 | 
             
            ###
         | 
| 260 339 | 
             
            # 
         | 
| 261 | 
            -
            # Context goodness provided by @citrusbyte's contest
         | 
| 340 | 
            +
            # Context goodness provided by @citrusbyte's contest.
         | 
| 341 | 
            +
            # See https://github.com/citrusbyte/contest
         | 
| 262 342 | 
             
            #
         | 
| 263 343 | 
             
            ###
         | 
| 264 344 |  | 
| 265 | 
            -
            # Test::Unit loads a default test if the suite is empty, whose purpose is to
         | 
| 266 | 
            -
            # fail. Since having empty contexts is a common practice, we decided to
         | 
| 267 | 
            -
            # overwrite TestSuite#empty? in order to allow them. Having a failure when no
         | 
| 268 | 
            -
            # tests have been defined seems counter-intuitive.
         | 
| 269 | 
            -
            class Test::Unit::TestSuite
         | 
| 270 | 
            -
              def empty?
         | 
| 271 | 
            -
                false
         | 
| 272 | 
            -
              end
         | 
| 273 | 
            -
            end
         | 
| 274 | 
            -
             | 
| 275 345 | 
             
            # Contest adds +teardown+, +test+ and +context+ as class methods, and the
         | 
| 276 346 | 
             
            # instance methods +setup+ and +teardown+ now iterate on the corresponding
         | 
| 277 347 | 
             
            # blocks. Note that all setup and teardown blocks must be defined with the
         | 
| 278 348 | 
             
            # block syntax. Adding setup or teardown instance methods defeats the purpose
         | 
| 279 349 | 
             
            # of this library.
         | 
| 280 | 
            -
            class Test | 
| 350 | 
            +
            class Minitest::Test
         | 
| 281 351 | 
             
              def self.setup(&block)
         | 
| 282 352 | 
             
                define_method :setup do
         | 
| 283 353 | 
             
                  super(&block)
         | 
| @@ -330,5 +400,5 @@ private | |
| 330 400 | 
             
            end
         | 
| 331 401 |  | 
| 332 402 | 
             
            def context(*name, &block)
         | 
| 333 | 
            -
              Test | 
| 403 | 
            +
              Minitest::Test.context(name, &block)
         | 
| 334 404 | 
             
            end
         |