lambdasoup
lambdasoup copied to clipboard
Make it possible to clone a node
In some HTML manipulation tasks, you need to create a copy of a node without deleting the original.
For example, if you are making a page ToC, you need to take the content of the original <h*>
tag and insert it into a link to that header. Now if you do let e = Soup.select_one "someselector" in Soup.append_child e p
, e
will be moved to p
.
Unless I'm missing something, there's no way to do it now other than to convert a node to string and then parse it back.
That's right, there is no other way right now.
Are there any fundamental difficulties, or it's a matter of just getting it done?
Got any pointers for diving into the source?
I don't think there are any fundamental obstacles. You're welcome to ask here if you have any difficulties with the source :)