Fix ordering of nested entities

This commit is contained in:
udf 2023-12-07 18:25:11 +02:00
parent abeb8c4d8d
commit 3b428f97a9
No known key found for this signature in database
GPG Key ID: E94E4702E3C6D729

View File

@ -124,6 +124,8 @@ def parse(html: str) -> Tuple[str, List[TypeMessageEntity]]:
parser = HTMLToTelegramParser() parser = HTMLToTelegramParser()
parser.feed(add_surrogate(html)) parser.feed(add_surrogate(html))
text = strip_text(parser.text, parser.entities) text = strip_text(parser.text, parser.entities)
parser.entities.reverse()
parser.entities.sort(key=lambda entity: entity.offset)
return del_surrogate(text), parser.entities return del_surrogate(text), parser.entities