From a345f039d5339859ca3680e20d1495694c9c3097 Mon Sep 17 00:00:00 2001 From: Beingpax Date: Sun, 11 May 2025 13:20:50 +0545 Subject: [PATCH] Handle single-word newline variants --- VoiceInk/Whisper/WhisperTextFormatter.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/VoiceInk/Whisper/WhisperTextFormatter.swift b/VoiceInk/Whisper/WhisperTextFormatter.swift index 6576ee7..5fe7687 100644 --- a/VoiceInk/Whisper/WhisperTextFormatter.swift +++ b/VoiceInk/Whisper/WhisperTextFormatter.swift @@ -20,6 +20,20 @@ struct WhisperTextFormatter { ) } + // Handle single-word variants + let singleWordPatterns = [ + (pattern: "\\b(newline)\\b", replacement: "new line"), + (pattern: "\\b(newparagraph)\\b", replacement: "new paragraph") + ] + + for (pattern, replacement) in singleWordPatterns { + formattedText = formattedText.replacingOccurrences( + of: pattern, + with: replacement, + options: [.regularExpression, .caseInsensitive] + ) + } + // Then handle the new line/paragraph commands with any combination of spaces and punctuation let patterns = [ // Handle "new paragraph" with any combination of spaces and punctuation