Skip to content

Commit

Permalink
fix: Fix diff code errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 12, 2022
1 parent 5443f04 commit 295e3e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Example/Shared/DemoList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI

struct DemoList: View {
@Environment(\.openURL) var openURL
@State private var selection: String? = "Home"
var body: some View {
NavigationView {
Expand All @@ -22,6 +23,14 @@ struct DemoList: View {
Text("\(selection ?? "Company Inc")")
Spacer()
#if os(macOS)
Button(action: {
openURL(URL(string: "https://jaywcjlove.github.io/markdown")!)
}, label: {
Image(systemName: "network")
.resizable() // 它将调整大小,以便填充所有可用空间
.aspectRatio(contentMode: .fit)
.font(.system(size: 18))
})
Button(action: {
NSApp.keyWindow?.firstResponder?.tryToPerform(#selector(NSSplitViewController.toggleSidebar(_:)), with: nil)
}, label: {
Expand Down
8 changes: 8 additions & 0 deletions Example/Shared/Group/CodeGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ struct CodeGroup: View {
}
```
```diff
@@ -4,6 +4,5 @@
- let foo = bar.baz([1, 2, 3]);
- foo = foo + 1;
+ const foo = bar.baz([1, 2, 3]) + 1;
console.log(`foo: ${foo}`);
```
```jsx
import CodeMirror from '@uiw/react-codemirror';
import { javascript } from '@codemirror/lang-javascript';
Expand Down
3 changes: 2 additions & 1 deletion Sources/Markdown/MarkdownWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public class MarkdownWebView: CustomView, WKNavigationDelegate {
let content = """
\(value)
""".replacingOccurrences(of: "`", with: "\\`", options: .literal, range: nil)
let end = "`; markdownPreview(content.replace(/\\\\`/g, '`'));"
.replacingOccurrences(of: "{", with: "\\{", options: .literal, range: nil)
let end = "`; markdownPreview(content.replace(/\\\\`/g, '`').replace(/\\\\{/g, '{'));"

let script = first + content + end
callJavascript(javascriptString: script)
Expand Down

0 comments on commit 295e3e6

Please sign in to comment.