Skip to content

Commit 9a9e6f1

Browse files
authored
πŸ› FIX: Do not error if a directive has no options or body (#12)
1 parent 7fbb4d1 commit 9a9e6f1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

β€Žmdformat_myst/_directives.pyβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def format_directive_content(raw_content: str) -> str:
100100

101101

102102
def parse_opts_and_content(raw_content: str) -> tuple[str, str] | None:
103+
if not raw_content:
104+
return None
103105
lines = raw_content.splitlines()
104106
line = lines.pop(0)
105107
yaml_lines = []

β€Žtests/data/fixtures.mdβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,12 @@ letter: a
394394
---
395395
```
396396
.
397+
398+
MyST directive, no opts or content
399+
.
400+
``` {some-directive} args
401+
```
402+
.
403+
```{some-directive} args
404+
```
405+
.

0 commit comments

Comments
Β (0)