From 51559315c9c3063416f5679014a811eee1381fa6 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Sun, 3 Nov 2013 09:20:26 +0100 Subject: [PATCH] Simplify the generated HTML code --- markdown.m | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/markdown.m b/markdown.m index ae1bf8f..e3a2c2e 100644 --- a/markdown.m +++ b/markdown.m @@ -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:@"" - "" - "" - "" + NSString *html = [NSString stringWithFormat:@"" + "" + "" "" - "" - "%@" - "", + "%@", styles, url, [NSString stringWithUTF8String:output]]; - + free(output); return [html dataUsingEncoding:NSUTF8StringEncoding]; } \ No newline at end of file