- Create MarkdownContentView to encapsulate MarkdownUI rendering - Replace custom AttributedString markdown parsing with MarkdownUI - Simplify ReleaseNotesView by removing manual markdown styling - Improve markdown rendering with proper support for lists, links, and formatting - Make markdown rendering easily replaceable by keeping it in a dedicated view
36 lines
705 B
Swift
36 lines
705 B
Swift
import SwiftUI
|
|
import MarkdownUI
|
|
|
|
/// A custom view that renders Markdown content using the MarkdownUI library.
|
|
/// This view encapsulates the Markdown rendering logic, making it easy to swap
|
|
/// the underlying Markdown library if needed in the future.
|
|
struct MarkdownContentView: View {
|
|
let content: String
|
|
|
|
var body: some View {
|
|
Markdown(content)
|
|
.textSelection(.enabled)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ScrollView {
|
|
MarkdownContentView(content: """
|
|
# Heading 1
|
|
|
|
This is a paragraph with **bold** and *italic* text.
|
|
|
|
## Heading 2
|
|
|
|
- List item 1
|
|
- List item 2
|
|
- List item 3
|
|
|
|
### Heading 3
|
|
|
|
Another paragraph with [a link](https://example.com).
|
|
""")
|
|
.padding()
|
|
}
|
|
}
|