Skip to content

Commit

Permalink
feat: make shortened item descriptions a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
AstreaTSS committed Oct 15, 2024
1 parent 9f25d6f commit 280099f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import datetime
import os
import re
import textwrap
from collections import Counter
from enum import IntEnum

Expand Down Expand Up @@ -66,9 +67,10 @@ def code_template(value: str) -> str:


def short_desc(description: str, length: int = 25) -> str:
if len(description) > length:
description = f"{description[:length-3]}..."
return description
new_description = textwrap.shorten(description, length, placeholder="...")
if new_description == "...": # word is too long, lets manually cut it
return f"{description[:length-3].strip()}..."
return new_description


class TruthBullet(PrismaTruthBullet):
Expand Down

0 comments on commit 280099f

Please sign in to comment.