mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 10:11:00 +00:00
match intended mastodon presentation (#557)
strip out <span="invisible">blah</span> append ellipsis to <span="ellipsis">blah</span>
This commit is contained in:
parent
0695fd5733
commit
0a0e985e33
1 changed files with 10 additions and 0 deletions
|
@ -27,6 +27,16 @@ public struct HTMLString: Decodable, Equatable, Hashable {
|
|||
htmlValue = regex.stringByReplacingMatches(in: htmlValue, options: [], range: NSRange(location: 0, length: htmlValue.count), withTemplate: "\\\\$1")
|
||||
}
|
||||
|
||||
// match intended mastodon presentation
|
||||
// strip out <span="invisible">blah</span>
|
||||
// append ellipsis to <span="ellipsis">blah</span>
|
||||
if let regex = try? NSRegularExpression(pattern: "(<span class=\"invisible\">.*?</span>)", options: .caseInsensitive) {
|
||||
htmlValue = regex.stringByReplacingMatches(in: htmlValue, options: [], range: NSRange(location: 0, length: htmlValue.count), withTemplate: "")
|
||||
}
|
||||
if let regex = try? NSRegularExpression(pattern: "(<span class=\"ellipsis\">(.*?)</span>)", options: .caseInsensitive) {
|
||||
htmlValue = regex.stringByReplacingMatches(in: htmlValue, options: [], range: NSRange(location: 0, length: htmlValue.count), withTemplate: "$2…")
|
||||
}
|
||||
|
||||
do {
|
||||
asMarkdown = try HTMLParser().parse(html: htmlValue)
|
||||
.toMarkdown()
|
||||
|
|
Loading…
Reference in a new issue