MarkdownView
A Swift package for rendering View with swift-markdown
Install / Use
/learn @zunda-pixel/MarkdownViewREADME
MarkdownView
MarkdownView uses swift-markdown as Parser
<img width="644" alt="Markdown Sample" src="https://github.com/zunda-pixel/MarkdownView/assets/47569369/38bd1d7f-ec8d-4380-90ef-dc882375fa59"><br> <img width="300" alt="Markdown Doxygen Document" src="https://github.com/user-attachments/assets/4d7e207d-b43a-46c2-8a33-63ee9a252436" />
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)
}
}
}
}
}
Adding MarkdownView as a Dependency
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"),
]
),