Skip to content

Commit

Permalink
Fix bug in delete_until logic in replace_section.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 17, 2023
1 parent 878ccd4 commit 03d0723
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/markly/node.rb
Expand Up @@ -100,7 +100,7 @@ def delete_until
def replace_section(new_node, replace_header: true, remove_subsections: true)
# Delete until the next heading:
self.next&.delete_until do |node|
node.type == :heading && (!remove_subsections || node.header_level <= self.header_level)
node.type == :header && (!remove_subsections || node.header_level <= self.header_level)
end

self.append_after(new_node) if new_node
Expand Down
2 changes: 1 addition & 1 deletion test/markly/node.rb
Expand Up @@ -216,7 +216,7 @@

it "can replace a section and subsections" do
document.find_header("Heading").replace_section(new_document.first_child, remove_subsections: false)
expect(document.to_html).to be == "<h3>New Heading</h3>\n"
expect(document.to_html).to be == "<h3>New Heading</h3>\n<h2>Subheading</h2>\n"
end
end
end

0 comments on commit 03d0723

Please sign in to comment.