MarkdownView uses swift-markdown as Parser
import MarkdownView
import Markdown
import SwiftUI
struct MarkdownView: View {
let markdown: String
var contents: [MarkupContent] {
let document = Document(
parsing: markdown,
options: [.parseBlockDirectives, .parseSymbolLinks, .parseMinimalDoxygen, .parseSymbolLinks]
)
return MarkdownViewParser.parse(document: document)
}
var body: some View {
ScrollView {
LazyVStack(alignment: .leading, spacing: 10) {
ForEach(contents, id: \.self) { content in
MarkupContentView(content: content)
}
}
}
}
}
To use the MarkdownView plugin in a SwiftPM project, add the following line to the dependencies in your Package.swift file:
.package(url: "https://github.com/zunda-pixel/MarkdownView", from: "0.4.0"),
Include "MarkdownView" as a dependency for your target:
.target(
name: "<target>",
dependencies: [
.product(name: "MarkdownView", package: "MarkdownView"),
]
),