Skip to content

Commit

Permalink
incorporate cmark 0.18.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rhinoman committed Apr 6, 2015
1 parent db0a775 commit 49686ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions commonmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
bool entering = (ev_type == CMARK_EVENT_ENTER);
const char *info;
const char *title;
char listmarker[64];
cmark_strbuf listmarker = GH_BUF_INIT;
char *emph_delim;
int marker_width;

Expand Down Expand Up @@ -347,19 +347,20 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
// we ensure a width of at least 4 so
// we get nice transition from single digits
// to double
snprintf(listmarker, 63, "%d%s%s", list_number,
list_delim == CMARK_PAREN_DELIM ?
")" : ".",
list_number < 10 ? " " : " ");
marker_width = strlen(listmarker);
cmark_strbuf_printf(&listmarker,
"%d%s%s", list_number,
list_delim == CMARK_PAREN_DELIM ?
")" : ".",
list_number < 10 ? " " : " ");
marker_width = listmarker.size;
}
if (entering) {
if (cmark_node_get_list_type(node->parent) ==
CMARK_BULLET_LIST) {
lit(state, "* ", false);
cmark_strbuf_puts(state->prefix, " ");
} else {
lit(state, listmarker, false);
lit(state, (char *)listmarker.ptr, false);
for (i=marker_width; i--;) {
cmark_strbuf_putc(state->prefix, ' ');
}
Expand All @@ -370,6 +371,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type,
marker_width);
cr(state);
}
cmark_strbuf_free(&listmarker);
break;

case CMARK_NODE_HEADER:
Expand Down
4 changes: 2 additions & 2 deletions inlines.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ unsigned char *cmark_clean_url(cmark_chunk *url)
}

cmark_strbuf_unescape(&buf);
return cmark_strbuf_detach(&buf);
return buf.size == 0 ? NULL : cmark_strbuf_detach(&buf);
}

unsigned char *cmark_clean_title(cmark_chunk *title)
Expand All @@ -660,7 +660,7 @@ unsigned char *cmark_clean_title(cmark_chunk *title)
}

cmark_strbuf_unescape(&buf);
return cmark_strbuf_detach(&buf);
return buf.size == 0 ? NULL : cmark_strbuf_detach(&buf);
}

// Parse an autolink or HTML tag.
Expand Down

0 comments on commit 49686ff

Please sign in to comment.