Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
executable file 45 lines (31 sloc) 1.29 KB
// NSString-Markdown.m
#import "NSString_Markdown.h"
#import "NoteObject.h"
@implementation NSString (Markdown)
+ (NSString*)stringWithProcessedMarkdown:(NSString*)inputString
NSString* mdScriptPath = [[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Markdown_1.0.1"] stringByAppendingPathComponent:@""];
NSTask* task = [[NSTask alloc] init];
NSMutableArray* args = [NSMutableArray array];
[args addObject:mdScriptPath];
[task setArguments:args];
NSPipe* stdinPipe = [NSPipe pipe];
NSPipe* stdoutPipe = [NSPipe pipe];
NSFileHandle* stdinFileHandle = [stdinPipe fileHandleForWriting];
NSFileHandle* stdoutFileHandle = [stdoutPipe fileHandleForReading];
[task setStandardInput:stdinPipe];
[task setStandardOutput:stdoutPipe];
[task setLaunchPath:@"/usr/bin/perl"];
[task launch];
[stdinFileHandle writeData:[inputString dataUsingEncoding:NSUTF8StringEncoding]];
[stdinFileHandle closeFile];
NSData* outputData = [stdoutFileHandle readDataToEndOfFile];
NSString* outputString = [[[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding] autorelease];
[stdoutFileHandle closeFile];
[task waitUntilExit];
return outputString;
Jump to Line
Something went wrong with that request. Please try again.