Swift Package Index


A library for parsing and formatting strings with markdown tags in swift


  • The latest stable release is 0.0.2. Released 2 years ago.
  • The last commit to master was 2 years ago.

Swift Version Compatibility

  • 0.0.2 and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 0.0.2 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

SwiftMarkdown

SwiftMarkdown is library for parsing and formatting strings with markdown tags

Travis

Bare String With Multiple Formatting

Usage

To have your label formatted like the above your code would look like the following:

let string = """
  Swift **Markdown** Library
  Swift ~~Markdown~~ Library
  Swift *Markdown* Library
  Swift ~~**Markdown**~~ Library
  """.uppercased()

label.attributedText = string.markdown(font: label.font)

Or if you already have a NSAttributedString, simply add the markdown tags to your string and use the markdown property:

let string = "SWIFT **MARKDOWN** LIBRARY"
let attributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 20)]
let attributed = NSAttributedString(string: string, attributes: attributes)
label.attributedText = attributed.markdown

Installation

Cocoapods

pod 'SwiftMarkdown'

Swift Package Manager

Add the following as a dependency to your Package.swift:

.package(url: "https://github.com/viniciusaro/SwiftMarkdown.git", .upToNextMajor(from: "0.0.2"))

You also need to specify "SwiftMarkdown" as a dependency of the Target in which you wish to use SwiftMarkdown.

...
targets: [
  .target(
    name: "MyApp",
    dependencies: ["SwiftResolver", "SwiftMarkdown"]),
...

Features

Emphasis

*Italic*
**Bold**
~~Strikethrough~~

Headers

# H1
## H2
### H3
#### H4
##### H5
###### H6

License

SwiftMarkdown is released under an MIT license.