Skip to content

Commit 813ab52

Browse files
committed
Add Markdown dingus
1 parent ba3140b commit 813ab52

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

Examples/MarkdownUIDemo/MarkdownUIDemo.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
824D53F92590FD6D00B19E57 /* ExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 824D53F72590FD6D00B19E57 /* ExampleView.swift */; };
1616
824D5401259104FF00B19E57 /* ExampleList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 824D5400259104FF00B19E57 /* ExampleList.swift */; };
1717
824D5402259104FF00B19E57 /* ExampleList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 824D5400259104FF00B19E57 /* ExampleList.swift */; };
18+
8250868B25B36A53007F0F07 /* DingusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8250868A25B36A53007F0F07 /* DingusView.swift */; };
1819
82C1F6D225A8792300C2CE35 /* ReadMeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82C1F6D125A8792300C2CE35 /* ReadMeView.swift */; };
1920
82C1F6D325A8792300C2CE35 /* ReadMeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82C1F6D125A8792300C2CE35 /* ReadMeView.swift */; };
2021
82C1F6E025A87DCA00C2CE35 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 82C1F6DF25A87DCA00C2CE35 /* README.md */; };
@@ -32,6 +33,7 @@
3233
824D53F02590F99C00B19E57 /* Example.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Example.swift; sourceTree = "<group>"; };
3334
824D53F72590FD6D00B19E57 /* ExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleView.swift; sourceTree = "<group>"; };
3435
824D5400259104FF00B19E57 /* ExampleList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleList.swift; sourceTree = "<group>"; };
36+
8250868A25B36A53007F0F07 /* DingusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DingusView.swift; sourceTree = "<group>"; };
3537
82C1F6D125A8792300C2CE35 /* ReadMeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadMeView.swift; sourceTree = "<group>"; };
3638
82C1F6DF25A87DCA00C2CE35 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../../../README.md; sourceTree = "<group>"; };
3739
82EAC72B258F1B7F009F513C /* MarkdownUIDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkdownUIDemoApp.swift; sourceTree = "<group>"; };
@@ -113,6 +115,7 @@
113115
children = (
114116
82EAC73C258F1B80009F513C /* Info.plist */,
115117
82EAC73D258F1B80009F513C /* macOS.entitlements */,
118+
8250868A25B36A53007F0F07 /* DingusView.swift */,
116119
);
117120
path = macOS;
118121
sourceTree = "<group>";
@@ -247,6 +250,7 @@
247250
824D53F22590F99C00B19E57 /* Example.swift in Sources */,
248251
824D53F92590FD6D00B19E57 /* ExampleView.swift in Sources */,
249252
82C1F6D325A8792300C2CE35 /* ReadMeView.swift in Sources */,
253+
8250868B25B36A53007F0F07 /* DingusView.swift in Sources */,
250254
824060102592399400F3BD7F /* AllExamplesView.swift in Sources */,
251255
);
252256
runOnlyForDeploymentPostprocessing = 0;

Examples/MarkdownUIDemo/Shared/ExampleList.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ struct ExampleList: View {
1717
}
1818
.tag(example)
1919
}
20+
21+
#if os(macOS)
22+
NavigationLink("Dingus", destination: DingusView())
23+
#endif
24+
2025
NavigationLink("README", destination: ReadMeView())
2126
NavigationLink("All", destination: AllExamplesView(examples: Example.all))
2227
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import MarkdownUI
2+
import SwiftUI
3+
4+
struct DingusView: View {
5+
@State private var text = #"""
6+
## Try CommonMark
7+
8+
You can try CommonMark here. This dingus is powered by
9+
[MarkdownUI](https://github.com/gonzalezreal/MarkdownUI), a
10+
CommonMark renderer for SwiftUI.
11+
12+
1. item one
13+
1. item two
14+
- sublist
15+
- sublist
16+
"""#
17+
18+
var body: some View {
19+
VStack {
20+
TextEditor(text: $text)
21+
.font(.system(.callout, design: .monospaced))
22+
.lineLimit(20)
23+
.padding()
24+
.background(Color(.textBackgroundColor))
25+
.border(Color.primary.opacity(0.25), width: 0.5)
26+
.padding([.top, .horizontal])
27+
28+
ScrollView {
29+
Markdown(Document(text))
30+
.padding()
31+
}
32+
.border(Color.primary.opacity(0.25), width: 0.5)
33+
.padding([.bottom, .horizontal])
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)