From afe1638da8696b0abeae50bbcecda2d4c51b8a0f Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sat, 20 Apr 2013 18:48:51 -0600 Subject: resolves #260 use code element instead of tt - perform macro sustitution on email in document header --- README.asciidoc | 7 ++++++- lib/asciidoctor/backends/html5.rb | 4 ++-- test/attributes_test.rb | 2 +- test/document_test.rb | 2 +- test/lists_test.rb | 2 +- test/substitutions_test.rb | 10 +++++----- test/tables_test.rb | 6 +++--- test/text_test.rb | 10 +++++----- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index c91f3790..11612614 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -219,9 +219,14 @@ Here are the known cases where Asciidoctor differs from AsciiDoc: * Asciidoctor strips XML entities from the section title before generating the id (makes for cleaner section ids) -* Asciidoctor use ++ instead of ++ around +* Asciidoctor uses ++ instead of ++ around inline literal text in the HTML backend +* Asciidoctor does not wrap email next to author name in header in + angle brackets + +* Asciidoctor allows email field to be a URL and renders it as such + * Asciidoctor is much more lenient about attribute list parsing (double quotes are rarely needed, though you may want to keep them for compatibility) diff --git a/lib/asciidoctor/backends/html5.rb b/lib/asciidoctor/backends/html5.rb index ad3b823d..e40c77e9 100644 --- a/lib/asciidoctor/backends/html5.rb +++ b/lib/asciidoctor/backends/html5.rb @@ -105,7 +105,7 @@ pre code { background-color: #F8F8F8; padding: 0; }

<%= @header.title %>

