md_resolve_links: Skip [...] used as a reference link/image label. Fixes #131.
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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 964797c..e9affd4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
# MD4C Change Log
+## Next Version (Work in Progress)
+
+Fixes:
+
+* [#131](https://github.com/mity/md4c/issues/131):
+ Fix handling of a reference image nested in a reference link.
+
+
## Version 0.4.6
Fixes:
diff --git a/src/md4c.c b/src/md4c.c
index 0119e7a..caa5fe7 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -3524,6 +3524,10 @@ md_resolve_links(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
if(is_link) {
/* Eat the 2nd "[...]". */
closer->end = next_closer->end;
+
+ /* Do not analyze the label as a standalone link in the next
+ * iteration. */
+ next_index = ctx->marks[next_index].prev;
}
} else {
if(closer->end < ctx->size && CH(closer->end) == _T('(')) {
diff --git a/test/coverage.txt b/test/coverage.txt
index 8367759..4b504e1 100644
--- a/test/coverage.txt
+++ b/test/coverage.txt
@@ -284,6 +284,18 @@ foo
````````````````````````````````
+### [Issue 131](https://github.com/mity/md4c/issues/131)
+
+```````````````````````````````` example
+[![alt][img]][link]
+
+[img]: img_url
+[link]: link_url
+.
+<p><a href="link_url"><img src="img_url" alt="alt"></a></p>
+````````````````````````````````
+
+
## Code coverage
### `md_is_unicode_whitespace__()`