Skip to content

Commit

Permalink
Merge pull request #28 from mathiasbynens/master
Browse files Browse the repository at this point in the history
Simplify the generated HTML code
  • Loading branch information
Phillip Toland committed Mar 13, 2014
2 parents 978987a + 5155931 commit ec46a92
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions markdown.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,24 @@
pathForResource:@"styles" ofType:@"css"]
encoding:NSUTF8StringEncoding
error:nil];

NSStringEncoding usedEncoding = 0;
NSError *e = nil;

NSString *source = [NSString stringWithContentsOfURL:url usedEncoding:&usedEncoding error:&e];

if (usedEncoding == 0) {
NSLog(@"Wasn't able to determine encoding for file “%@", [url path]);
}

char *output = convert_markdown_to_string([source UTF8String]);
NSString *html = [NSString stringWithFormat:@"<html>"
"<head>"
"<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />"
"<style type=\"text/css\">%@</style>"
NSString *html = [NSString stringWithFormat:@"<!DOCTYPE html>"
"<meta charset=utf-8>"
"<style>%@</style>"
"<base href=\"%@\"/>"
"</head>"
"<body>%@</body>"
"</html>",
"%@",
styles, url, [NSString stringWithUTF8String:output]];

free(output);
return [html dataUsingEncoding:NSUTF8StringEncoding];
}

0 comments on commit ec46a92

Please sign in to comment.