<% end %> <% if attr? :author %><%= attr :author %>
- <% if attr? :email %><<%= attr :email %>>
<% end %><% end %> + <% if attr? :email %><%= sub_macros(attr :email) %>
<% end %><% end %> <% if attr? :revnumber %>version <%= attr :revnumber %><%= attr?(:revdate) ? ',' : '' %><% end %> <% if attr? :revdate %><%= attr :revdate %><% end %> <% if attr? :revremark %>
<%= attr :revremark %><% end %> @@ -618,7 +618,7 @@ class InlineQuotedTemplate < BaseTemplate QUOTED_TAGS = { :emphasis => ['', ''], :strong => ['', ''], - :monospaced => ['', ''], + :monospaced => ['', ''], :superscript => ['', ''], :subscript => ['', ''], :double => ['“', '”'], diff --git a/test/attributes_test.rb b/test/attributes_test.rb index fb13fe27..c2152d44 100644 --- a/test/attributes_test.rb +++ b/test/attributes_test.rb @@ -227,7 +227,7 @@ preamble To use {gem_name}, the first thing to do is to import it in your Ruby source file. EOS output = render_embedded_string input - assert_xpath '//*[@class="title"]/tt[text()="asciidoctor"]', output, 1 + assert_xpath '//*[@class="title"]/code[text()="asciidoctor"]', output, 1 end test 'renders attribute until it is deleted' do diff --git a/test/document_test.rb b/test/document_test.rb index c8234eac..6c932a7f 100644 --- a/test/document_test.rb +++ b/test/document_test.rb @@ -434,7 +434,7 @@ more info... EOS output = render_string input assert_xpath '//*[@id="header"]/span[@id="author"][text() = "Stuart Rackham"]', output, 1 - assert_xpath '//*[@id="header"]/span[@id="email"][contains(text(), "founder@asciidoc.org")]', output, 1 + assert_xpath '//*[@id="header"]/span[@id="email"]/a[@href="mailto:founder@asciidoc.org"][text() = "founder@asciidoc.org"]', output, 1 assert_xpath '//*[@id="header"]/span[@id="revnumber"][text() = "version 8.6.8,"]', output, 1 assert_xpath '//*[@id="header"]/span[@id="revdate"][text() = "2012-07-12"]', output, 1 assert_xpath '//*[@id="header"]/span[@id="revremark"][text() = "See changelog."]', output, 1 diff --git a/test/lists_test.rb b/test/lists_test.rb index 3ca002b3..11e7e855 100644 --- a/test/lists_test.rb +++ b/test/lists_test.rb @@ -472,7 +472,7 @@ List assert_xpath '//ul/li', output, 3 assert_xpath '(//ul/li)[1]//strong', output, 1 assert_xpath '(//ul/li)[2]//em', output, 1 - assert_xpath '(//ul/li)[3]//tt', output, 1 + assert_xpath '(//ul/li)[3]//code', output, 1 end test "attribute substitutions" do diff --git a/test/substitutions_test.rb b/test/substitutions_test.rb index 7b5c28fb..4db8146f 100644 --- a/test/substitutions_test.rb +++ b/test/substitutions_test.rb @@ -158,7 +158,7 @@ context 'Substitutions' do test 'single-line constrained monospaced string' do para = block_from_string(%q{`a few <\{monospaced\}> words`}) # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough - assert_equal 'a few <{monospaced}> words', para.apply_normal_subs(para.buffer) + assert_equal 'a few <{monospaced}> words', para.apply_normal_subs(para.buffer) end test 'escaped single-line constrained monospaced string' do @@ -170,7 +170,7 @@ context 'Substitutions' do test 'multi-line constrained monospaced string' do para = block_from_string(%Q{`a few\n<\{monospaced\}> words`}) # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough - assert_equal "a few\n<{monospaced}> words", para.apply_normal_subs(para.buffer) + assert_equal "a few\n<{monospaced}> words", para.apply_normal_subs(para.buffer) end test 'single-line unconstrained strong chars' do @@ -231,17 +231,17 @@ context 'Substitutions' do test 'single-line unconstrained monospaced chars' do para = block_from_string(%q{Git++Hub++}) - assert_equal 'GitHub', para.sub_quotes(para.buffer.join) + assert_equal 'GitHub', para.sub_quotes(para.buffer.join) end test 'escaped single-line unconstrained monospaced chars' do para = block_from_string(%q{Git\++Hub++}) - assert_equal 'Git+Hub+', para.sub_quotes(para.buffer.join) + assert_equal 'Git+Hub+', para.sub_quotes(para.buffer.join) end test 'multi-line unconstrained monospaced chars' do para = block_from_string(%Q{Git++\nH\nu\nb++}) - assert_equal "Git\nH\nu\nb", para.sub_quotes(para.buffer.join) + assert_equal "Git\nH\nu\nb", para.sub_quotes(para.buffer.join) end test 'single-line superscript chars' do diff --git a/test/tables_test.rb b/test/tables_test.rb index 5ccb92e2..b8e15783 100644 --- a/test/tables_test.rb +++ b/test/tables_test.rb @@ -279,14 +279,14 @@ d|9 2+>|10 assert_css 'table tr:nth-child(1) > td:nth-child(4).halign-right.valign-top p strong', output, 1 assert_css 'table tr:nth-child(2) > td:nth-child(1).halign-center.valign-top p em', output, 1 - assert_css 'table tr:nth-child(2) > td:nth-child(2).halign-center.valign-middle[colspan="2"][rowspan="2"] p tt', output, 1 - assert_css 'table tr:nth-child(2) > td:nth-child(3).halign-left.valign-bottom[rowspan="3"] p tt', output, 1 + assert_css 'table tr:nth-child(2) > td:nth-child(2).halign-center.valign-middle[colspan="2"][rowspan="2"] p code', output, 1 + assert_css 'table tr:nth-child(2) > td:nth-child(3).halign-left.valign-bottom[rowspan="3"] p code', output, 1 assert_css 'table tr:nth-child(3) > td:nth-child(1).halign-center.valign-top p em', output, 1 assert_css 'table tr:nth-child(4) > td:nth-child(1).halign-left.valign-top p', output, 1 assert_css 'table tr:nth-child(4) > td:nth-child(1).halign-left.valign-top p em', output, 0 - assert_css 'table tr:nth-child(4) > td:nth-child(2).halign-right.valign-top[colspan="2"] p tt', output, 1 + assert_css 'table tr:nth-child(4) > td:nth-child(2).halign-right.valign-top[colspan="2"] p code', output, 1 end test 'supports repeating cells' do diff --git a/test/text_test.rb b/test/text_test.rb index daa87ea9..9f4cc8b3 100644 --- a/test/text_test.rb +++ b/test/text_test.rb @@ -89,7 +89,7 @@ context "Text" do end test "backtick-escaped text followed by single-quoted text" do - assert_match(/foo<\/tt>/, render_string(%Q(run `foo` 'dog'))) + assert_match(/foo<\/code>/, render_string(%Q(run `foo` 'dog'))) end context "basic styling" do @@ -106,7 +106,7 @@ context "Text" do end test "monospaced" do - assert_xpath "//tt", @rendered + assert_xpath "//code", @rendered end test "superscript" do @@ -118,21 +118,21 @@ context "Text" do end test "backticks" do - assert_xpath "//tt", render_string("This is `totally cool`.") + assert_xpath "//code", render_string("This is `totally cool`.") end test "nested styles" do rendered = render_string("Winning *big _time_* in the +city *boyeeee*+.") assert_xpath "//strong/em", rendered - assert_xpath "//tt/strong", rendered + assert_xpath "//code/strong", rendered end test "unconstrained quotes" do rendered_chars = render_string("**B**__I__++M++") assert_xpath "//strong", rendered_chars assert_xpath "//em", rendered_chars - assert_xpath "//tt", rendered_chars + assert_xpath "//code", rendered_chars end end end -- cgit v1.2.3