From 41b3e781d585bcdc048bc3dcd2bc67b9b81ced5d Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 15 Apr 2018 02:08:38 -0600 Subject: rephrase warning message about using level 0 sections when the doctype is not book --- CHANGELOG.adoc | 1 + lib/asciidoctor/parser.rb | 4 ++-- test/blocks_test.rb | 2 +- test/sections_test.rb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 8e318865..af04b35e 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -113,6 +113,7 @@ Improvements / Refactoring:: * automatically assign parent reference when adding node to parent (#2398, PR #2403) * leave inline anchor in section title as is if section has ID (#2243, PR #2427) * align and improve error message about invalid use of partintro between HTML5 and DocBook converters + * rephrase warning when level 0 sections are found and the doctype is not book * only warn if thread_safe gem is missing when using built-in template cache * rename enumerate_section to assign_numeral; update API docs * drop deprecated compact option from CLI; remove from manpage diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb index 9116eff2..b307d5bf 100644 --- a/lib/asciidoctor/parser.rb +++ b/lib/asciidoctor/parser.rb @@ -325,7 +325,7 @@ class Parser next_level += document.attr('leveloffset').to_i if document.attr?('leveloffset') if next_level > current_level || (next_level == 0 && section.context == :document) if next_level == 0 && doctype != 'book' - logger.error message_with_context 'only book doctypes can contain level 0 sections', :source_location => reader.cursor + logger.error message_with_context 'level 0 sections can only be used when doctype is book', :source_location => reader.cursor elsif expected_next_levels && !expected_next_levels.include?(next_level) logger.warn message_with_context %(section title out of sequence: expected #{expected_next_levels.size > 1 ? 'levels' : 'level'} #{expected_next_levels * ' or '}, got level #{next_level}), :source_location => reader.cursor end @@ -335,7 +335,7 @@ class Parser section.blocks << new_section else if next_level == 0 && doctype != 'book' - logger.error message_with_context 'only book doctypes can contain level 0 sections', :source_location => reader.cursor + logger.error message_with_context 'level 0 sections can only be used when doctype is book', :source_location => reader.cursor end # close this section (and break out of the nesting) to begin a new one break diff --git a/test/blocks_test.rb b/test/blocks_test.rb index 7a5aecac..30fd0f59 100644 --- a/test/blocks_test.rb +++ b/test/blocks_test.rb @@ -1638,7 +1638,7 @@ section paragraph assert_xpath '//*[@id="content"]/h1[text()="Section Title"]', output, 1 assert_xpath '//*[@class="paragraph"]', output, 1 assert_xpath '//*[@class="paragraph"]/*[@class="title"][text()="Block title"]', output, 1 - assert_message @logger, :ERROR, ': line 2: only book doctypes can contain level 0 sections', Hash + assert_message @logger, :ERROR, ': line 2: level 0 sections can only be used when doctype is book', Hash end test 'block title above document title gets carried over to first block in first section if no preamble' do diff --git a/test/sections_test.rb b/test/sections_test.rb index 0329e182..39a988b7 100644 --- a/test/sections_test.rb +++ b/test/sections_test.rb @@ -868,7 +868,7 @@ text in standalone using_memory_logger do |logger| render_string input - assert_message logger, :ERROR, ': line 7: only book doctypes can contain level 0 sections', Hash + assert_message logger, :ERROR, ': line 7: level 0 sections can only be used when doctype is book', Hash end end -- cgit v1.2.3