mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Port RSHTMLTag and RSOMLFeedSpecifier to Swift.
This commit is contained in:
24
Modules/Parser/Sources/Parser/HTML/HTMLTag.swift
Normal file
24
Modules/Parser/Sources/Parser/HTML/HTMLTag.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// HTMLTag.swift
|
||||
//
|
||||
//
|
||||
// Created by Brent Simmons on 8/18/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct HTMLTag: Sendable {
|
||||
|
||||
public enum HTMLTagType {
|
||||
case link
|
||||
case meta
|
||||
}
|
||||
|
||||
public let tagType: HTMLTagType
|
||||
public let attributes: [String: String]?
|
||||
|
||||
public init(tagType: TagType, attributes: [String : String]?) {
|
||||
self.tagType = tagType
|
||||
self.attributes = attributes
|
||||
}
|
||||
}
|
||||
40
Modules/Parser/Sources/Parser/OPML/OPMLFeedSpecifier.swift
Normal file
40
Modules/Parser/Sources/Parser/OPML/OPMLFeedSpecifier.swift
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by Brent Simmons on 8/18/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct OPMLFeedSpecifier: Sendable {
|
||||
|
||||
let title: String?
|
||||
let feedDescription: String?
|
||||
let homePageURL: String?
|
||||
let feedURL: String
|
||||
|
||||
init(title: String?, feedDescription: String?, homePageURL: String?, feedURL: String) {
|
||||
|
||||
if String.isEmptyOrNil(title) {
|
||||
self.title = nil
|
||||
} else {
|
||||
self.title = title
|
||||
}
|
||||
|
||||
if String.isEmptyOrNil(feedDescription) {
|
||||
self.feedDescription = nil
|
||||
} else {
|
||||
self.feedDescription = feedDescription
|
||||
}
|
||||
|
||||
if String.isEmptyOrNil(homePageURL) {
|
||||
self.homePageURL = nil
|
||||
} else {
|
||||
self.homePageURL = homePageURL
|
||||
}
|
||||
|
||||
self.feedURL = feedURL
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,10 @@ extension String {
|
||||
return self.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ? nil : self
|
||||
}
|
||||
|
||||
static func isEmptyOrNil(_ s: String?) {
|
||||
if let s {
|
||||
return s.isEmpty
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user