Skip to content

Commit

Permalink
🐛 FIX: Convert empty directive option to None (#452)
Browse files Browse the repository at this point in the history
This allows for converters like `optional_int` to work correctly
  • Loading branch information
chrisjsewell authored Dec 4, 2021
1 parent 89ad170 commit ea6e967
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion myst_parser/parse_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def parse_directive_options(
raise DirectiveParsingError(f"Unknown option: {name}")
if not isinstance(value, str):
if value is True or value is None:
value = "" # flag converter requires no argument
value = None # flag converter requires no argument
elif isinstance(value, (int, float, datetime.date, datetime.datetime)):
# convertor always requires string input
value = str(value)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_renderers/fixtures/sphinx_directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ highlight (`sphinx.directives.code.Highlight`):
code-block (`sphinx.directives.code.CodeBlock`):
.
```{code-block}
:dedent:
a=1
a=1
```
.
<document source="notset">
Expand Down

0 comments on commit ea6e967

Please sign in to comment.