Merge branch 'master' of github.com:tanoku/sundown

This commit is contained in:
Vicent Marti 2011-07-24 23:29:23 +02:00
commit 72c9453882
3 changed files with 9 additions and 5 deletions

View file

@ -62,7 +62,7 @@ main(int argc, char **argv)
for (i = 0; i < iterations; ++i) {
ob->size = 0;
sdhtml_renderer(&renderer, 0);
sdhtml_renderer(&renderer, 0, NULL);
sd_markdown(ob, ib, &renderer, ~0);
sdhtml_free_renderer(&renderer);
}

View file

@ -24,6 +24,8 @@
#include <ctype.h>
struct html_renderopt {
void *extra;
struct {
int header_count;
int current_level;
@ -546,7 +548,7 @@ toc_finalize(struct buf *ob, void *opaque)
}
void
sdhtml_toc_renderer(struct mkd_renderer *renderer)
sdhtml_toc_renderer(struct mkd_renderer *renderer, void *extra)
{
static const struct mkd_renderer toc_render = {
NULL,
@ -584,13 +586,14 @@ sdhtml_toc_renderer(struct mkd_renderer *renderer)
struct html_renderopt *options;
options = calloc(1, sizeof(struct html_renderopt));
options->flags = HTML_TOC;
options->extra = extra;
memcpy(renderer, &toc_render, sizeof(struct mkd_renderer));
renderer->opaque = options;
}
void
sdhtml_renderer(struct mkd_renderer *renderer, unsigned int render_flags)
sdhtml_renderer(struct mkd_renderer *renderer, unsigned int render_flags, void *extra)
{
static const char *xhtml_close = "/>\n";
static const char *html_close = ">\n";
@ -632,6 +635,7 @@ sdhtml_renderer(struct mkd_renderer *renderer, unsigned int render_flags)
options = calloc(1, sizeof(struct html_renderopt));
options->flags = render_flags;
options->close_tag = (render_flags & HTML_USE_XHTML) ? xhtml_close : html_close;
options->extra = extra;
memcpy(renderer, &renderer_default, sizeof(struct mkd_renderer));
renderer->opaque = options;

View file

@ -47,10 +47,10 @@ int
sdhtml_tag(const char *tag_data, size_t tag_size, const char *tagname);
extern void
sdhtml_renderer(struct mkd_renderer *renderer, unsigned int render_flags);
sdhtml_renderer(struct mkd_renderer *renderer, unsigned int render_flags, void *extra);
extern void
sdhtml_toc_renderer(struct mkd_renderer *renderer);
sdhtml_toc_renderer(struct mkd_renderer *renderer, void *extra);
extern void
sdhtml_free_renderer(struct mkd_renderer *renderer);