Skip to content

Text transformation functions for implementing a markdown toolbar in an iOS app.

License

Notifications You must be signed in to change notification settings

bnickel/SEMarkdownEditor

Repository files navigation

SEMarkdownEditor

SEMarkdownEditor is a port of Pagedown's Markdown.Editor.js transformation logic to Objective-C. While this does not provide rendering capabilities, it does allow you to create a full-fledged markdown toolbar for your UITextView similar to what you would see on StackExchange sites.

Example

Performing any transformation is a matter of getting the text and selection information from your UITextView, performing a transformation and updating the text view with the new text and selected region:

- (IBAction)toggleBoldface:(id)sender
{
    SEMarkdownTextChunks *chunks = [self.textView SE_textChunksFromSelection];
    [chunks toggleBoldface];
    [self.textView SE_updateWithTextChunks:chunks actionName:NSLocalizedString(@"markdown.boldface", @"Boldface")];
}
@IBAction func toggleBoldface(sender:AnyObject) {
	let chunks = textView.SE_textChunksFromSelection()
	chunks.toggleBoldface()
	textView.SE_updateWithTextChunks(chunks, actionName:NSLocalizedString("markdown.boldface", comment: "Boldface"))
}

Demo

The project contains an iOS demo with a simple toolbar demonstrating how to wire features to a toolbar. Open the project in Xcode 6 or later and run the iOS Demo target.

Installation

pod 'SEMarkdownEditor'

About

Text transformation functions for implementing a markdown toolbar in an iOS app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published