Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-31T04:14:43.000Z (8 months ago)
- Last Synced: 2024-05-31T05:28:09.921Z (8 months ago)
- Topics: markdown, swift, swift-package-manager, swiftui
- Language: Swift
- Homepage:
- Size: 126 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- 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
```swift
import Algorithms
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.indexed(), id: \.index) { _, 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.0.4"),
```
Include "MarkdownView" as a dependency for your target:```swift
.target(
name: "",
dependencies: [
.product(name: "MarkdownView", package: "MarkdownView"),
]
),
```