diff options
Diffstat (limited to 'src/commonmark.c')
-rw-r--r-- | src/commonmark.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/commonmark.c b/src/commonmark.c index f5a352d..ed6eff3 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -172,6 +172,8 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, char listmarker[LISTMARKER_SIZE]; char *emph_delim; bufsize_t marker_width; + bool allow_wrap = renderer->width > 0 && !(CMARK_OPT_NOBREAKS & options) && + !(CMARK_OPT_HARDBREAKS & options); // Don't adjust tight list status til we've started the list. // Otherwise we loose the blank line between a paragraph and @@ -327,7 +329,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, break; case CMARK_NODE_TEXT: - OUT(cmark_node_get_literal(node), true, NORMAL); + OUT(cmark_node_get_literal(node), allow_wrap, NORMAL); break; case CMARK_NODE_LINEBREAK: @@ -338,10 +340,14 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, break; case CMARK_NODE_SOFTBREAK: - if (renderer->width == 0 && !(CMARK_OPT_HARDBREAKS & options)) { + if (CMARK_OPT_HARDBREAKS & options) { + LIT(" "); + CR(); + } else if (renderer->width == 0 && !(CMARK_OPT_HARDBREAKS & options) && + !(CMARK_OPT_NOBREAKS & options)) { CR(); } else { - OUT(" ", true, LITERAL); + OUT(" ", allow_wrap, LITERAL); } break; @@ -355,7 +361,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, if (code_len == 0 || code[0] == '`') { LIT(" "); } - OUT(cmark_node_get_literal(node), true, LITERAL); + OUT(cmark_node_get_literal(node), allow_wrap, LITERAL); if (code_len == 0 || code[code_len - 1] == '`') { LIT(" "); } @@ -435,7 +441,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, OUT(cmark_node_get_url(node), false, URL); title = cmark_node_get_title(node); if (safe_strlen(title) > 0) { - OUT(" \"", true, LITERAL); + OUT(" \"", allow_wrap, LITERAL); OUT(title, false, TITLE); LIT("\""); } |