summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2013-06-27 00:16:20 -0700
committerDan Allen <dan.j.allen@gmail.com>2013-06-27 00:16:20 -0700
commitf620bfd8e6fe8c483bf47fe69e52dc6608927f78 (patch)
tree77469a4a31fa298cea8c410c2f962bd9f675b1de
parent8d3d80f3bef205bd5f02ebd188915c2b3a89f987 (diff)
parent76f19674e1eabdf6c973a7dcbeafc89ad6615599 (diff)
Merge pull request #459 from mojavelinux/showtitle
resolves #457 honor showtitle attribute as alternate to notitle!
-rw-r--r--lib/asciidoctor/document.rb2
-rw-r--r--test/document_test.rb27
2 files changed, 26 insertions, 3 deletions
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb
index fa7aa586..a18cc603 100644
--- a/lib/asciidoctor/document.rb
+++ b/lib/asciidoctor/document.rb
@@ -428,7 +428,7 @@ class Document < AbstractBlock
end
def notitle
- @attributes.has_key? 'notitle'
+ !@attributes.has_key?('showtitle') && @attributes.has_key?('notitle')
end
def noheader
diff --git a/test/document_test.rb b/test/document_test.rb
index d7224684..bcd18c24 100644
--- a/test/document_test.rb
+++ b/test/document_test.rb
@@ -871,8 +871,31 @@ content
assert_xpath '/*[@id="preamble"]', result, 1
end
- test 'enable title when no header footer' do
- result = render_string("= Title\n\npreamble", :header_footer => false, :attributes => {'notitle!' => ''})
+ test 'enable title in embedded document by unassigning notitle attribute' do
+ input = <<-EOS
+= Document Title
+
+content
+ EOS
+
+ result = render_string input, :header_footer => false, :attributes => {'notitle!' => ''}
+ assert_xpath '/html', result, 0
+ assert_xpath '/h1', result, 1
+ assert_xpath '/*[@id="header"]', result, 0
+ assert_xpath '/*[@id="footer"]', result, 0
+ assert_xpath '/*[@id="preamble"]', result, 1
+ assert_xpath '(/*)[1]/self::h1', result, 1
+ assert_xpath '(/*)[2]/self::*[@id="preamble"]', result, 1
+ end
+
+ test 'enable title in embedded document by assigning showtitle attribute' do
+ input = <<-EOS
+= Document Title
+
+content
+ EOS
+
+ result = render_string input, :header_footer => false, :attributes => {'showtitle' => ''}
assert_xpath '/html', result, 0
assert_xpath '/h1', result, 1
assert_xpath '/*[@id="header"]', result, 0