Fix an ImageSyntax issue (dart-lang/markdown#493)

diff --git a/pkgs/markdown/lib/src/inline_syntaxes/image_syntax.dart b/pkgs/markdown/lib/src/inline_syntaxes/image_syntax.dart
index cb47ae0..5d36e58 100644
--- a/pkgs/markdown/lib/src/inline_syntaxes/image_syntax.dart
+++ b/pkgs/markdown/lib/src/inline_syntaxes/image_syntax.dart
@@ -25,7 +25,15 @@
     final element = Element.empty('img');
     final children = getChildren();
     element.attributes['src'] = destination;
-    element.attributes['alt'] = children.map((node) => node.textContent).join();
+    element.attributes['alt'] = children.map((node) {
+      // See https://spec.commonmark.org/0.30/#image-description.
+      // An image description may contain links. Fetch text from the alt
+      // attribute if this nested link is an image.
+      if (node is Element && node.tag == 'img') {
+        return node.attributes['alt'];
+      }
+      return node.textContent;
+    }).join();
     if (title != null && title.isNotEmpty) {
       element.attributes['title'] = normalizeLinkTitle(title);
     }
diff --git a/pkgs/markdown/test/common_mark/images.unit b/pkgs/markdown/test/common_mark/images.unit
index 158ca40..e7b09ea 100644
--- a/pkgs/markdown/test/common_mark/images.unit
+++ b/pkgs/markdown/test/common_mark/images.unit
@@ -11,7 +11,7 @@
 >>> Images - 573
 ![foo ![bar](/url)](/url2)
 <<<
-<p><img src="/url2" alt="foo " /></p>
+<p><img src="/url2" alt="foo bar" /></p>
 >>> Images - 574
 ![foo [bar](/url)](/url2)
 <<<
diff --git a/pkgs/markdown/test/gfm/images.unit b/pkgs/markdown/test/gfm/images.unit
index e0bfb90..106e1a2 100644
--- a/pkgs/markdown/test/gfm/images.unit
+++ b/pkgs/markdown/test/gfm/images.unit
@@ -11,7 +11,7 @@
 >>> Images - 582
 ![foo ![bar](/url)](/url2)
 <<<
-<p><img src="/url2" alt="foo " /></p>
+<p><img src="/url2" alt="foo bar" /></p>
 >>> Images - 583
 ![foo [bar](/url)](/url2)
 <<<
diff --git a/pkgs/markdown/tool/common_mark_stats.json b/pkgs/markdown/tool/common_mark_stats.json
index 8368b9a..a073b64 100644
--- a/pkgs/markdown/tool/common_mark_stats.json
+++ b/pkgs/markdown/tool/common_mark_stats.json
@@ -358,7 +358,7 @@
  "Images": {
   "571": "strict",
   "572": "strict",
-  "573": "fail",
+  "573": "strict",
   "574": "strict",
   "575": "strict",
   "576": "strict",
diff --git a/pkgs/markdown/tool/common_mark_stats.txt b/pkgs/markdown/tool/common_mark_stats.txt
index 910b446..5935a21 100644
--- a/pkgs/markdown/tool/common_mark_stats.txt
+++ b/pkgs/markdown/tool/common_mark_stats.txt
@@ -9,7 +9,7 @@
   29 of   29 – 100.0%  Fenced code blocks
   15 of   15 – 100.0%  Hard line breaks
   44 of   44 – 100.0%  HTML blocks
-  21 of   22 –  95.5%  Images
+  22 of   22 – 100.0%  Images
   12 of   12 – 100.0%  Indented code blocks
    1 of    1 – 100.0%  Inlines
   21 of   27 –  77.8%  Link reference definitions
@@ -24,5 +24,5 @@
   11 of   11 – 100.0%  Tabs
    3 of    3 – 100.0%  Textual content
   19 of   19 – 100.0%  Thematic breaks
- 635 of  652 –  97.4%  TOTAL
- 616 of  635 –  97.0%  TOTAL Strict
+ 636 of  652 –  97.5%  TOTAL
+ 617 of  636 –  97.0%  TOTAL Strict
diff --git a/pkgs/markdown/tool/gfm_stats.json b/pkgs/markdown/tool/gfm_stats.json
index a431a10..f426ab8 100644
--- a/pkgs/markdown/tool/gfm_stats.json
+++ b/pkgs/markdown/tool/gfm_stats.json
@@ -373,7 +373,7 @@
  "Images": {
   "580": "strict",
   "581": "strict",
-  "582": "fail",
+  "582": "strict",
   "583": "strict",
   "584": "strict",
   "585": "strict",
diff --git a/pkgs/markdown/tool/gfm_stats.txt b/pkgs/markdown/tool/gfm_stats.txt
index 0a103e9..b460faa 100644
--- a/pkgs/markdown/tool/gfm_stats.txt
+++ b/pkgs/markdown/tool/gfm_stats.txt
@@ -11,7 +11,7 @@
   29 of   29 – 100.0%  Fenced code blocks
   15 of   15 – 100.0%  Hard line breaks
   43 of   43 – 100.0%  HTML blocks
-  21 of   22 –  95.5%  Images
+  22 of   22 – 100.0%  Images
   12 of   12 – 100.0%  Indented code blocks
    1 of    1 – 100.0%  Inlines
   22 of   28 –  78.6%  Link reference definitions
@@ -28,5 +28,5 @@
   11 of   11 – 100.0%  Tabs
    3 of    3 – 100.0%  Textual content
   19 of   19 – 100.0%  Thematic breaks
- 653 of  671 –  97.3%  TOTAL
- 633 of  653 –  96.9%  TOTAL Strict
+ 654 of  671 –  97.5%  TOTAL
+ 634 of  654 –  96.9%  TOTAL Strict