Okay the underlying cause of the problem is gumbo does not build DOM trees the way that Qt builds DOM trees when it comes to where text nodes are inserted. It seems Qt's tree assumes there is a text node made up of a null string between the p tag and its first child the span tag. But in this case gumbo does not create the same null string text node and thinks that the span tag is the first child of the p tag and that the next node is the text tag we are playing with.
So sometimes by playing around with text nodes the offset is the same between Qt's Dom and Gumbo's node tree and sometimes it is not.
The fix is not easy as it is hard to say how when this issue will arrive. It arrives here because of the span tag having no text separation from its parent p tag.
I will have to think about this some more.
|