refactor: simplify truncation
This commit is contained in:
@@ -23,12 +23,7 @@ def one_line(text: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def truncate(text: str, max_len: int) -> str:
|
def truncate(text: str, max_len: int) -> str:
|
||||||
text = one_line(text)
|
return one_line(text)[:max_len]
|
||||||
if len(text) <= max_len:
|
|
||||||
return text
|
|
||||||
if max_len <= len(ELLIPSIS):
|
|
||||||
return text[:max_len]
|
|
||||||
return text[: max_len - len(ELLIPSIS)] + ELLIPSIS
|
|
||||||
|
|
||||||
|
|
||||||
def inline_code(text: str) -> str:
|
def inline_code(text: str) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user