parent
1d701f32b6
commit
24d3a5a48d
@ -473,16 +473,11 @@ class clean_content(Converter):
|
|||||||
result = pattern.sub(repl, argument)
|
result = pattern.sub(repl, argument)
|
||||||
|
|
||||||
if self.escape_markdown:
|
if self.escape_markdown:
|
||||||
transformations = {
|
result = re.sub(r'\\', r'\\\\', result)
|
||||||
re.escape(c): '\\' + c
|
for c in ('*', '`', '_', '~', '|'):
|
||||||
for c in ('*', '`', '_', '~', '\\', '||')
|
regex = r'\{0}(?=([\s\S]*((?<!\{0})\{0})))'.format(c)
|
||||||
}
|
replace = '\{0}'.format(c)
|
||||||
|
result = re.sub(regex, replace, result)
|
||||||
def replace(obj):
|
|
||||||
return transformations.get(re.escape(obj.group(0)), '')
|
|
||||||
|
|
||||||
pattern = re.compile('|'.join(transformations.keys()))
|
|
||||||
result = pattern.sub(replace, result)
|
|
||||||
|
|
||||||
# Completely ensure no mentions escape:
|
# Completely ensure no mentions escape:
|
||||||
return re.sub(r'@(everyone|here|[!&]?[0-9]{17,21})', '@\u200b\\1', result)
|
return re.sub(r'@(everyone|here|[!&]?[0-9]{17,21})', '@\u200b\\1', result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user