@@ -109,6 +109,10 @@ def check_unbalanced_inline_literals_delimiters(file, lines, options=None):
109109 )
110110
111111
112+ _ends_with_role_tag = re .compile (rst .ROLE_TAG + "$" ).search
113+ _starts_with_role_tag = re .compile ("^" + rst .ROLE_TAG ).search
114+
115+
112116@checker (".rst" , ".po" , enabled = False )
113117def check_default_role (file , lines , options = None ):
114118 """Search for default roles (but they are allowed in many projects).
@@ -127,10 +131,10 @@ def check_default_role(file, lines, options=None):
127131 if (stripped_line .startswith ("|" ) and stripped_line .endswith ("|" ) and
128132 stripped_line .count ("|" ) >= 4 and "|" in match .group (0 )):
129133 return # we don't handle tables yet.
130- if rst . ROLE_TAG_ENDING_LINE_RE . search (before_match ):
134+ if _ends_with_role_tag (before_match ):
131135 # It's not a default role: it ends with a tag.
132136 continue
133- if rst . ROLE_TAG_STARTING_LINE_RE . search (after_match ):
137+ if _starts_with_role_tag (after_match ):
134138 # It's not a default role: it starts with a tag.
135139 continue
136140 if match .group (0 ).startswith ("``" ) and match .group (0 ).endswith ("``" ):
@@ -280,7 +284,7 @@ def check_role_with_double_backticks(file, lines, options=None):
280284 if inline_literal is None :
281285 break
282286 before = paragraph [: inline_literal .start ()]
283- if rst . ROLE_TAG_ENDING_LINE_RE . search (before ):
287+ if _ends_with_role_tag (before ):
284288 error_offset = paragraph [: inline_literal .start ()].count ("\n " )
285289 yield paragraph_lno + error_offset , "role use a single backtick, double backtick found."
286290 paragraph = (
0 commit comments