1 Star 0 Fork 0

從尛就壞ˇˇ / MarkdownText

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

macOS ios swift

MarkdownText

A native SwiftUI view for rendering Markdown text in an iOS or macOS app.

Preview

Markdown Text Screenshot

Sponsor

Building useful libraries like these, takes time away from my family. I build these tools in my spare time because I feel its important to give back to the community. Please consider Sponsoring me as it helps keep me working on useful libraries like these 😬

You can also give me a follow and a 'thanks' anytime.

Twitter

Supported Markdown

  • Headings
  • Paragraphs
  • Quotes
  • Inline formatting
    • Strong/Bold
    • Emphasis/Italic
    • Strikethrough
    • Code
    • Links (non interactive only)
  • Lists
    • Ordered
    • Unordered
    • Checklist (GitHub style)
  • Thematic Breaks
  • Code Blocks
  • Images
    • A full backport of AsyncImage is included

Features

Style APIs

Adopting the familiar SwiftUI style-based APIs, you can customize the appearance of almost all markdown elements either individually or composed.

struct CustomUnorderedBullets: UnorderedListBulletMarkdownStyle {
    func makeBody(configuration: Configuration) -> some View {
        // you can also provide a completely new View if preferred 👍
        configuration.label
            .foregroundColor(.blue)
    }
}

You can even customize animations since the library is composed of 100% SwiftUI elements only.

struct ScaledImageStyle: ImageMarkdownStyle {
    // image will scale up as its loaded, moving content out of the way
    func makeBody(configuration: Configuration) -> some View {
        configuration.label
            .transition(.scale)
    }
}

Modifiers for styling and visibility can also be placed anywhere in your SwiftUI hierarchy, just as you'd expect:

NavigationView {
    MarkdownText(markdown)
}
// Styling
.markdownQuoteStyle(.inset)
.markdownOrderedListBulletStyle(.tinted)
.markdownImageStyle(.animated)

// Visibility
.markdownCode(.visible)
.markdownThematicBreak(.hidden)

Demo App

A MarkdownText Demo is also available to better showcase the libraries capabilities.

Usage

Using the view couldn't be easier:

MarkdownText("Some **markdown** text")
LazyMarkdownText(someMassiveMarkdownText)

There's even a LazyMarkdownText view that loads its view's lazily for those cases where you need improved scrolling and loading performance.

Installation

You can install manually (by copying the files in the Sources directory) or using Swift Package Manager (preferred)

To install using Swift Package Manager, add this to the dependencies section of your Package.swift file:

.package(url: "https://github.com/shaps80/MarkdownText.git", .upToNextMinor(from: "1.0.0"))

MIT License Copyright (c) 2021 Shaps Benkau Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

pull from github 展开 收起
Swift 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xuguangjian/MarkdownText.git
git@gitee.com:xuguangjian/MarkdownText.git
xuguangjian
MarkdownText
MarkdownText
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891