forked from toland/qlmarkdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneratePreviewForURL.m
More file actions
30 lines (24 loc) · 940 Bytes
/
GeneratePreviewForURL.m
File metadata and controls
30 lines (24 loc) · 940 Bytes
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
30
#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)
{
@autoreleasepool {
NSData *data = renderMarkdown((__bridge NSURL*) url);
if (data) {
NSDictionary *props = [[NSDictionary alloc] init];
QLPreviewRequestSetDataRepresentation(preview, (__bridge CFDataRef)data, kUTTypeHTML, (__bridge CFDictionaryRef)props);
}
return noErr;
}
}
void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
{
// implement only if supported
}