Created
October 17, 2011 01:31
-
-
Save CarterA/1291718 to your computer and use it in GitHub Desktop.
Made on a Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create and fill a buffer for with the raw markdown data. | |
struct sd_callbacks callbacks; | |
struct html_renderopt options; | |
const char *rawMarkdown = [markdownContent cStringUsingEncoding:NSUTF8StringEncoding]; | |
struct buf *inputBuffer = bufnew(strlen(rawMarkdown)); | |
bufputs(inputBuffer, rawMarkdown); | |
// Parse the markdown into a new buffer using Sundown. | |
struct buf *outputBuffer = bufnew(64); | |
sdhtml_renderer(&callbacks, &options, 0); | |
struct sd_markdown *markdown = sd_markdown_new(0, 16, &callbacks, &options); | |
sd_markdown_render(outputBuffer, inputBuffer->data, inputBuffer->size, markdown); | |
sd_markdown_free(markdown); | |
NSString *parsedContent = [NSString stringWithCString:bufcstr(outputBuffer) encoding:NSUTF8StringEncoding]; | |
bufrelease(inputBuffer); | |
bufrelease(outputBuffer); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<article class="post"> | |
<header class="post-header"> | |
<h1>{{title}}</h1> | |
<span class="date">{{dateString}}</span> | |
</header> | |
<section class="post-content"> | |
{{{content}}} | |
</section> | |
</article> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment