Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mdformat_mkdocs/mdit_plugins/_material_deflist.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ut eros sed sapien ullamcorper consequat. Nunc ligula ante.

Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis.
Nam vulputate tincidunt fringilla.
Vulputate tincidunt fringilla.
Nullam dignissim ultrices urna non auctor.
```

Expand All @@ -28,6 +28,7 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING

from markdown_it import MarkdownIt
Expand Down Expand Up @@ -106,6 +107,7 @@ def escape_deflist(
context: RenderContext, # noqa: ARG001
) -> str:
"""Escape line starting ":" which would otherwise be parsed as a definition list."""
pattern = re.compile(r"^[:~] ")
return "\n".join(
"\\" + line if line.startswith(":") else line for line in text.split("\n")
"\\" + line if pattern.match(line) else line for line in text.split("\n")
)
6 changes: 6 additions & 0 deletions tests/format/fixtures/regression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Prevent regression with non-deflists: https://github.com/KyleKing/mdformat-mkdocs/issues/56
.
::: my_lib.core
.
::: my_lib.core
.
1 change: 1 addition & 0 deletions tests/format/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def flatten(nested_list: list[list[T]]) -> list[T]:
"pymd_abbreviations.md",
"pymd_snippet.md",
"python_markdown_attr_list.md",
"regression.md",
"text.md",
)
],
Expand Down
Loading