Commit 45a1027115059210658b39b1c8b1403f95ad96aa

Martin Mitas 2016-12-07T13:43:54

md_do_normalize_string: Fix handling of escaped backslash ("\\").

diff --git a/md4c/md4c.c b/md4c/md4c.c
index 3e5e276..7119abf 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -867,14 +867,15 @@ md_do_normalize_string(MD_CTX* ctx, OFF beg, OFF end, const MD_LINE* lines, int 
             }
 
             if(resolve_escapes  &&  CH(off) == _T('\\')  &&
-               off+1 < end  &&  (ISPUNCT(off+1) || ISNEWLINE(off+1)))
-            {
-                off++;
-            } else {
-                *ptr = CH(off);
-                ptr++;
+               off+1 < end  &&  (ISPUNCT(off+1) || ISNEWLINE(off+1))) {
+                if(ISNEWLINE(off+1))
+                    break;
                 off++;
             }
+
+            *ptr = CH(off);
+            ptr++;
+            off++;
         }
 
         *ptr = line_break_replacement_char;