mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-06 20:25:52 +03:00
Fix overlapping URLs and improve overlapping in md
Also remove the unused overlap function.
This commit is contained in:
parent
38d024312e
commit
551c24f3e4
|
@ -26,10 +26,6 @@ DEFAULT_URL_RE = re.compile(r'\[([\s\S]+)\]\((.+)\)')
|
||||||
DEFAULT_URL_FORMAT = '[{0}]({1})'
|
DEFAULT_URL_FORMAT = '[{0}]({1})'
|
||||||
|
|
||||||
|
|
||||||
def overlap(a, b, x, y):
|
|
||||||
return max(a, x) < min(b, y)
|
|
||||||
|
|
||||||
|
|
||||||
def parse(message, delimiters=None, url_re=None):
|
def parse(message, delimiters=None, url_re=None):
|
||||||
"""
|
"""
|
||||||
Parses the given markdown message and returns its stripped representation
|
Parses the given markdown message and returns its stripped representation
|
||||||
|
@ -90,8 +86,8 @@ 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:
|
||||||
# If the old start is also before ours, it is fully enclosed
|
# If the old start is before ours and the old end is after ours, we are fully enclosed
|
||||||
if ent.offset <= i:
|
if ent.offset <= i and ent.offset + ent.length >= end + len(delim):
|
||||||
ent.length -= len(delim) * 2
|
ent.length -= len(delim) * 2
|
||||||
else:
|
else:
|
||||||
ent.length -= len(delim)
|
ent.length -= len(delim)
|
||||||
|
@ -119,7 +115,7 @@ def parse(message, delimiters=None, url_re=None):
|
||||||
message[m.end():]
|
message[m.end():]
|
||||||
))
|
))
|
||||||
|
|
||||||
delim_size = m.end() - m.start() - len(m.group())
|
delim_size = m.end() - m.start() - len(m.group(1))
|
||||||
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 > m.start():
|
if ent.offset + ent.length > m.start():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user