Skip to content

Commit 295e3e6

Browse files
committed
fix: Fix diff code errors.
1 parent 5443f04 commit 295e3e6

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Example/Shared/DemoList.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import SwiftUI
99

1010
struct DemoList: View {
11+
@Environment(\.openURL) var openURL
1112
@State private var selection: String? = "Home"
1213
var body: some View {
1314
NavigationView {
@@ -22,6 +23,14 @@ struct DemoList: View {
2223
Text("\(selection ?? "Company Inc")")
2324
Spacer()
2425
#if os(macOS)
26+
Button(action: {
27+
openURL(URL(string: "https://jaywcjlove.github.io/markdown")!)
28+
}, label: {
29+
Image(systemName: "network")
30+
.resizable() // 它将调整大小,以便填充所有可用空间
31+
.aspectRatio(contentMode: .fit)
32+
.font(.system(size: 18))
33+
})
2534
Button(action: {
2635
NSApp.keyWindow?.firstResponder?.tryToPerform(#selector(NSSplitViewController.toggleSidebar(_:)), with: nil)
2736
}, label: {

Example/Shared/Group/CodeGroup.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ struct CodeGroup: View {
3131
}
3232
```
3333
34+
```diff
35+
@@ -4,6 +4,5 @@
36+
- let foo = bar.baz([1, 2, 3]);
37+
- foo = foo + 1;
38+
+ const foo = bar.baz([1, 2, 3]) + 1;
39+
console.log(`foo: ${foo}`);
40+
```
41+
3442
```jsx
3543
import CodeMirror from '@uiw/react-codemirror';
3644
import { javascript } from '@codemirror/lang-javascript';

Sources/Markdown/MarkdownWebView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public class MarkdownWebView: CustomView, WKNavigationDelegate {
8989
let content = """
9090
\(value)
9191
""".replacingOccurrences(of: "`", with: "\\`", options: .literal, range: nil)
92-
let end = "`; markdownPreview(content.replace(/\\\\`/g, '`'));"
92+
.replacingOccurrences(of: "{", with: "\\{", options: .literal, range: nil)
93+
let end = "`; markdownPreview(content.replace(/\\\\`/g, '`').replace(/\\\\{/g, '{'));"
9394

9495
let script = first + content + end
9596
callJavascript(javascriptString: script)

0 commit comments

Comments
 (0)