@@ -175,34 +175,34 @@ def _parse_directive_options(
175
175
176
176
:returns: (content, options, validation_errors)
177
177
"""
178
- yaml_block : None | str = None
178
+ options_block : None | str = None
179
179
if content .startswith ("---" ):
180
180
line = None if line is None else line + 1
181
181
content = "\n " .join (content .splitlines ()[1 :])
182
182
match = re .search (r"^-{3,}" , content , re .MULTILINE )
183
183
if match :
184
- yaml_block = content [: match .start ()]
184
+ options_block = content [: match .start ()]
185
185
content = content [match .end () + 1 :] # TODO advance line number
186
186
else :
187
- yaml_block = content
187
+ options_block = content
188
188
content = ""
189
- yaml_block = dedent (yaml_block )
190
- elif content .startswith (":" ):
189
+ options_block = dedent (options_block )
190
+ elif content .lstrip (). startswith (":" ):
191
191
content_lines = content .splitlines ()
192
192
yaml_lines = []
193
193
while content_lines :
194
- if not content_lines [0 ].startswith (":" ):
194
+ if not content_lines [0 ].lstrip (). startswith (":" ):
195
195
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 )
198
198
content = "\n " .join (content_lines )
199
199
200
- has_options_block = yaml_block is not None
200
+ has_options_block = options_block is not None
201
201
202
202
if as_yaml :
203
203
yaml_errors : list [ParseWarnings ] = []
204
204
try :
205
- yaml_options = yaml .safe_load (yaml_block or "" ) or {}
205
+ yaml_options = yaml .safe_load (options_block or "" ) or {}
206
206
except (yaml .parser .ParserError , yaml .scanner .ScannerError ):
207
207
yaml_options = {}
208
208
yaml_errors .append (
@@ -226,9 +226,9 @@ def _parse_directive_options(
226
226
validation_errors : list [ParseWarnings ] = []
227
227
228
228
options : dict [str , str ] = {}
229
- if yaml_block is not None :
229
+ if options_block is not None :
230
230
try :
231
- _options , state = options_to_items (yaml_block )
231
+ _options , state = options_to_items (options_block )
232
232
options = dict (_options )
233
233
except TokenizeError as err :
234
234
return _DirectiveOptions (
0 commit comments