memories are now redacted
This commit is contained in:
@@ -63,10 +63,21 @@ class JournalEntry(BaseModel):
|
||||
|
||||
@property
|
||||
def spoiler_text(self) -> str:
|
||||
new_text = self.text.replace("\n", "<br>").replace("<", "<").replace(">", ">").replace("&", "&")
|
||||
matches = re.findall(r"[A-Z](\s|\w)+\:\)(\w|\s)+\.", new_text)
|
||||
"""Returns the text with all the frisky details hidden away"""
|
||||
new_text = self.text.replace("<", "<").replace(">", ">").replace("&", "&")
|
||||
pattern = re.compile(
|
||||
"("
|
||||
"(((?<=(\.|\!|\?)\s)[A-Z])|(^[A-Z]))" # beginning of a sentence
|
||||
"([^\.\!\?])+" # any character being part of a sentence
|
||||
"\:\)" # the smiley
|
||||
"([^\.\!\?])*" # continuation of sentence
|
||||
"(\.|\!|\?|\,|$)" # end of the sentence
|
||||
")"
|
||||
)
|
||||
matches = pattern.findall(new_text)
|
||||
for match in matches:
|
||||
new_text = new_text.replace(match, f"<tg-spoiler>{match}</tg-spoiler>")
|
||||
group_to_replace = match[0]
|
||||
new_text = new_text.replace(group_to_replace, f"<tg-spoiler>{group_to_replace}</tg-spoiler>")
|
||||
return new_text
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user