lambdasoup icon indicating copy to clipboard operation
lambdasoup copied to clipboard

Make it possible to clone a node

Open dmbaturin opened this issue 5 years ago • 3 comments

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.

dmbaturin avatar Jul 22 '19 16:07 dmbaturin

That's right, there is no other way right now.

aantron avatar Jul 23 '19 06:07 aantron

Are there any fundamental difficulties, or it's a matter of just getting it done?

Got any pointers for diving into the source?

dmbaturin avatar Jul 23 '19 16:07 dmbaturin

I don't think there are any fundamental obstacles. You're welcome to ask here if you have any difficulties with the source :)

aantron avatar Jul 24 '19 02:07 aantron