public
Description: QuickLook generator for Markdown files.
Homepage: http://fiatdev.com
Clone URL: git://github.com/toland/qlmarkdown.git
qlmarkdown / GeneratePreviewForURL.m
100644 29 lines (22 sloc) 0.888 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 <QuickLook/QuickLook.h>
#import <Cocoa/Cocoa.h>
#include "markdown.h"
 
/* -----------------------------------------------------------------------------
Generate a preview for file
 
This function's job is to create preview for designated file
-------------------------------------------------------------------------- */
 
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
CFURLRef url, CFStringRef contentTypeUTI,
CFDictionaryRef options)
{
    CFDataRef data = (CFDataRef) renderMarkdown((NSURL*) url);
 
    if (data) {
CFDictionaryRef props = (CFDictionaryRef) [NSDictionary dictionary];
        QLPreviewRequestSetDataRepresentation(preview, data, kUTTypeHTML, props);
    }
 
    return noErr;
}
 
void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
{
    // implement only if supported
}