Markdowner 2.0.0

Markdowner 2.0.0

Maintained by Reynaldo Aguilar.



  • By
  • rlaguilar

Markdowner

CI Status Version License Platform

Markdowner is a library intended to edit and preview markdown in real time. It supports custom markdown elements or use only a subset of the standard ones. Custom fonts and colors are also supported.

Preview of Library Demo

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Requires iOS 10 or later and Swift 4.1 or later.

Installation

Markdowner is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Markdowner'

How to use it

The main entry point ot use Markdowner is using the custom type MarkdownTextView, which is just a sublcass of UITextView.

var textView = MarkdownTextView(frame: parentView.bounds)
parentView.addSubview(textView)
textView.frame = ... // setup text view position inside its parent
textView.text = ... // set the initial markdown to display, if any

If you want to customize the default look of the markdown elements, you can use the class StylesConfiguration.

textView.stylesConfiguration = StylesConfiguration(
    baseFont: UIFont.systemFont(ofSize: 18),
    textColor: UIColor.darkGray,
    symbolsColor: UIColor.red
)

Creating custom elements is as simple as subclassing the type MarkdownElement, and then calling the function textView.use(elements: [MarkdownElement]) passing as arguments the list of markdown elements that you want to use. As a guide for creating new elements you could use any of the already implemented ones inside the folder Markdowner/Classes/Default Elements.

It's important to note that for now Markdowner doesn't support initialization from Storyboards.

Author

rlaguilar, [email protected]

License

Markdowner is available under the MIT license. See the LICENSE file for more info.