diff --git a/abogen/utils.py b/abogen/utils.py index 4e51ba5..46f77b9 100644 --- a/abogen/utils.py +++ b/abogen/utils.py @@ -204,11 +204,15 @@ def save_config(config): def calculate_text_length(text): # Ignore chapter markers - text_no_markers = re.sub(r"<>", "", text) + text = re.sub(r"<>", "", text) + # Ignore metadata patterns + text = re.sub(r"<]*>>", "", text) # Ignore newlines - cleaned_text = text_no_markers.replace("\n", "") + text = text.replace("\n", "") + # Ignore leading/trailing spaces + text = text.strip() # Calculate character count - char_count = len(cleaned_text) + char_count = len(text) return char_count