test/links_test.rb in asciidoctor-0.0.9 vs test/links_test.rb in asciidoctor-0.1.0

- old
+ new

@@ -48,18 +48,30 @@ test 'escaped inline qualified url using macro syntax should not create link' do assert_xpath '//a', render_string('\http://asciidoc.org[AsciiDoc] is the key to good docs.'), 0 end + test 'inline qualified url followed by an endline should not include endline in link' do + assert_xpath '//a[@href="http://github.com/asciidoctor"]', render_string("The source code for Asciidoctor can be found at http://github.com/asciidoctor\nwhich is a GitHub organization."), 1 + end + + test 'qualified url divided by endline using macro syntax should not create link' do + assert_xpath '//a', render_string("The source code for Asciidoctor can be found at link:http://github.com/asciidoctor\n[]which is a GitHub organization."), 0 + end + test 'qualified url containing whitespace using macro syntax should not create link' do assert_xpath '//a', render_string('I often need to refer to the chapter on link:http://asciidoc.org?q=attribute references[Attribute References].'), 0 end test 'qualified url containing an encoded space using macro syntax should create a link' do assert_xpath '//a', render_string('I often need to refer to the chapter on link:http://asciidoc.org?q=attribute%20references[Attribute References].'), 1 end + test 'inline quoted qualified url should not consume surrounding angled brackets' do + assert_xpath '//a[@href="http://github.com/asciidoctor"]', render_string('Asciidoctor GitHub organization: <**http://github.com/asciidoctor**>'), 1 + end + test 'inline ref' do doc = document_from_string 'Here you can read about tigers.[[tigers]]' output = doc.render assert_equal '[tigers]', doc.references[:ids]['tigers'] assert_xpath '//a[@id = "tigers"]', output, 1 @@ -128,9 +140,27 @@ end test 'xref creates link for unknown reference' do doc = document_from_string '<<tigers>>' assert_xpath '//a[@href="#tigers"][text() = "[tigers]"]', doc.render, 1 + end + + test 'xref shows label from title of target for forward and backward references in html backend' do + input = <<-EOS +== Section A + +<\<_section_b>> + +== Section B + +<\<_section_a>> + EOS + + output = render_embedded_string input + assert_xpath '//h2[@id="_section_a"][text()="Section A"]', output, 1 + assert_xpath '//a[@href="#_section_a"][text()="Section A"]', output, 1 + assert_xpath '//h2[@id="_section_b"][text()="Section B"]', output, 1 + assert_xpath '//a[@href="#_section_b"][text()="Section B"]', output, 1 end test 'anchor creates reference' do doc = document_from_string "[[tigers]]Tigers roam here." assert_equal({'tigers' => '[tigers]'}, doc.references[:ids])