- Move and replace utility files (SafariUtil, SpeechQueue, StringExtensions, TTSManager, VoiceManager) - Refactor and extend SpeechPlayer components (UI, progress, volume, queue) - Improved state and EnvironmentObject management (PlayerUIState) - UI and logic optimizations in menu and tab views - Remove obsolete and duplicate files - General code and UX improvements
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)
|
|
}
|
|
} |