Skip to content

Commit ef855c7

Browse files
committed
Markdown: Add MarkdownUI to support Markdown render of post content and comments
1 parent 9378834 commit ef855c7

File tree

6 files changed

+86
-4
lines changed

6 files changed

+86
-4
lines changed

RedditOs.xcodeproj/project.pbxproj

+17
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
69F74E9624DB0B7300E58BD8 /* GlobalSearchPopoverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69F74E9524DB0B7300E58BD8 /* GlobalSearchPopoverView.swift */; };
6464
9F19B57A26505DCF00FBEEDA /* SidebarMultiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F19B57926505DCF00FBEEDA /* SidebarMultiView.swift */; };
6565
9F4812CC264FC8DB007A719D /* SearchMainContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F4812CB264FC8DB007A719D /* SearchMainContentView.swift */; };
66+
9F8EE49126510BCF00BDE4AC /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 9F8EE49026510BCF00BDE4AC /* MarkdownUI */; };
6667
/* End PBXBuildFile section */
6768

6869
/* Begin PBXFileReference section */
@@ -134,6 +135,7 @@
134135
69D459FE264BBB0000A98C6F /* Kingfisher in Frameworks */,
135136
697E324524E3E7D90006F00F /* UI in Frameworks */,
136137
69EACF1C24B7272E00303A16 /* Backend in Frameworks */,
138+
9F8EE49126510BCF00BDE4AC /* MarkdownUI in Frameworks */,
137139
);
138140
runOnlyForDeploymentPostprocessing = 0;
139141
};
@@ -400,6 +402,7 @@
400402
69EACF1B24B7272E00303A16 /* Backend */,
401403
697E324424E3E7D90006F00F /* UI */,
402404
69D459FD264BBB0000A98C6F /* Kingfisher */,
405+
9F8EE49026510BCF00BDE4AC /* MarkdownUI */,
403406
);
404407
productName = RedditOs;
405408
productReference = 69EACEFF24B63D5800303A16 /* Curiosity.app */;
@@ -430,6 +433,7 @@
430433
mainGroup = 69EACEF624B63D5800303A16;
431434
packageReferences = (
432435
6923F8CB250250FC0003870F /* XCRemoteSwiftPackageReference "Kingfisher" */,
436+
9F8EE48F26510BCF00BDE4AC /* XCRemoteSwiftPackageReference "MarkdownUI" */,
433437
);
434438
productRefGroup = 69EACF0024B63D5800303A16 /* Products */;
435439
projectDirPath = "";
@@ -715,6 +719,14 @@
715719
minimumVersion = 6.0.0;
716720
};
717721
};
722+
9F8EE48F26510BCF00BDE4AC /* XCRemoteSwiftPackageReference "MarkdownUI" */ = {
723+
isa = XCRemoteSwiftPackageReference;
724+
repositoryURL = "https://github.com/gonzalezreal/MarkdownUI";
725+
requirement = {
726+
kind = upToNextMajorVersion;
727+
minimumVersion = 0.5.1;
728+
};
729+
};
718730
/* End XCRemoteSwiftPackageReference section */
719731

720732
/* Begin XCSwiftPackageProductDependency section */
@@ -731,6 +743,11 @@
731743
isa = XCSwiftPackageProductDependency;
732744
productName = Backend;
733745
};
746+
9F8EE49026510BCF00BDE4AC /* MarkdownUI */ = {
747+
isa = XCSwiftPackageProductDependency;
748+
package = 9F8EE48F26510BCF00BDE4AC /* XCRemoteSwiftPackageReference "MarkdownUI" */;
749+
productName = MarkdownUI;
750+
};
734751
/* End XCSwiftPackageProductDependency section */
735752
};
736753
rootObject = 69EACEF724B63D5800303A16 /* Project object */;

