mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-06-09 16:59:35 +00:00
26 lines
484 B
Swift
26 lines
484 B
Swift
import Foundation
|
|
import HTML2Markdown
|
|
import SwiftUI
|
|
|
|
public typealias HTMLString = String
|
|
|
|
extension HTMLString {
|
|
public var asMarkdown: String {
|
|
do {
|
|
let dom = try HTMLParser().parse(html: self)
|
|
return dom.toMarkdown()
|
|
} catch {
|
|
return self
|
|
}
|
|
}
|
|
|
|
public var asSafeAttributedString: AttributedString {
|
|
do {
|
|
return try AttributedString(markdown: asMarkdown)
|
|
} catch {
|
|
return AttributedString(stringLiteral: self)
|
|
}
|
|
}
|
|
}
|
|
|