Skip to content

Commit

Permalink
backport fix for #4565 don't duplicate block attribute line above det…
Browse files Browse the repository at this point in the history
…ached block that breaks a dlist
  • Loading branch information
mojavelinux committed May 6, 2024
1 parent 63cc47c commit 4cbef6c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Expand Up @@ -21,6 +21,7 @@ This project utilizes semantic versioning.
Bug Fixes::

* Don't leave behind empty line inside skipped preprocessor conditional (#4580)
* Don't duplicate block attribute line above detached block that breaks a dlist; fixes duplicate role on detached block (#4565)

== 2.0.22 (2024-03-08) - @mojavelinux

Expand Down
1 change: 1 addition & 0 deletions lib/asciidoctor/parser.rb
Expand Up @@ -1476,6 +1476,7 @@ def self.read_lines_for_list_item(reader, list_type, sibling_trait = nil, has_te
break
end
if interrupt
this_line = nil
reader.unshift_lines block_attribute_lines
break
end
Expand Down
34 changes: 32 additions & 2 deletions test/lists_test.rb
Expand Up @@ -4204,7 +4204,23 @@ def 1
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="exampleblock"]//p[text()="detached"]', output, 1
end

test 'attribute line breaks list even when term has no inline description' do
test 'block attribute line above delimited block that breaks a dlist is not duplicated' do
input = <<~'EOS'
== Lists
term:: desc
[.rolename]
----
detached
----
EOS

output = convert_string_to_embedded input
assert_xpath '//*[@class="dlist"]/dl', output, 1
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="listingblock rolename"]', output, 1
end

test 'block attribute line above paragraph breaks list even when term has no inline description' do
input = <<~'EOS'
== Lists
Expand All @@ -4220,7 +4236,21 @@ def 1
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="verseblock"]/pre[text()="detached"]', output, 1
end

test 'id line breaks list even when term has no inline description' do
test 'block attribute line above paragraph that breaks a dlist is not duplicated' do
input = <<~'EOS'
== Lists
term:: desc
[.rolename]
detached
EOS

output = convert_string_to_embedded input
assert_xpath '//*[@class="dlist"]/dl', output, 1
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph rolename"]', output, 1
end

test 'block anchor line breaks list even when term has no inline description' do
input = <<~'EOS'
== Lists
Expand Down

0 comments on commit 4cbef6c

Please sign in to comment.