From 6fd960dd6f1524f011a11470b644046ce9d8593c Mon Sep 17 00:00:00 2001 From: RTSDA Date: Tue, 1 Apr 2025 12:24:42 -0400 Subject: [PATCH] Improve Bible verse formatting and cleanup --- RTSDA.xcodeproj/project.pbxproj | 6 +++--- Services/BibleService.swift | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/RTSDA.xcodeproj/project.pbxproj b/RTSDA.xcodeproj/project.pbxproj index ae80d4a..82f4a04 100644 --- a/RTSDA.xcodeproj/project.pbxproj +++ b/RTSDA.xcodeproj/project.pbxproj @@ -282,7 +282,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1610; - LastUpgradeCheck = 1620; + LastUpgradeCheck = 1630; TargetAttributes = { EA2F9F7D2CF406E800B9F454 = { CreatedOnToolsVersion = 16.1; @@ -412,6 +412,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = TQMND62F2W; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; @@ -476,6 +477,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = TQMND62F2W; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; @@ -507,7 +509,6 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Preview Content\""; - DEVELOPMENT_TEAM = TQMND62F2W; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Info.plist; @@ -550,7 +551,6 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Preview Content\""; - DEVELOPMENT_TEAM = TQMND62F2W; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Info.plist; diff --git a/Services/BibleService.swift b/Services/BibleService.swift index 0a95836..cea060e 100644 --- a/Services/BibleService.swift +++ b/Services/BibleService.swift @@ -28,8 +28,14 @@ class BibleService { .replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression) .replacingOccurrences(of: """, with: "\"") .replacingOccurrences(of: "'", with: "'") + .replacingOccurrences(of: "¶\\s*", with: "", options: .regularExpression) // Remove paragraph markers .replacingOccurrences(of: "NUN\\s+\\d+\\s+", with: "", options: .regularExpression) // Remove Hebrew letter prefixes .replacingOccurrences(of: "^[A-Z]+\\s+\\d+\\s+", with: "", options: .regularExpression) // Remove any other letter prefixes + .replacingOccurrences(of: "^\\d+\\s*¶?\\s*", with: "", options: .regularExpression) // Remove verse numbers and paragraph markers at start + .replacingOccurrences(of: "^\\d+(?=\\w)", with: "", options: .regularExpression) // Remove verse numbers stuck to text + .replacingOccurrences(of: "\\s+\\d+\\s+", with: " ", options: .regularExpression) // Remove verse numbers in middle + .replacingOccurrences(of: "\\([^)]*\\)", with: "", options: .regularExpression) // Remove parenthetical content + .replacingOccurrences(of: "\\s+", with: " ", options: .regularExpression) // Normalize spaces .trimmingCharacters(in: .whitespacesAndNewlines) } } @@ -57,6 +63,13 @@ class BibleService { let (data, response) = try await URLSession.shared.data(for: request) + // Log raw response + if let rawResponse = String(data: data, encoding: .utf8) { + print("Raw Bible API Response:") + print(rawResponse) + print("\n") + } + // Check for successful response guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else { @@ -66,6 +79,12 @@ class BibleService { let decoder = JSONDecoder() let apiResponse = try decoder.decode(BibleAPIResponse.self, from: data) + // Log cleaned content + print("Cleaned verse content:") + print(apiResponse.data.cleanContent) + print("\nReference:", apiResponse.data.reference) + print("\n") + return (verse: apiResponse.data.cleanContent, reference: apiResponse.data.reference) } }