Skip to content

Commit

Permalink
feat: Support blank line between ::: path and YAML options
Browse files Browse the repository at this point in the history
Issue-450: #450
  • Loading branch information
pawamoy committed Apr 27, 2024
1 parent 828bd59 commit d799d2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mkdocstrings/extension.py
Expand Up @@ -116,6 +116,10 @@ def run(self, parent: Element, blocks: MutableSequence[str]) -> None:

block, the_rest = self.detab(block)

if not block and blocks and blocks[0].startswith((" handler:", " options:")):
# YAML options were separated from the `:::` line by a blank line.
block = blocks.pop(0)

if match:
identifier = match["name"]
heading_level = match["heading"].count("#")
Expand Down
5 changes: 5 additions & 0 deletions tests/test_extension.py
Expand Up @@ -172,6 +172,11 @@ def test_use_options_yaml_key(ext_markdown: Markdown) -> None:
assert "h1" not in ext_markdown.convert("::: tests.fixtures.headings\n options:\n heading_level: 2")


def test_use_yaml_options_after_blank_line(ext_markdown: Markdown) -> None:
"""Check that YAML options are detected even after a blank line."""
assert "h1" not in ext_markdown.convert("::: tests.fixtures.headings\n\n options:\n heading_level: 2")


@pytest.mark.parametrize("ext_markdown", [{"markdown_extensions": [{"admonition": {}}]}], indirect=["ext_markdown"])
def test_removing_duplicated_headings(ext_markdown: Markdown) -> None:
"""Assert duplicated headings are removed from the output."""
Expand Down

0 comments on commit d799d2f

Please sign in to comment.