2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Fix entities unparsing in other scenarios (#892)

This commit is contained in:
Andrea Princic 2022-02-03 15:26:17 +01:00 committed by GitHub
parent 855e69e3f8
commit b3f849df76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,7 +175,16 @@ class HTML:
entities_offsets.append((start_tag, start,))
entities_offsets.append((end_tag, end,))
for entity, offset in reversed(entities_offsets):
entities_offsets = map(
lambda x: x[1],
sorted(
enumerate(entities_offsets),
key = lambda x: (x[1][1], x[0]),
reverse = True
)
)
for entity, offset in entities_offsets:
text = text[:offset] + entity + text[offset:]
return utils.remove_surrogates(text)