@@ -127,12 +127,12 @@ def check_default_role(file, lines, options=None):
127127 if (stripped_line .startswith ("|" ) and stripped_line .endswith ("|" ) and
128128 stripped_line .count ("|" ) >= 4 and "|" in match .group (0 )):
129129 return # we don't handle tables yet.
130- if rst .ROLE_TAG_STARTING_LINE_RE .search (before_match ):
131- # It's not a default role: it starts with a tag.
132- continue
133- if rst .ROLE_TAG_ENDING_LINE_RE .search (after_match ):
130+ if rst .ROLE_TAG_ENDING_LINE_RE .search (before_match ):
134131 # It's not a default role: it ends with a tag.
135132 continue
133+ if rst .ROLE_TAG_STARTING_LINE_RE .search (after_match ):
134+ # It's not a default role: it starts with a tag.
135+ continue
136136 if match .group (0 ).startswith ("``" ) and match .group (0 ).endswith ("``" ):
137137 # It's not a default role: it's an inline literal.
138138 continue
@@ -453,7 +453,7 @@ def check_triple_backticks(file, lines, options=None):
453453 yield lno + 1 , "There's no rst syntax using triple backticks"
454454
455455
456- _BAD_DEDENT_RE = re .compile (" [^ ].*::$" )
456+ _contains_bad_dedent = re .compile (" [^ ].*::$" ). match
457457
458458
459459@checker (".rst" , ".po" , rst_only = False )
@@ -473,19 +473,20 @@ def check_bad_dedent(file, lines, options=None):
473473
474474 def check_block (block_lineno , block ):
475475 for lineno , line in enumerate (block .splitlines ()):
476- if _BAD_DEDENT_RE . match (line ):
476+ if _contains_bad_dedent (line ):
477477 errors .append ((block_lineno + lineno , "Bad dedent in block" ))
478478
479479 list (hide_non_rst_blocks (lines , hidden_block_cb = check_block ))
480480 yield from errors
481481
482482
483- _DANGLING_HYPHEN_RE = re .compile (r".*[a-z]-$" )
483+ _contains_dangling_hyphen = re .compile (r".*[a-z]-$" ).match
484+
484485
485486@checker (".rst" , rst_only = True )
486487def check_dangling_hyphen (file , lines , options ):
487488 """Check for lines ending in a hyphen."""
488489 for lno , line in enumerate (lines ):
489490 stripped_line = line .rstrip ("\n " )
490- if _DANGLING_HYPHEN_RE . match (stripped_line ):
491+ if _contains_dangling_hyphen (stripped_line ):
491492 yield lno + 1 , f"Line ends with dangling hyphen"
0 commit comments