mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 09:41:02 +00:00
Render Status as Markdown
This commit is contained in:
parent
3c1b879d1a
commit
0608996bb8
4 changed files with 32 additions and 2 deletions
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "html2markdown",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://gitlab.com/mflint/HTML2Markdown",
|
||||
"state" : {
|
||||
"revision" : "00d7a9744bbd1e7762c587bbd248775e16345a65",
|
||||
"version" : "1.0.0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 2
|
||||
}
|
|
@ -13,10 +13,13 @@ let package = Package(
|
|||
name: "Network",
|
||||
targets: ["Network"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://gitlab.com/mflint/HTML2Markdown", exact: "1.0.0")
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "Network",
|
||||
dependencies: []),
|
||||
dependencies: ["HTML2Markdown"]),
|
||||
.testTarget(
|
||||
name: "NetworkTests",
|
||||
dependencies: ["Network"]),
|
||||
|
|
13
Packages/Network/Sources/Network/ModelsExt/StatusExt.swift
Normal file
13
Packages/Network/Sources/Network/ModelsExt/StatusExt.swift
Normal file
|
@ -0,0 +1,13 @@
|
|||
import SwiftSoup
|
||||
import HTML2Markdown
|
||||
|
||||
extension Status {
|
||||
public var contentAsMarkdown: String {
|
||||
do {
|
||||
let dom = try HTMLParser().parse(html: content)
|
||||
return dom.toMarkdown()
|
||||
} catch {
|
||||
return content
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ struct StatusRowView: View {
|
|||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
Text(status.content)
|
||||
Text(try! AttributedString(markdown: status.contentAsMarkdown))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue