From cdd8ead3cc73382e3388556759900401d2129575 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 16 Jul 2017 23:15:02 -0600 Subject: [PATCH] drop skipped content inside a delimited block - drop skipped content inside of creating empty paragraphs - add missing test for scenario --- lib/asciidoctor/parser.rb | 10 +++++----- test/blocks_test.rb | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb index 775b079080..85fcf10ba7 100644 --- a/lib/asciidoctor/parser.rb +++ b/lib/asciidoctor/parser.rb @@ -444,13 +444,12 @@ def self.next_block(reader, parent, attributes = {}, options = {}) if options.fetch :parse_metadata, true # read lines until there are no more metadata lines to read while parse_block_metadata_line reader, document, attributes, options + # discard the line just processed advanced = reader.advance + reader.skip_blank_lines end - if advanced && !reader.has_more_lines? - # NOTE there are no cases when these attributes are used, but clear them anyway - attributes.clear - return - end + # QUESTION should we clear the attributes? + return if advanced && !reader.has_more_lines? end if (extensions = document.extensions) @@ -719,6 +718,7 @@ def self.next_block(reader, parent, attributes = {}, options = {}) if in_list && lines.empty? # call advance since the reader preserved the last line reader.advance + # QUESTION should we clear attributes? return end diff --git a/test/blocks_test.rb b/test/blocks_test.rb index e921f2d0c4..22a868285a 100644 --- a/test/blocks_test.rb +++ b/test/blocks_test.rb @@ -85,6 +85,23 @@ assert_xpath '//p', output, 2 end + test 'comment block between paragraphs offset by blank lines inside delimited block' do + input = <<-EOS +==== +first paragraph + +//// +block comment +//// + +second paragraph +==== + EOS + output = render_embedded_string input + refute_match(/block comment/, output) + assert_xpath '//p', output, 2 + end + test 'adjacent comment block between paragraphs' do input = <<-EOS first paragraph