cmark

My personal build of CMark ✏️

Commit
becfb75e9f2f85cfff18aec49fd96e252f737eb2
Parent
6f1f4e312016261143b3ebf91e35a1ddb805cdf1
Author
John MacFarlane <jgm@berkeley.edu>
Date

render: only emit actual newline when escape mode is LITERAL.

For markdown content, e.g., in other contexts we want some kind of escaping, not a literal newline.

Diffstat

1 file changed, 16 insertions, 14 deletions

Status File Name N° Changes Insertions Deletions
Modified src/render.c 30 16 14
diff --git a/src/render.c b/src/render.c
@@ -82,21 +82,23 @@ static void S_out(cmark_renderer *renderer, const char *source, bool wrap,
         }
       }
 
-    } else if (c == 10) {
-      cmark_strbuf_putc(renderer->buffer, '\n');
-      renderer->column = 0;
-      renderer->begin_line = true;
-      renderer->begin_content = true;
-      renderer->last_breakable = 0;
     } else if (escape == LITERAL) {
-      cmark_render_code_point(renderer, c);
-      renderer->begin_line = false;
-      // we don't set 'begin_content' to false til we've
-      // finished parsing a digit.  Reason:  in commonmark
-      // we need to escape a potential list marker after
-      // a digit:
-      renderer->begin_content =
-          renderer->begin_content && cmark_isdigit(c) == 1;
+      if (c == 10) {
+        cmark_strbuf_putc(renderer->buffer, '\n');
+        renderer->column = 0;
+        renderer->begin_line = true;
+        renderer->begin_content = true;
+        renderer->last_breakable = 0;
+      } else {
+        cmark_render_code_point(renderer, c);
+        renderer->begin_line = false;
+        // we don't set 'begin_content' to false til we've
+        // finished parsing a digit.  Reason:  in commonmark
+        // we need to escape a potential list marker after
+        // a digit:
+        renderer->begin_content =
+            renderer->begin_content && cmark_isdigit(c) == 1;
+      }
     } else {
       (renderer->outc)(renderer, escape, c, nextc);
       renderer->begin_line = false;