RobertDober/earmark_parser

Fail to parse html `a` link with preceding content

Closed this issue · 4 comments

Tested on 1.4, 1.5, and master branches for both earmark and earmark_parser getting the same result:

iex> Earmark.as_html!("reading <a href=\"http://amzn.com/1592535879\">The Universal Principles of Design</a>")
"<p>\nreading &lt;a href=”<a href=\"http://amzn.com/1592535879%22\">http://amzn.com/1592535879”</a>&gt;The Universal Principles of Design&lt;/a&gt;</p>\n"

Is that format expected? If so, how can I help fixing it?

HTML tags are only supported when starting a line and behavior for the rest of the line is undefined.

Maybe the docs could be clearer on that.

Hi @RobertDober thanks for feedback

HTML tags are only supported when starting a line and behavior for the rest of the line is undefined.

Maybe the docs could be clearer on that.

@RobertDober Ran into the same problem and did not understand why this issue was closed. Does it mean, that links with preceding content are not supported by EarmarkParser? If so, are there plans to support it in the future?

Example string

Hello <a target="_blank" href="https://example.com">Example</a>

Expected Result

https://babelmark.github.io/?text=Hello+%3Ca+target%3D%22_blank%22+href%3D%22https%3A%2F%2Fexample.com%22%3EExample%3C%2Fa%3E

Actual Result (notice that the link breaks)

CleanShot 2023-03-21 at 16 34 26

This has been planned for EarmarkParser 1.5 for a long time, unfortunately I have barely time to maintain 1.4.x
:(
Should update the docs