8000 bpo.py: leave code blocks untouched · python/bedevere@8d863f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d863f1

Browse files
committed
bpo.py: leave code blocks untouched
1 parent df9c7f6 commit 8d863f1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

bedevere/bpo.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def check_hyperlink(match):
115115
"""The span checking of regex matches takes care of cases like bpo-123 [bpo-123]…"""
116116
issue = match.group("issue")
117117
markdown_link_re = re.compile(r"""
118-
\[\s*bpo-(?P<issue>{issue})\s*\]
118+
\[\s*bpo-(?P<issue>{issue})\s*\]
119119
\(\s*https://bugs.python.org/issue{issue}\s*\)""".format(issue=issue),
120120
re.VERBOSE)
121121
html_link_re = re.compile(r""" <a
@@ -140,6 +140,12 @@ def create_hyperlink_in_comment_body(body):
140140
new_body = ""
141141
leftover_body = body
142142
ISSUE_RE = re.compile(r"bpo-(?P<issue>\d+)")
143+
144+
# leave code blocks, inline or otherwise, untouched
145+
CODE_BLOCK = re.compile(r"(`{1,3})(.|\s)*(`{1,3})")
146+
if CODE_BLOCK.search(body):
147+
return body
148+
143149
while True:
144150
match = ISSUE_RE.search(leftover_body)
145151
if match is None:
@@ -153,4 +159,5 @@ def create_hyperlink_in_comment_body(body):
153159
new_body = new_body + leftover_body[:presence]
154160
leftover_body = leftover_body[presence:]
155161
new_body = new_body + leftover_body
162+
156163
return new_body

0 commit comments

Comments
 (0)
0