Comment 5 for bug 1882067

Revision history for this message
Leonard Richardson (leonardr) wrote :

Before you spend too much additional time on this, I want to let you know that I don't think this change makes sense as part of the extract() method. This seems really specific to your situation and not something that should be in the core code.

Beautiful Soup 4.8.0 introduced a cleanup method called smooth() which consolidates adjacent NavigableString objects, a situation that mainly happens through calling tree-modification methods such as extract():

https://www.crummy.com/software/BeautifulSoup/bs4/doc/#smooth

If this were to go into the core code, my gut feeling is that it would take the form of an argument to smooth(). smooth() merges adjacent NavigableStrings; you want to find adjacent NavigableStrings and delete some of them.