From 1eab964c0b2d0426504c17c8373f4d883200f548 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 23 Jan 2023 15:15:43 -0500 Subject: [PATCH] Parse HTML in trending link card descriptions --- .../Screens/Explore/TrendingLinkCardCollectionViewCell.swift | 3 ++- Tusker/Views/Status/StatusCardView.swift | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.swift b/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.swift index 55de1361..976485f9 100644 --- a/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.swift +++ b/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.swift @@ -9,6 +9,7 @@ import UIKit import Pachyderm import WebURLFoundationExtras +import SwiftSoup class TrendingLinkCardCollectionViewCell: UICollectionViewCell { @@ -55,7 +56,7 @@ class TrendingLinkCardCollectionViewCell: UICollectionViewCell { let provider = card.providerName!.trimmingCharacters(in: .whitespacesAndNewlines) providerLabel.text = provider - let description = card.description.trimmingCharacters(in: .whitespacesAndNewlines) + let description = try! SwiftSoup.parseBodyFragment(card.description).text() descriptionLabel.text = description descriptionLabel.isHidden = description.isEmpty diff --git a/Tusker/Views/Status/StatusCardView.swift b/Tusker/Views/Status/StatusCardView.swift index a4c89106..dd354ba4 100644 --- a/Tusker/Views/Status/StatusCardView.swift +++ b/Tusker/Views/Status/StatusCardView.swift @@ -10,6 +10,7 @@ import UIKit import Pachyderm import SafariServices import WebURLFoundationExtras +import SwiftSoup class StatusCardView: UIView { @@ -156,7 +157,7 @@ class StatusCardView: UIView { titleLabel.text = title titleLabel.isHidden = title.isEmpty - let description = card.description.trimmingCharacters(in: .whitespacesAndNewlines) + let description = try! SwiftSoup.parseBodyFragment(card.description).text() descriptionLabel.text = description descriptionLabel.isHidden = description.isEmpty