• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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"))

More Repositories

1

Peek

All new design. Inspect your iOS application at runtime.
Swift
2,601
star
2

SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS
Swift
940
star
3

InkKit

Drawing and Geometry made easy on iOS - now in Swift 3.0
Swift
373
star
4

iMessageStyleReveal

Adds iMessage style timestamp support. Written in Swift!
Swift
147
star
5

GraphicsRenderer

A drop-in UIGraphicsRenderer port -- CrossPlatform, Swift 4, Image & PDF
Swift
109
star
6

Warrant

Data validation made easy. In code and from Interface Builder.
Swift
54
star
7

Stack

A Type-Safe, Thread-Safe-ish approach to CoreData in Swift
Swift
48
star
8

SwiftUIPlus

SwiftUI additions and helpers that are missing from the official implementation.
Swift
24
star
9

Color

A Swifty type-safe abstraction around color models
Objective-C
23
star
10

Feedback

Familiar, easy state-driven haptics, audio and more
Swift
22
star
11

ColumnView

A column-view navigation controller that behaves similarly to Files and Finder
Swift
21
star
12

Logging

Apple's SwiftLog + OSLog style StringInterpolation
Swift
16
star
13

Objective-C-Style-Guide

Objective-C Style Guide
15
star
14

SwiftUIBackportsDemo

A collection of Demo's for the SwiftUI Backports.
Swift
15
star
15

SwiftBackports

A collection of Swift backports for earlier versions of iOS, macOS, tvOS and watchOS
Swift
13
star
16

Abracadabra

A truly plug 'n' play solution for securing your code.
Objective-C
12
star
17

Snaply

Drop-in snapping behaviour for any scroll/collection/table/view using arbitrary points!
Swift
9
star
18

CornerMasking

SPXMasking is category on CALayer that allows you to specify different a corner radius for each corner of a CALayer.
Objective-C
8
star
19

MarkdownTextDemo

A demo app for showcasing the MarkdownText library.
Swift
7
star
20

SVGRenderer

An SVG renderer using the familiar GraphicsRenderer API.
Swift
6
star
21

ActivityView

Moved to SwiftUI-Plus/ActivityView
5
star
22

Storage

Moved to SwiftUI-Plus/DefaultStorage
5
star
23

Media

Moved to SwiftUI-Plus/Media
5
star
24

ghost-app-extract

Allows you to create better excerpt's in your Ghost blog posts.
JavaScript
4
star
25

AppManifest

Swift
4
star
26

SwiftLayout

A Swift library for programmatically dealing with AutoLayout
Swift
4
star
27

FlowLayout-Demo

A high-performance flow layout that provides global headers, footers, section backgrounds and various configurations.
Swift
4
star
28

Endpoints

A generic Swift networking library inspired by SwiftUI APIs
Swift
4
star
29

Analytics

Swift
3
star
30

PhotoLibrary

Photo library picker for iOS
Swift
2
star
31

primo

The first script to install a newly installed Mac! This will install common terminal utilities & applications.
Shell
2
star
32

Whos-Who

Who's Who sample code for job interview.
Objective-C
2
star
33

SPXLayout

AutoLayout the programmatic way
Objective-C
2
star
34

SPXSubscripting

This is a library for adding subscripting support to various Foundation classes. It also adds some interesting solutions to working with NSString's, NSAttributedString's and their attributes.
Objective-C
2
star
35

SPXDataSources

DataSource implementations for UITableView and UICollection, plus more...
Objective-C
2
star
36

Populate

Data providers for populating your data views.
Swift
2
star
37

bash

Various bash scripts I've written to simply my development and sometimes just to make me smile.
Shell
2
star
38

DownloadService

A Swift service for handling downloads and their associated resources.
Swift
1
star
39

SwiftHelpDemo

A demo project for showcasing SwiftHelp
Swift
1
star
40

SwiftHelp

A SwiftUI library for building interactive help systems in your apps
Swift
1
star
41

Development-Environment

All files, settings and configurations I use for my Development Environment's
1
star
42

FlowLayout

A high-performance flow layout that provides global headers, footers, section backgrounds and various configurations.
Swift
1
star
43

SPXCacheManager

A highly configurable and reusable library for handling caching in your iOS apps. Not only for images!!
Objective-C
1
star
44

SPXKeychain

My iOS Keychain Wrapper
Objective-C
1
star
45

PGTest-XCTest

Swift
1
star
46

ScaledMetric

A SwiftUI dynamic property wrapper (a back-port) that scales a numeric value. iOS, macOS, tvOS, watchOS
Swift
1
star
47

Snippex

My own personal library of reusable code that compiles and standardises some classes across iOS and OSX.
Objective-C
1
star
48

CellProvider

A generic cell provider implementation in Swift
Shell
1
star