Marklight alternatives and similar libraries
Based on the "Text" category.
Alternatively, view Marklight alternatives based on common mentions on social networks and blogs.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of Marklight or a related project?
Markdown syntax highlighter for iOS and macOS.
Marklight is a drop in component to easily add realtime Markdown syntax highlight on any user editable text view in iOS and macOS applications. Marklight doesn't include HTML generation from Markdown, but you can use one of the many other components available like Markingbird.
Regular expressions are taken from Markingbird, a Markdown parser and html generator.
- [x] Applicable to any
NSTextStoragesubclass ready to use.
- [x] Struct optimized for performances.
- [x] Swift 4.1 compatible.
- [x] Dynamic text style supported.
- [x] Choose markdown syntax color.
- [x] Choose font and color for code blocks.
- [x] Choose font and color for quotes.
- [x] Choose dynamic type font text style.
- [x] Quote indentation.
- [x] Documented.
- [x] macOS compatibility.
- [ ] Parsing tests.
- [ ] Performance tests.
- iOS 8.0+
- Xcode 9.3+
- macOS 10.11+
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.0.0+ is required to build Marklight.
To integrate Marklight into your Xcode project using CocoaPods, specify it in your
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! pod 'Marklight'
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
$ brew update $ brew install carthage
To integrate Marklight into your Xcode project using Carthage, specify it in your
carthage update --platform iOS to build the framework and drag the built
Marklight.framework into your Xcode project.
Add the Marklight Xcode project to your own. Then add the
Marklight framework as desired to the embedded binaries of your app's target.
In this repository you can find a sample project with few lines of code in the
ViewController class for a jumpstart.
Sample code is written in Swift but Objective-C should be supported too, if you find an incompatibility please open an issue.
The easiest way to crete a user editable
UITextView with markdown syntax highlight is to use the provided
MarklightTextStorage class as
NSTextStorage and add the
textLayout to the
MarklightTextStorage text storage.
Import Marklight modules into your Swift class
or if you are writing in Objective-C
Keep in mind the you have to let the project generate the Bridging Header otherwise the integration may fail.
UIViewController subclass keep a strong instance of the this
let textStorage = MarklightTextStorage()
Customize the appearance as desired:
- Dynamic text style.
- Markdown syntax color.
- Code's font and color.
- Quotes' font and color.
As per Apple's documentation it should be enough to assign the
NSLayoutManager to the
NSTextStorage subclass, in our case
However I'm experiencing some crashes if I want to preload some text instead of letting the user start from scratch with a new text. A workaround is proposed below.
For simplicity we assume you have a
String to be highlighted inside an editable
UITextView loaded from a storyboard.
let string = "# My awesome markdown string"
string to an
let attributedString = NSAttributedString(string: string)
Set the loaded string to the
textView.attributedText = attributedString
Append the loaded string to the
Marklight is released under the MIT license. See LICENSE for details.
*Note that all licence references and agreements mentioned in the Marklight README section above are relevant to that project's source code only.