CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CDMarkdownKit into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'CDMarkdownKit', '2.5.1'
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate CDMarkdownKit into your Xcode project using Carthage, specify it in your Cartfile:
github "chrisdhaan/CDMarkdownKit" == 2.5.1
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding CDMarkdownKit as a dependency is as easy as adding it to the dependencies value of your Package.swift.
Open the new CDMarkdownKit folder, and drag the CDMarkdownKit.xcodeproj into the Project Navigator of your application’s Xcode project.
It should appear nested underneath your application’s blue project icon. Whether it is above or below all the other Xcode groups does not matter.
Select the CDMarkdownKit.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the “Targets” heading in the sidebar.
In the tab bar at the top of that window, open the “General” panel.
Click on the + button under the “Embedded Binaries” section.
You will see two different CDMarkdownKit.xcodeproj folders each with two different versions of the CDMarkdownKit.framework nested inside a Products folder.
It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom CDMarkdownKit.framework.
Select the top CDMarkdownKit.framework for iOS and the bottom one for macOS.
You can verify which one you selected by inspecting the build log for your project. The build target for CDMarkdownKit will be listed as either CDMarkdownKit iOS, CDMarkdownKit macOS, CDMarkdownKit tvOS or CDMarkdownKit watchOS.
And that’s it!
The CDMarkdownKit.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
Contributing
Before contributing to CDMarkdownKit, please read the instructions detailed in our contribution guide.
*italic* or _italic_
**bold** or __bold__
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
###### Header 6
> Quote
* List
- List
+ List
`code`
```syntax```
[Link](url)

CDMarkdownTextView
It is recommended that any CDMarkdownTextView objects be initialized programmatically as it uses custom text drawing objects to render attributed strings.
A CDMarkdownTextView object will still render when initialized via a storyboard but the default behavior for the following properties will be overridden:
isScrollEnabled = true
isSelectable = false
isEditable = false
These defaults are set to avoid crashes. There still may be unforeseen crashes that occur when initializing a CDMarkdownTextView object via a storyboard.
This Swift framework handles standard markdown parsing along with the ability to parse custom elements.
For a demonstration of the capabilities of CDMarkdownKit; run the iOS Example project after cloning the repo.
Features
Requirements
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CDMarkdownKit into your Xcode project using CocoaPods, specify it in your
Podfile
:Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate CDMarkdownKit into your Xcode project using Carthage, specify it in your
Cartfile
:Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the
swift
compiler.Once you have your Swift package set up, adding CDMarkdownKit as a dependency is as easy as adding it to the
dependencies
value of yourPackage.swift
.Git Submodule
If you prefer not to use any of the aforementioned dependency managers, you can integrate CDMarkdownKit into your project manually.
cd
into your top-level project directory, and run the following command “if” your project is not initialized as a git repository:Open the new
CDMarkdownKit
folder, and drag theCDMarkdownKit.xcodeproj
into the Project Navigator of your application’s Xcode project.Select the
CDMarkdownKit.xcodeproj
in the Project Navigator and verify the deployment target matches that of your application target.Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the “Targets” heading in the sidebar.
In the tab bar at the top of that window, open the “General” panel.
Click on the
+
button under the “Embedded Binaries” section.You will see two different
CDMarkdownKit.xcodeproj
folders each with two different versions of theCDMarkdownKit.framework
nested inside aProducts
folder.Select the top
CDMarkdownKit.framework
for iOS and the bottom one for macOS.And that’s it!
Contributing
Before contributing to CDMarkdownKit, please read the instructions detailed in our contribution guide.
Usage
Initialization
Customization
Supported Markdown Elements
CDMarkdownTextView
It is recommended that any CDMarkdownTextView objects be initialized programmatically as it uses custom text drawing objects to render attributed strings.
A CDMarkdownTextView object will still render when initialized via a storyboard but the default behavior for the following properties will be overridden:
isScrollEnabled = true
isSelectable = false
isEditable = false
These defaults are set to avoid crashes. There still may be unforeseen crashes that occur when initializing a CDMarkdownTextView object via a storyboard.
Programmatic Example
Storyboard Example
CDMarkdownLabel
Programmatic Example
Storyboard Example
Author
Christopher de Haan, contact@christopherdehaan.me
Credits
CDMarkdownKit was influenced by MarkdownKit, a markdown parsing library developed by Ivan Bruel.
CDMarkdownKit adds the following functionalities:
License
CDMarkdownKit is available under the MIT license. See the LICENSE file for more info.