- Add TTSManager and SpeechQueue utilities - Create AddTextToSpeechQueueUseCase and ReadBookmarkUseCase - Add SpeechPlayer UI components (GlobalPlayerContainerView, SpeechPlayerView, SpeechPlayerViewModel) - Update BookmarkDetailView and BookmarkDetailViewModel for TTS integration - Add audio background mode to Info.plist - Update PhoneTabView for TTS controls - Add StringExtensions for text processing - Add StringExtensionsTests for testing - Update Localizable.xcstrings with new strings - Add VS Code settings
29 lines
1.1 KiB
Swift
29 lines
1.1 KiB
Swift
import Foundation
|
|
|
|
extension String {
|
|
var stripHTML: String {
|
|
// Entfernt HTML-Tags und decodiert HTML-Entities
|
|
let attributedString = try? NSAttributedString(
|
|
data: Data(utf8),
|
|
options: [
|
|
.documentType: NSAttributedString.DocumentType.html,
|
|
.characterEncoding: String.Encoding.utf8.rawValue
|
|
],
|
|
documentAttributes: nil
|
|
)
|
|
|
|
return attributedString?.string ?? self
|
|
}
|
|
|
|
var stripHTMLSimple: String {
|
|
// Einfache Regex-basierte HTML-Entfernung
|
|
return self.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)
|
|
.replacingOccurrences(of: " ", with: " ")
|
|
.replacingOccurrences(of: "&", with: "&")
|
|
.replacingOccurrences(of: "<", with: "<")
|
|
.replacingOccurrences(of: ">", with: ">")
|
|
.replacingOccurrences(of: """, with: "\"")
|
|
.replacingOccurrences(of: "'", with: "'")
|
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
}
|
|
} |