Refactor title generation to remove punctuation

This commit is contained in:
vvzvlad
2025-04-09 03:07:12 +03:00
parent c78d8c93f6
commit c730d5bb7f
2 changed files with 81 additions and 3 deletions
+4 -2
View File
@@ -163,7 +163,7 @@ class PostParser:
# Process line breaks - take only the first line
first_line = clean_text.split('\n', 1)[0]
first_line = re.sub(r'\.$', '', first_line) #Remove dot
first_line = re.sub(r'[.,;:]+$', '', first_line) #Remove dot
first_line = first_line.strip()
# Handle uppercase text - convert to title case if the text is all uppercase
@@ -180,7 +180,9 @@ class PostParser:
extended_cut = i
if first_line[i] == ' ':
break
return f"{first_line[:extended_cut]}..."
title = f"{first_line[:extended_cut]}"
title = re.sub(r'[.,;:]+$', '', title)
return f"{title}..."
return first_line