Contents

viniciusaro/swiftmarkdown

SwiftMarkdown is library for parsing and formatting strings with markdown tags

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.

Package Metadata

Repository: viniciusaro/swiftmarkdown

Default branch: master

README: README.md