summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2014-06-16 21:13:51 -0500
committerDan Allen <dan.j.allen@gmail.com>2014-06-16 21:15:46 -0500
commit5a312b3ea4ba81ad179857270ec7101b1a31209c (patch)
treece1a723830ac6b0ed0a43adb1edb477db1e97d8c
parenta04713bfe582d0e0c1e5e5be91fc45d2e63ea7e9 (diff)
resolves #971 top-level content must be wrapped inside preamble in book doctype
-rw-r--r--lib/asciidoctor/parser.rb6
-rw-r--r--test/document_test.rb3
2 files changed, 4 insertions, 5 deletions
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb
index 45f1a516..c2033f40 100644
--- a/lib/asciidoctor/parser.rb
+++ b/lib/asciidoctor/parser.rb
@@ -223,9 +223,8 @@ class Parser
# that we are at a section title (so we don't have to check)
if parent.context == :document && parent.blocks.empty? &&
((has_header = parent.has_header?) || attributes.delete('invalid-header') || !is_next_line_section?(reader, attributes))
-
doctype = parent.doctype
- if has_header
+ if has_header || (doctype == 'book' && attributes[1] != 'abstract')
preamble = intro = Block.new(parent, :preamble, :content_model => :compound)
parent << preamble
end
@@ -360,8 +359,7 @@ class Parser
document = parent
if preamble.blocks?
# unwrap standalone preamble (i.e., no sections), if permissible
- if Compliance.unwrap_standalone_preamble && document.blocks.size == 1 &&
- (doctype != 'book' || preamble.blocks[0].style != 'abstract')
+ if Compliance.unwrap_standalone_preamble && document.blocks.size == 1 && doctype != 'book'
document.blocks.shift
while (child_block = preamble.blocks.shift)
child_block.parent = document
diff --git a/test/document_test.rb b/test/document_test.rb
index e4834f84..ecb8b361 100644
--- a/test/document_test.rb
+++ b/test/document_test.rb
@@ -1358,7 +1358,8 @@ chapter body
result = render_string('text', :attributes => {'backend' => 'docbook45', 'doctype' => 'book'})
assert_xpath '/book', result, 1
assert_xpath '/book/bookinfo/date', result, 1
- assert_xpath '/book/simpara[text() = "text"]', result, 1
+ # NOTE simpara cannot be a direct child of book, so content must be treated as a preface
+ assert_xpath '/book/preface/simpara[text() = "text"]', result, 1
end
test 'docbook45 backend doctype book no xmlns' do