Skip to content

Commit

Permalink
🔧 Use str.removesuffix (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin authored Dec 18, 2024
1 parent c5161b5 commit 0c933dc
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions markdown_it/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def type(self) -> str:
if self.token:
return self.token.type
assert self.nester_tokens
return _removesuffix(self.nester_tokens.opening.type, "_open")
return self.nester_tokens.opening.type.removesuffix("_open")

@property
def next_sibling(self: _NodeType) -> _NodeType | None:
Expand Down Expand Up @@ -331,14 +331,3 @@ def hidden(self) -> bool:
"""If it's true, ignore this element when rendering.
Used for tight lists to hide paragraphs."""
return self._attribute_token().hidden


def _removesuffix(string: str, suffix: str) -> str:
"""Remove a suffix from a string.
Replace this with str.removesuffix() from stdlib when minimum Python
version is 3.9.
"""
if suffix and string.endswith(suffix):
return string[: -len(suffix)]
return string

0 comments on commit 0c933dc

Please sign in to comment.