Skip to content

Commit

Permalink
replace umlauts and other chars in hashtags instead of removing them
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunsi committed Oct 20, 2024
1 parent 1d5b3bc commit c33373e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion voctopublish/tools/announcements.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ class EmptyAnnouncementMessage(Exception):
pass


def _replace_special_chars(maybe_string):
string = str(maybe_string)
for search, replace in {
"Ä": "Ae",
"Ö": "Oe",
"Ü": "Ue",
"ß": "ss",
"ä": "ae",
"ö": "oe",
"ü": "ue",
"ẞ": "Ss",
}.items():
string.replace(search, replace)
return sub(r"[^A-Za-z0-9]+", "", string)


def make_message(ticket, config, max_length=None, override_url_length=None):
if max_length is None:
# if max_length is not set, set it to something very big here.
Expand Down Expand Up @@ -45,7 +61,7 @@ def make_message(ticket, config, max_length=None, override_url_length=None):
for tag in ticket.publishing_tags:
if tag is None:
continue
tag = sub(r"[^A-Za-z0-9]+", "", str(tag))
tag = _replace_special_chars(tag)
if tag.isdigit():
continue
if len(message) < (max_length - 2 - len(tag)):
Expand Down

0 comments on commit c33373e

Please sign in to comment.