Inline elements in image descriptions are flattened and stripped
Consider the following document:



mdformat changes the document to this:



In the second case, the formatting is removed. In the third case, the formatted inline element is removed completely. This is surprising to me and the case of removing the inline element seems dangerous to me. I would have expected mdformat to not change this document.
I looked into the CommonMark specification (6.4 Images), which says that an image description can contain inline elements, but that they should be flattened to the plain text content of the elements when rendering to HTML.
This means that in the second case, some information is lost because the document could be rendered to an output format that supports styled image descriptions and in the third case, part of the text is lost.
My setup:
$ pip install mdformat
Collecting mdformat
Downloading mdformat-0.7.17-py3-none-any.whl.metadata (8.7 kB)
Collecting markdown-it-py<4.0.0,>=1.0.0 (from mdformat)
Using cached markdown_it_py-3.0.0-py3-none-any.whl.metadata (6.9 kB)
Collecting mdurl~=0.1 (from markdown-it-py<4.0.0,>=1.0.0->mdformat)
Using cached mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Downloading mdformat-0.7.17-py3-none-any.whl (28 kB)
Using cached markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
Installing collected packages: mdurl, markdown-it-py, mdformat
Successfully installed markdown-it-py-3.0.0 mdformat-0.7.17 mdurl-0.1.2
I ran mdformat without arguments:
mdformat foo.md
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Thanks for the issue!
The third case seems like a duplicate of https://github.com/executablebooks/mdformat/issues/414