-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hi @willforde - I don't know for certain whether this is a bug - it also looks like it could've been a performance-related decision, but either way, I figured it'd be worth asking about.
There's some code at
Lines 366 to 368 in 20b365a
| # If the previous element is what we actually have then the expected element was not | |
| # properly closed so we must close that before closing what we have now | |
| elif len(_elem) >= 2 and _elem[-2].tag == tag: |
At the moment, that check only inspects the previous element (second-from-last in the element stack/list) for a match.
There aren't many negative side-effects of this as far as I can tell, but it does allow for more text than expected to be gathered into the _data buffer some cases, and I wondered whether the choice of array index check is intentional?
I'll offer a pull request with an example text-handling problem that can occur, and a possible alternative implementation for the previously-opened-tag condition.