public
Description: Markdown processing with Nu. Use with any Nu or Objective-C project. Created by Grayson Hansard.
Homepage: http://programming.nu/posts/2007/10/10/markdown-in-nu
Clone URL: git://github.com/timburks/numarkdown.git
numarkdown / objc / markdown.m
100644 29 lines (26 sloc) 0.816 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#import <Cocoa/Cocoa.h>
#import <Nu/Nu.h>
 
static int load_nu_files(NSString *bundleIdentifier, NSString *mainFile)
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSBundle *bundle = [NSBundle bundleWithIdentifier:bundleIdentifier];
    NSString *main_path = [bundle pathForResource:mainFile ofType:@"nu"];
    if (main_path) {
        NSString *main = [NSString stringWithContentsOfFile:main_path];
        if (main) {
            id parser = [Nu parser];
            id script = [parser parse: main];
            id result = [script evalWithContext:[parser context]];
        }
    }
    [pool release];
    return 0;
}
 
void MarkdownInit()
{
    static initialized = 0;
    if (!initialized) {
        initialized = 1;
        load_nu_files(@"nu.programming.markdown", @"markdown");
    }
}