mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
Ignore chapter markers and single newlines when calculating text length
This commit is contained in:
+4
-2
@@ -119,8 +119,10 @@ def save_config(config):
|
||||
|
||||
|
||||
def calculate_text_length(text):
|
||||
# Remove double newlines (replace them with single newlines)
|
||||
cleaned_text = text.replace("\n\n", "")
|
||||
# Ignore chapter markers
|
||||
text_no_markers = re.sub(r"<<CHAPTER_MARKER:.*?>>", "", text)
|
||||
# Ignore newlines
|
||||
cleaned_text = text_no_markers.replace("\n", "")
|
||||
# Calculate character count
|
||||
char_count = len(cleaned_text)
|
||||
return char_count
|
||||
|
||||
Reference in New Issue
Block a user