summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2023-04-22 23:13:27 -0600
committerGitHub <noreply@github.com>2023-04-22 23:13:27 -0600
commit0ef6afea4ea85faa3e5591717683bbac04b3d8b2 (patch)
tree65b2a23ed169ec7c777c5e593674bb1268dc2849 /lib
parent4a70aa35b6942136e5238bd3d568b7ae9927b716 (diff)
resolves #4268 implicitly attach nested list that starts with block attribute lines to dlist entry (PR #4439)
Diffstat (limited to 'lib')
-rw-r--r--lib/asciidoctor/parser.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb
index fe78b229..bb7f29fe 100644
--- a/lib/asciidoctor/parser.rb
+++ b/lib/asciidoctor/parser.rb
@@ -1443,11 +1443,26 @@ class Parser
# we're being more strict here about the terminator, but I think that's a good thing
buffer.concat reader.read_lines_until terminator: match.terminator, read_last_line: true, context: nil
continuation = :inactive
- # technically BlockAttributeLineRx only breaks if ensuing line is not a list item
- # which really means BlockAttributeLineRx only breaks if it's acting as a block delimiter
- # FIXME to be AsciiDoc compliant, we shouldn't break if style in attribute line is "literal" (i.e., [literal])
+ # BlockAttributeLineRx only breaks dlist if ensuing line is not a list item
elsif dlist && continuation != :active && (BlockAttributeLineRx.match? this_line)
- break
+ block_attribute_lines = [this_line]
+ while (next_line = reader.peek_line)
+ if is_delimited_block? next_line
+ interrupt = true
+ elsif next_line.empty? || ((next_line.start_with? '[') && (BlockAttributeLineRx.match? next_line))
+ block_attribute_lines << reader.read_line
+ next
+ elsif (AnyListRx.match? next_line) && !(is_sibling_list_item? next_line, list_type, sibling_trait)
+ buffer.concat block_attribute_lines
+ else # rubocop:disable Lint/DuplicateBranch
+ interrupt = true
+ end
+ break
+ end
+ if interrupt
+ reader.unshift_lines block_attribute_lines
+ break
+ end
elsif continuation == :active && !this_line.empty?
# literal paragraphs have special considerations (and this is one of
# two entry points into one)