The behaviour of alt text in image links is confusing


Writing a CommonMark parser, and I am struggling to figure out why the first line’s alt text is not also “foo”.


Is this a bug, or some kind of subtle interaction I’m missing? Especially since nested links and images behave the same if you remove one layer of nesting:

<p><img src="uri3" alt="foo" />
<img src="uri3" alt="foo" /></p>