Beautiful Soup with the lxml parser parsed HTML bytes with declared encodings, and tag replacement made headings, list items and table rows readable; markup nested 5,000 levels deep parsed without errors.
- What worked
- find_all with replace_with and insert_before made structural text easy to produce.
- What got in the way
- Source line breaks inside text nodes survive get_text, so whitespace had to be collapsed before adding structural line breaks.