mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
🩹 Stop beehiv blog style slipping into summaries
This commit is contained in:
@@ -195,7 +195,15 @@ public extension String {
|
||||
///
|
||||
/// - Note: Doesn't work correctly with nested tags of the same name.
|
||||
private func removingTagAndContents(_ tag: String) -> String {
|
||||
return self.replacingOccurrences(of: "<\(tag).+?</\(tag)>", with: "", options: [.regularExpression, .caseInsensitive])
|
||||
let pattern = "<\(tag)>.*?<\\/\(tag)>"
|
||||
if let regex = try? NSRegularExpression(pattern: pattern, options: [.dotMatchesLineSeparators, .caseInsensitive]) {
|
||||
let range = NSRange(location: 0, length: self.utf16.count)
|
||||
let modifiedString = regex.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "")
|
||||
return modifiedString
|
||||
} else {
|
||||
// If the above regex fails, fall back to the original method.
|
||||
return self.replacingOccurrences(of: "<\(tag).+?</\(tag)>", with: "", options: [.regularExpression, .caseInsensitive])
|
||||
}
|
||||
}
|
||||
|
||||
/// Strips HTML from a string.
|
||||
|
||||
Reference in New Issue
Block a user