Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# MarkdownView

MarkdownView uses [swift-markdown](https://github.com/apple/swift-markdown) as Parser

Markdown Sample

```swift
import Algorithms
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.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"),
]
),
```