Commit 7deaccf65d01d5bde104efb3b6fd18aab8ae8392

Martin Mitas 2018-05-29T18:32:10

md_is_link_label: Fix if the link label contains just backslash escapes. The function did not remember the label start line index, leading to bad consequences. Fixes #39.

diff --git a/md4c/md4c.c b/md4c/md4c.c
index e572b97..53a725c 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -1887,8 +1887,10 @@ md_is_link_label(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg,
 
         while(off < line_end) {
             if(CH(off) == _T('\\')  &&  off+1 < ctx->size  &&  (ISPUNCT(off+1) || ISNEWLINE(off+1))) {
-                if(contents_end == 0)
+                if(contents_end == 0) {
                     contents_beg = off;
+                    *p_beg_line_index = line_index;
+                }
                 contents_end = off + 2;
                 off += 2;
             } else if(CH(off) == _T('[')) {
diff --git a/test/coverage.txt b/test/coverage.txt
index 6a622d8..ab4f75b 100644
--- a/test/coverage.txt
+++ b/test/coverage.txt
@@ -134,6 +134,13 @@ __x_ _x___
 ````````````````````````````````
 
 
+### [Issue 39](https://github.com/mity/md4c/issues/39)
+```````````````````````````````` example
+[\\]: x
+.
+````````````````````````````````
+
+
 
 ## Code coverage