RedditOs.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+63
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
{
22
"object": {
33
"pins": [
4+
{
5+
"package": "AttributedText",
6+
"repositoryURL": "https://github.com/gonzalezreal/AttributedText",
7+
"state": {
8+
"branch": null,
9+
"revision": "bf076de48dbb2172525486936d512e1bba062642",
10+
"version": "0.3.0"
11+
}
12+
},
13+
{
14+
"package": "combine-schedulers",
15+
"repositoryURL": "https://github.com/pointfreeco/combine-schedulers",
16+
"state": {
17+
"branch": null,
18+
"revision": "c37e5ae8012fb654af776cc556ff8ae64398c841",
19+
"version": "0.5.0"
20+
}
21+
},
422
{
523
"package": "KeychainAccess",
624
"repositoryURL": "https://github.com/kishikawakatsumi/KeychainAccess",
@@ -18,6 +36,51 @@
1836
"revision": "44450a8f564d7c0165f736ba2250649ff8d3e556",
1937
"version": "6.3.0"
2038
}
39+
},
40+
{
41+
"package": "MarkdownUI",
42+
"repositoryURL": "https://github.com/gonzalezreal/MarkdownUI",
43+
"state": {
44+
"branch": null,
45+
"revision": "e8931e37dcf777b4c03ca76aa09c10cf246a2ced",
46+
"version": "0.5.1"
47+
}
48+
},
49+
{
50+
"package": "NetworkImage",
51+
"repositoryURL": "https://github.com/gonzalezreal/NetworkImage",
52+
"state": {
53+
"branch": null,
54+
"revision": "15582b821cb097012b41b83d6219717926ec4ed6",
55+
"version": "2.1.0"
56+
}
57+
},
58+
{
59+
"package": "cmark",
60+
"repositoryURL": "https://github.com/SwiftDocOrg/swift-cmark.git",
61+
"state": {
62+
"branch": null,
63+
"revision": "9c8096a23f44794bde297452d87c455fc4f76d42",
64+
"version": "0.29.0+20210102.9c8096a"
65+
}
66+
},
67+
{
68+
"package": "SwiftCommonMark",
69+
"repositoryURL": "https://github.com/gonzalezreal/SwiftCommonMark",
70+
"state": {
71+
"branch": null,
72+
"revision": "f1575c37110a386e50da3208a04266b398bcefaa",
73+
"version": "0.1.1"
74+
}
75+
},
76+
{
77+
"package": "xctest-dynamic-overlay",
78+
"repositoryURL": "https://github.com/pointfreeco/xctest-dynamic-overlay",
79+
"state": {
80+
"branch": null,
81+
"revision": "603974e3909ad4b48ba04aad7e0ceee4f077a518",
82+
"version": "0.1.0"
83+
}
2184
}
2285
]
2386
},

RedditOs/Features/Comments/CommentRow.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import SwiftUI
99
import Backend
10+
import MarkdownUI
1011

1112
struct CommentRow: View {
1213
@StateObject private var viewModel: CommentViewModel
@@ -68,9 +69,9 @@ struct CommentRow: View {
6869
}
6970
}
7071
if let body = viewModel.comment.body {
71-
Text(body)
72+
Markdown(Document(body))
7273
.font(.body)
73-
.fixedSize(horizontal: false, vertical: true)
74+
.fixedSize(horizontal: false, vertical: true)
7475
} else {
7576
Text("Deleted comment")
7677
.font(.footnote)

RedditOs/Features/Post/PostDetailContent.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SwiftUI
99
import Backend
1010
import AVKit
1111
import Kingfisher
12+
import MarkdownUI
1213

1314
struct PostDetailContent: View {
1415
let listing: SubredditPost
@@ -17,7 +18,7 @@ struct PostDetailContent: View {
1718
@ViewBuilder
1819
var body: some View {
1920
if let text = listing.selftext ?? listing.description {
20-
Text(text)
21+
Markdown(Document(text))
2122
.font(.body)
2223
.fixedSize(horizontal: false, vertical: true)
2324
}

RedditOs/Features/Post/PostDetailHeader.swift

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct PostDetailHeader: View {
1919
.lineLimit(10)
2020
.multilineTextAlignment(.leading)
2121
.truncationMode(.tail)
22+
.fixedSize(horizontal: false, vertical: true)
2223
if let url = listing.thumbnailURL, url.pathExtension != "jpg", url.pathExtension != "png" {
2324
KFImage(url)
2425
.frame(width: 80, height: 60)

RedditOs/Features/Search/ToolbarSearchBar.swift

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct ToolbarSearchBar: View {
2727
} onCommit: {
2828
onCommit()
2929
}
30-
3130
.keyboardShortcut("f", modifiers: .command)
3231
.padding(8)
3332
.background(RoundedRectangle(cornerRadius: 8)

0 commit comments

Comments
 (0)