SwiftMarkdown

master

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

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.

Description

  • Swift Tools 4.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Oct 19 2024 22:36:53 GMT-0900 (Hawaii-Aleutian Daylight Time)