elixir-lang / ex_doc

ExDoc produces HTML and EPUB documentation for Elixir projects
http://elixir-lang.org
Other
1.44k stars 325 forks source link

Multiple markdown images with links are not parsed correctly #1635

Closed eproxus closed 1 year ago

eproxus commented 1 year ago

When using markdown images with links, ex_doc incorrectly parses them when they are in one paragraph.

Input

[![Travis][travis badge]][travis]
[![Hex.pm Version][hex version badge]][hex]
[![Hex.pm License][hex license badge]][hex]
[![Erlang Versions][erlang version badge]][travis]
[![Build Tool][build tool]][hex]
[![Donations][liberapay badge]][liberapay]

...

<!-- Badges -->
[travis]: https://travis-ci.org/eproxus/unite
[travis badge]: https://img.shields.io/travis/eproxus/unite/master.svg?style=flat-square
[hex]: https://hex.pm/packages/unite
[hex version badge]: https://img.shields.io/hexpm/v/unite.svg?style=flat-square
[hex license badge]: https://img.shields.io/hexpm/l/unite.svg?style=flat-square
[erlang version badge]: https://img.shields.io/badge/erlang-21%20to%2024-blue.svg?style=flat-square
[build tool]: https://img.shields.io/badge/build%20tool-rebar3-orange.svg?style=flat-square
[liberapay badge]: https://img.shields.io/liberapay/receives/eproxus.svg?logo=liberapay&style=flat-square
[liberapay]: https://liberapay.com/eproxus/

Full example: https://github.com/eproxus/unite/blob/v0.4.0/README.md

Result

Screenshot 2022-11-29 at 12 04 55

HTML

<p><a href="https://liberapay.com/eproxus/" title="" class="no-underline"><img src="https://hex.pm/packages/unite" alt="Travis][travis badge]][travis]
[![Hex.pm Version][hex version badge]][hex]
[![Hex.pm License][hex license badge]][hex]
[![Erlang Versions][erlang version badge]][travis]
[![Build Tool][build tool]" title="">
[<img src="https://img.shields.io/liberapay/receives/eproxus.svg?logo=liberapay&amp;style=flat-square" alt="Donations" title=""></a></p>

Expected

As rendered on GitHub, a bunch of images on one line in a paragraph:

Screenshot 2022-11-29 at 12 08 25
josevalim commented 1 year ago

Can you please file a bug report on Earmark if none has been filled yet?

josevalim commented 1 year ago

To clarify, the Markdown handling and parsing is done in Earmark.

RobertDober commented 1 year ago

Can you please file a bug report on Earmark if none has been filled yet?

I will take care of myself because it goes into EarmarkParser, ex_doc does not use EarmarkParser anymore

This issue is strangely familiar....

josevalim commented 1 year ago

Closing this here as @RobertDober is tracking it.

btw @RobertDober, you should be able to transfer the issue between repos that you own with a link on the sidebar in the right!

RobertDober commented 1 year ago

@eproxus I understand why you use the delayed url definition form of the links and images and I will eventually fix the bug. However this might not be possible this year, as a workaround you could use the inline definition which works fine.

[![CI](https://github.com/pragdave/earmark/actions/workflows/ci.yml/badge.svg)](https://github.com/pragdave/earmark/actions/workflows/ci.yml)

as can be confirmed at hex.pm 😉

eproxus commented 1 year ago

@RobertDober No worries, thanks too for looking into it! 🙇