From 9c3a7023014f961197bc27ff8360ce9e1b1d6c29 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 9 Apr 2016 11:44:58 -0700 Subject: Fixed a number of issues relating to line wrapping. - Extend CMARK_OPT_NOBREAKS to all renderers and add `--nobreaks`. - Do not autowrap, regardless of width parameter, if CMARK_OPT_NOBREAKS is set. - Fixed CMARK_OPT_HARDBREAKS for LaTeX and man renderers. - Ensure that no auto-wrapping occurs if CMARK_OPT_NOBREAKS is enabled, or if output is CommonMark and CMARK_OPT_HARDBREAKS is enabled. - Updated man pages. --- src/latex.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/latex.c') diff --git a/src/latex.c b/src/latex.c index cd2f6f3..904a1b9 100644 --- a/src/latex.c +++ b/src/latex.c @@ -223,6 +223,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, cmark_list_type list_type; const char *roman_numerals[] = {"", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x"}; + bool allow_wrap = renderer->width > 0 && !(CMARK_OPT_NOBREAKS & options); // avoid warning about unused parameter: (void)(options); @@ -334,7 +335,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: @@ -343,10 +344,13 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, break; case CMARK_NODE_SOFTBREAK: - if (renderer->width == 0) { + if (options & CMARK_OPT_HARDBREAKS) { + LIT("\\\\"); + CR(); + } else if (renderer->width == 0 && !(CMARK_OPT_NOBREAKS & options)) { CR(); } else { - OUT(" ", true, NORMAL); + OUT(" ", allow_wrap, NORMAL); } break; -- cgit v1.2.3