cmark

My personal build of CMark ✏️

Commit
60bd289c18e06e199260ee374ef29e3017bc4a90
Parent
be020e1928f2d0750573730483dd4cb40140935a
Author
John MacFarlane <jgm@berkeley.edu>
Date

renderer: no_linebreaks instead of no_wrap.

We generally want this option to prohibit any breaking in things like headers (not just wraps, but softbreaks).

Diffstat

3 files changed, 8 insertions, 6 deletions

Status File Name N° Changes Insertions Deletions
Modified src/commonmark.c 10 6 4
Modified src/render.c 2 1 1
Modified src/render.h 2 1 1
diff --git a/src/commonmark.c b/src/commonmark.c
@@ -258,9 +258,9 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
       }
       LIT(" ");
       renderer->begin_content = true;
-      renderer->no_wrap = true;
+      renderer->no_linebreaks = true;
     } else {
-      renderer->no_wrap = false;
+      renderer->no_linebreaks = false;
       BLANKLINE();
     }
     break;
@@ -343,8 +343,10 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
     if (CMARK_OPT_HARDBREAKS & options) {
       LIT("  ");
       CR();
-    } else if (renderer->width == 0 && !(CMARK_OPT_HARDBREAKS & options) &&
-               !(CMARK_OPT_NOBREAKS & options)) {
+    } else if (!renderer->no_linebreaks &&
+		renderer->width == 0 &&
+		!(CMARK_OPT_HARDBREAKS & options) &&
+                !(CMARK_OPT_NOBREAKS & options)) {
       CR();
     } else {
       OUT(" ", allow_wrap, LITERAL);
diff --git a/src/render.c b/src/render.c
@@ -28,7 +28,7 @@ static void S_out(cmark_renderer *renderer, const char *source, bool wrap,
   cmark_chunk remainder = cmark_chunk_literal("");
   int k = renderer->buffer->size - 1;
 
-  wrap = wrap && !renderer->no_wrap;
+  wrap = wrap && !renderer->no_linebreaks;
 
   if (renderer->in_tight_list_item && renderer->need_cr > 1) {
     renderer->need_cr = 1;
diff --git a/src/render.h b/src/render.h
@@ -20,7 +20,7 @@ struct cmark_renderer {
   bufsize_t last_breakable;
   bool begin_line;
   bool begin_content;
-  bool no_wrap;
+  bool no_linebreaks;
   bool in_tight_list_item;
   void (*outc)(struct cmark_renderer *, cmark_escaping, int32_t, unsigned char);
   void (*cr)(struct cmark_renderer *);