File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -461,10 +461,12 @@ def check_block(block_lineno, block):
461461 yield from errors
462462
463463
464+ _DANGLING_HYPHEN_RE = re .compile (r".*[a-z]-$" )
465+
464466@checker (".rst" , rst_only = True )
465467def check_dangling_hyphen (file , lines , options ):
466468 """Check for lines ending in a hyphen."""
467469 for lno , line in enumerate (lines ):
468470 stripped_line = line .rstrip ("\n " )
469- if re .match (r".*[a-z]-$" , stripped_line ):
471+ if _DANGLING_HYPHEN_RE .match (stripped_line ):
470472 yield lno + 1 , f"Line ends with dangling hyphen"
Original file line number Diff line number Diff line change @@ -121,17 +121,22 @@ def looks_like_glued(match):
121121 return True
122122
123123
124+ _START_OF_COMMENT_BLOCK_RE = re .compile (r"^\s*\.\.$" )
125+ _PRODUCTION_LIST_DIRECTIVE_RE = re .compile (r"^ *.. productionlist::" )
126+ _COMMENT_RE = re .compile (r"^ *\.\. " )
127+
128+
124129def is_multiline_non_rst_block (line ):
125130 """Returns True if the next lines are an indented literal block."""
126- if re . match ( r"^\s*\.\.$" , line ): # it's the start of a comment block.
131+ if _START_OF_COMMENT_BLOCK_RE . search ( line ):
127132 return True
128133 if rst .DIRECTIVES_CONTAINING_RST_RE .match (line ):
129134 return False
130135 if rst .DIRECTIVES_CONTAINING_ARBITRARY_CONTENT_RE .match (line ):
131136 return True
132- if re . match ( r"^ *.. productionlist::" , line ):
137+ if _PRODUCTION_LIST_DIRECTIVE_RE . search ( line ):
133138 return True
134- if re . match ( r"^ *\.\. " , line ) and type_of_explicit_markup (line ) == "comment" :
139+ if _COMMENT_RE . search ( line ) and type_of_explicit_markup (line ) == "comment" :
135140 return True
136141 if line .endswith ("::\n " ): # It's a literal block
137142 return True
@@ -164,7 +169,7 @@ def hide_non_rst_blocks(lines, hidden_block_cb=None):
164169 block_line_start = lineno
165170 assert not excluded_lines
166171 if (
167- re . match ( r" *\.\. " , line )
172+ _COMMENT_RE . search ( line )
168173 and type_of_explicit_markup (line ) == "comment"
169174 ):
170175 line = "\n "
You can’t perform that action at this time.
0 commit comments