Skip to content

Commit

Permalink
Fix for wrapped child nodes only writing the first child (#87)
Browse files Browse the repository at this point in the history
* Fix an issue where a wrapper div with several children would write only the first child
  • Loading branch information
jmouka authored Dec 2, 2022
1 parent fa6cb61 commit 379cd9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
evernote2md
notes/
12 changes: 5 additions & 7 deletions internal/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ func (*ExtraDiv) ReplaceTag(n *html.Node) {
if hasExtraDiv(n) {
wrapper := n.FirstChild
if wrapper != nil && wrapper.Data == "div" {
content := wrapper.FirstChild
if content == nil {
return
}
wrapper.RemoveChild(content)
if content.Data != "br" || content.FirstChild != nil {
n.AppendChild(content)
for c := wrapper.FirstChild; c != nil; c = wrapper.FirstChild {
wrapper.RemoveChild(c)
if c.Data != "br" {
n.AppendChild(c)
}
}
n.RemoveChild(wrapper)
}
Expand Down

0 comments on commit 379cd9c

Please sign in to comment.