@@ -175,34 +175,34 @@ def _parse_directive_options(
175175
176176 :returns: (content, options, validation_errors)
177177 """
178- yaml_block : None | str = None
178+ options_block : None | str = None
179179 if content .startswith ("---" ):
180180 line = None if line is None else line + 1
181181 content = "\n " .join (content .splitlines ()[1 :])
182182 match = re .search (r"^-{3,}" , content , re .MULTILINE )
183183 if match :
184- yaml_block = content [: match .start ()]
184+ options_block = content [: match .start ()]
185185 content = content [match .end () + 1 :] # TODO advance line number
186186 else :
187- yaml_block = content
187+ options_block = content
188188 content = ""
189- yaml_block = dedent (yaml_block )
190- elif content .startswith (":" ):
189+ options_block = dedent (options_block )
190+ elif content .lstrip (). startswith (":" ):
191191 content_lines = content .splitlines ()
192192 yaml_lines = []
193193 while content_lines :
194- if not content_lines [0 ].startswith (":" ):
194+ if not content_lines [0 ].lstrip (). startswith (":" ):
195195 break
196- yaml_lines .append (content_lines .pop (0 )[1 :])
197- yaml_block = "\n " .join (yaml_lines )
196+ yaml_lines .append (content_lines .pop (0 ). lstrip () [1 :])
197+ options_block = "\n " .join (yaml_lines )
198198 content = "\n " .join (content_lines )
199199
200- has_options_block = yaml_block is not None
200+ has_options_block = options_block is not None
201201
202202 if as_yaml :
203203 yaml_errors : list [ParseWarnings ] = []
204204 try :
205- yaml_options = yaml .safe_load (yaml_block or "" ) or {}
205+ yaml_options = yaml .safe_load (options_block or "" ) or {}
206206 except (yaml .parser .ParserError , yaml .scanner .ScannerError ):
207207 yaml_options = {}
208208 yaml_errors .append (
@@ -226,9 +226,9 @@ def _parse_directive_options(
226226 validation_errors : list [ParseWarnings ] = []
227227
228228 options : dict [str , str ] = {}
229- if yaml_block is not None :
229+ if options_block is not None :
230230 try :
231- _options , state = options_to_items (yaml_block )
231+ _options , state = options_to_items (options_block )
232232 options = dict (_options )
233233 except TokenizeError as err :
234234 return _DirectiveOptions (
0 commit comments