Revert "Fix problematic link destinations with angle brackets." The updated specification now explicitly requests the behavior we implemented before fixing #24. This reverts commit 2e0a74ba990e291ef4eace047d50af05ca81daef. Also remove associated regression test as it is no longer valid.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 71daafb..5c46481 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -2019,6 +2019,14 @@ md_is_link_destination_B(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
return TRUE;
}
+static inline int
+md_is_link_destination(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
+ OFF* p_contents_beg, OFF* p_contents_end)
+{
+ return (md_is_link_destination_A(ctx, beg, max_end, p_end, p_contents_beg, p_contents_end) ||
+ md_is_link_destination_B(ctx, beg, max_end, p_end, p_contents_beg, p_contents_end));
+}
+
static int
md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg,
OFF* p_end, int* p_beg_line_index, int* p_end_line_index,
@@ -2088,9 +2096,7 @@ md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg,
* Returns -1 in case of an error (out of memory).
*/
static int
-md_is_link_reference_definition_helper(
- MD_CTX* ctx, const MD_LINE* lines, int n_lines,
- int (*is_link_dest_fn)(MD_CTX*, OFF, OFF, OFF*, OFF*, OFF*))
+md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
{
OFF label_contents_beg;
OFF label_contents_end;
@@ -2134,8 +2140,8 @@ md_is_link_reference_definition_helper(
}
/* Link destination. */
- if(!is_link_dest_fn(ctx, off, lines[line_index].end,
- &off, &dest_contents_beg, &dest_contents_end))
+ if(!md_is_link_destination(ctx, off, lines[line_index].end,
+ &off, &dest_contents_beg, &dest_contents_end))
return FALSE;
/* (Optional) title. Note we interpret it as an title only if nothing
@@ -2221,16 +2227,6 @@ abort:
return -1;
}
-static inline int
-md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
-{
- int ret;
- ret = md_is_link_reference_definition_helper(ctx, lines, n_lines, md_is_link_destination_A);
- if(ret == 0)
- ret = md_is_link_reference_definition_helper(ctx, lines, n_lines, md_is_link_destination_B);
- return ret;
-}
-
static int
md_is_link_reference(MD_CTX* ctx, const MD_LINE* lines, int n_lines,
OFF beg, OFF end, MD_LINK_ATTR* attr)
@@ -2286,9 +2282,8 @@ abort:
}
static int
-md_is_inline_link_spec_helper(MD_CTX* ctx, const MD_LINE* lines, int n_lines,
- OFF beg, OFF* p_end, MD_LINK_ATTR* attr,
- int (*is_link_dest_fn)(MD_CTX*, OFF, OFF, OFF*, OFF*, OFF*))
+md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, int n_lines,
+ OFF beg, OFF* p_end, MD_LINK_ATTR* attr)
{
int line_index = 0;
int tmp_line_index;
@@ -2328,7 +2323,7 @@ md_is_inline_link_spec_helper(MD_CTX* ctx, const MD_LINE* lines, int n_lines,
}
/* Link destination. */
- if(!is_link_dest_fn(ctx, off, lines[line_index].end,
+ if(!md_is_link_destination(ctx, off, lines[line_index].end,
&off, &attr->dest_beg, &attr->dest_end))
return FALSE;
@@ -2383,14 +2378,6 @@ abort:
return ret;
}
-static inline int
-md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, int n_lines,
- OFF beg, OFF* p_end, MD_LINK_ATTR* attr)
-{
- return md_is_inline_link_spec_helper(ctx, lines, n_lines, beg, p_end, attr, md_is_link_destination_A) ||
- md_is_inline_link_spec_helper(ctx, lines, n_lines, beg, p_end, attr, md_is_link_destination_B);
-}
-
static void
md_free_ref_defs(MD_CTX* ctx)
{
diff --git a/test/coverage.txt b/test/coverage.txt
index 07121f5..ab26400 100644
--- a/test/coverage.txt
+++ b/test/coverage.txt
@@ -110,14 +110,6 @@ a*b**c*
````````````````````````````````
-### [Issue 24](https://github.com/mity/md4c/issues/24)
-```````````````````````````````` example
-[a](<b>c)
-.
-<p><a href="%3Cb%3Ec">a</a></p>
-````````````````````````````````
-
-
### [Issue 33](https://github.com/mity/md4c/issues/33)
```````````````````````````````` example
```&&&&&&&&