Commit f8ed51c9f7b47f5e5a0ba434d7a6b3f6edb395e0

Martin Mitas 2019-05-05T16:11:21

md_analyze_line: Simplify. Move some common code from multiple branches to one (and more appropriate) place.

diff --git a/md4c/md4c.c b/md4c/md4c.c
index 4527242..2b171df 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -5493,6 +5493,15 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
         n_parents++;
     }
 
+    if(off >= ctx->size  ||  ISNEWLINE(off)) {
+        /* Blank line does not need any real indentation to be nested inside
+         * a list. */
+        if(n_brothers + n_children == 0) {
+            while(n_parents < ctx->n_containers  &&  ctx->containers[n_parents].ch != _T('>'))
+                n_parents++;
+        }
+    }
+
 redo:
     /* Check whether we are fenced code continuation. */
     if(pivot_line->type == MD_LINE_FENCEDCODE) {
@@ -5508,15 +5517,6 @@ redo:
             }
         }
 
-        if(off >= ctx->size  ||  ISNEWLINE(off)) {
-            /* Blank line does not need any real indentation to be nested inside
-             * a list. */
-            if(n_brothers + n_children == 0) {
-                while(n_parents < ctx->n_containers  &&  ctx->containers[n_parents].ch != _T('>'))
-                    n_parents++;
-            }
-        }
-
         /* Change indentation accordingly to the initial code fence. */
         if(n_parents == ctx->n_containers) {
             if(line->indent > pivot_line->indent)
@@ -5548,15 +5548,6 @@ redo:
             }
         }
 
-        if(off >= ctx->size  ||  ISNEWLINE(off)) {
-            /* Blank line does not need any real indentation to be nested inside
-             * a list. */
-            if(n_brothers + n_children == 0) {
-                while(n_parents < ctx->n_containers  &&  ctx->containers[n_parents].ch != _T('>'))
-                    n_parents++;
-            }
-        }
-
         if(n_parents == ctx->n_containers) {
             line->type = MD_LINE_HTML;
             goto done;
@@ -5565,13 +5556,6 @@ redo:
 
     /* Check for blank line. */
     if(off >= ctx->size  ||  ISNEWLINE(off)) {
-        /* Blank line does not need any real indentation to be nested inside
-         * a list. */
-        if(n_brothers + n_children == 0) {
-            while(n_parents < ctx->n_containers  &&  ctx->containers[n_parents].ch != _T('>'))
-                n_parents++;
-        }
-
         if(pivot_line->type == MD_LINE_INDENTEDCODE  &&  n_parents == ctx->n_containers) {
             line->type = MD_LINE_INDENTEDCODE;
             if(line->indent > ctx->code_indent_offset)