https://github.com/zunda-pixel/markdownview
A Swift package for rendering View with swift-markdown
https://github.com/zunda-pixel/markdownview
markdown swift swift-package-manager swiftui
Last synced: 2 months ago
JSON representation
A Swift package for rendering View with swift-markdown
- Host: GitHub
- URL: https://github.com/zunda-pixel/markdownview
- Owner: zunda-pixel
- License: apache-2.0
- Created: 2023-09-04T05:14:40.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T16:01:36.000Z (3 months ago)
- Last Synced: 2025-05-07T22:47:08.705Z (2 months ago)
- Topics: markdown, swift, swift-package-manager, swiftui
- Language: Swift
- Homepage:
- Size: 142 KB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MarkdownView
MarkdownView uses [swift-markdown](https://github.com/apple/swift-markdown) as Parser
[](https://swiftpackageindex.com/zunda-pixel/MarkdownView)
[](https://swiftpackageindex.com/zunda-pixel/MarkdownView)
```swift
import MarkdownView
import Markdown
import SwiftUIstruct MarkdownView: View {
let markdown: Stringvar 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:
```swift
.package(url: "https://github.com/zunda-pixel/MarkdownView", from: "0.4.0"),
```
Include "MarkdownView" as a dependency for your target:```swift
.target(
name: "",
dependencies: [
.product(name: "MarkdownView", package: "MarkdownView"),
]
),
```