https://github.com/jaywcjlove/swiftui-markdown
Render Markdown text in SwiftUI.
https://github.com/jaywcjlove/swiftui-markdown
ios macos markdown markdown-preview markdown-viewer swift swift5 swiftui
Last synced: 3 months ago
JSON representation
Render Markdown text in SwiftUI.
- Host: GitHub
- URL: https://github.com/jaywcjlove/swiftui-markdown
- Owner: jaywcjlove
- License: mit
- Created: 2022-03-10T17:01:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-02T14:53:36.000Z (3 months ago)
- Last Synced: 2025-04-13T12:08:26.121Z (3 months ago)
- Topics: ios, macos, markdown, markdown-preview, markdown-viewer, swift, swift5, swiftui
- Language: Swift
- Homepage: https://jaywcjlove.github.io/swiftui-markdown
- Size: 1.88 MB
- Stars: 103
- Watchers: 4
- Forks: 14
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
SwiftUI Markdown
===[](https://jaywcjlove.github.io/#/sponsor)
[](https://github.com/jaywcjlove/markdown/actions/workflows/ci.yml)
Render Markdown text in SwiftUI. It is a preview based on the [`Marked`](https://github.com/markedjs/marked) implementation.
✦ My macOS/iOS application ✦
https://user-images.githubusercontent.com/1680273/159059803-d844769b-36ad-44c1-a296-a657de8d099c.mov



## Installation
You can add MarkdownUI to an Xcode project by adding it as a package dependency.
1. From the File menu, select Add Packages…
2. Enter https://github.com/jaywcjlove/swiftui-markdown the Search or Enter Package URL search field
3. Link `Markdown` to your application targetOr add the following to `Package.swift`:
```swift
.package(url: "https://github.com/jaywcjlove/swiftui-markdown", from: "1.0.0")
```Or [add the package in Xcode](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app).
## Usage
```swift
import SwiftUI
import Markdownstruct ContentView: View {
@State private var mdStr: String = """
## Hello World
Render Markdown text in SwiftUI.
"""
var body: some View {
VStack {
Markdown(content: $mdStr)
TextEditor(text: $mdStr)
}
}
}
```### `.markdownStyle()`
Setting markdown related styles.
```swift
Markdown(content: $mdStr)
.markdownStyle(
MarkdownStyle(
padding: 0, paddingTop: 115, paddingBottom: 2, paddingLeft: 130, paddingRight: 5
)
)
``````swift
Markdown(content: $mdStr)
.markdownStyle(MarkdownStyle(padding: 35 ))
```## Configure
## Contributors
As always, thanks to our amazing contributors!
Made with [contributors](https://github.com/jaywcjlove/github-action-contributors).
## License
Licensed under the MIT License.