Skip to content

Commit

Permalink
drop skipped content inside a delimited block
Browse files Browse the repository at this point in the history
- drop skipped content inside of creating empty paragraphs
- add missing test for scenario
  • Loading branch information
mojavelinux committed Jul 17, 2017
1 parent bc004af commit cdd8ead
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/asciidoctor/parser.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions test/blocks_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit cdd8ead

Please sign in to comment.