diff --git a/mdformat_mkdocs/plugin.py b/mdformat_mkdocs/plugin.py index e3a935e..c13fe4f 100644 --- a/mdformat_mkdocs/plugin.py +++ b/mdformat_mkdocs/plugin.py @@ -128,9 +128,19 @@ def __init__(self) -> None: self._lookup: dict[str, int] = {} def _get_block_indent(self, indent: str, content: str) -> str: + if ( + self._block_type == "marked" + and content + and len(indent) <= len(self._block_indent) + ): + # Remove tracked indent on end of a marked (content tab or admonition) block + # `Which could be the start of a new block, so this must be first + self._block_type = None + self._block_indent = "" + if self._block_type is None: # Identify block type - markers = CONTENT_TAB_MARKERS + MKDOCS_ADMON_MARKERS + markers = CONTENT_TAB_MARKERS.union(MKDOCS_ADMON_MARKERS) if content.startswith("```"): self._block_type = "code" elif any(content.startswith(f"{marker} ") for marker in markers): @@ -142,14 +152,6 @@ def _get_block_indent(self, indent: str, content: str) -> str: # Remove tracked indent on end of code block self._block_type = None self._block_indent = "" - elif ( - self._block_type == "marked" - and content - and len(indent) <= len(self._block_indent) - ): - # Remove tracked indent on end of a marked (content tab or admonition) block - self._block_type = None - self._block_indent = "" return self._block_indent diff --git a/tests/format/fixtures.md b/tests/format/fixtures.md index bd11ebb..ba1870f 100644 --- a/tests/format/fixtures.md +++ b/tests/format/fixtures.md @@ -1269,3 +1269,73 @@ Example with '===+' (active) from