Fix DeprecationWarning in escape_markdown()

Using `count` as positional argument to `re.sub` is deprecated since
Python 3.13.

Fixes #10490
This commit is contained in:
Niklas Mertsch
2026-07-22 09:52:00 -04:00
committed by GitHub
parent 188d32d632
commit 1add8a0b40
+1 -1
View File
@@ -1008,7 +1008,7 @@ def escape_markdown(text: str, *, as_needed: bool = False, ignore_links: bool =
regex = _MARKDOWN_STOCK_REGEX
if ignore_links:
regex = f'(?:{_URL_REGEX}|{regex})'
return re.sub(regex, replacement, text, 0, re.MULTILINE)
return re.sub(regex, replacement, text, count=0, flags=re.MULTILINE)
else:
text = re.sub(r'\\', r'\\\\', text)
return _MARKDOWN_ESCAPE_REGEX.sub(r'\\\1', text)