From e1b935938f176b1b93bcfa6a652413310d40b8d4 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Mon, 12 Jul 2021 21:12:48 -0400 Subject: [PATCH] fix: Do not error if a directive has no options or body --- mdformat_myst/_directives.py | 2 ++ tests/data/fixtures.md | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/mdformat_myst/_directives.py b/mdformat_myst/_directives.py index 9de256c..1a5545a 100644 --- a/mdformat_myst/_directives.py +++ b/mdformat_myst/_directives.py @@ -100,6 +100,8 @@ def format_directive_content(raw_content: str) -> str: def parse_opts_and_content(raw_content: str) -> tuple[str, str] | None: + if not raw_content: + return None lines = raw_content.splitlines() line = lines.pop(0) yaml_lines = [] diff --git a/tests/data/fixtures.md b/tests/data/fixtures.md index 81819be..8801baf 100644 --- a/tests/data/fixtures.md +++ b/tests/data/fixtures.md @@ -394,3 +394,12 @@ letter: a --- ``` . + +MyST directive, no opts or content +. +``` {some-directive} args +``` +. +```{some-directive} args +``` +.