diff --git a/src/solidation/__main__.py b/src/solidation/__main__.py index 6bf0e52..74c9e76 100644 --- a/src/solidation/__main__.py +++ b/src/solidation/__main__.py @@ -439,7 +439,7 @@ def ensure_aware(dt: datetime) -> datetime: def sanitize_md(s: str) -> str: # Remove `[]` symbols to ensure correct markdown in the references - return re.sub(r'[\[\]]', '', s) + return re.sub(r'([\\\[\]])', r'\\\1', s) @click.command() diff --git a/src/solidation/tests/test_main.py b/src/solidation/tests/test_main.py index 59dd5cc..de1d589 100644 --- a/src/solidation/tests/test_main.py +++ b/src/solidation/tests/test_main.py @@ -2,4 +2,4 @@ def test_sanitize_md() -> None: - assert sanitize_md("[gh-actions](deps): Bump") == "gh-actions(deps): Bump" + assert sanitize_md(r"[gh-actions](deps): Fix \n") == r"\[gh-actions\](deps): Fix \\n"