Skip to content

Commit

Permalink
Escape, not remove, [] and \
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed Aug 21, 2024
1 parent 9ace6e3 commit b3ccc84
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/solidation/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/solidation/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit b3ccc84

Please sign in to comment.