Fix directly nested markdown entities

This commit is contained in:
Lonami Exo 2019-07-06 12:55:44 +02:00
parent 8e36bb4c4d
commit 05b770a93f

View File

@ -90,7 +90,11 @@ def parse(message, delimiters=None, url_re=None):
for ent in result: for ent in result:
# If the end is after our start, it is affected # If the end is after our start, it is affected
if ent.offset + ent.length > i: if ent.offset + ent.length > i:
ent.length -= len(delim) # If the old start is also before ours, it is fully enclosed
if ent.offset <= i:
ent.length -= len(delim) * 2
else:
ent.length -= len(delim)
# Append the found entity # Append the found entity
ent = delimiters[delim] ent = delimiters[delim]