Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Earmark does only render first link with a title of a line correctly. #220

Closed
RichMorin opened this issue Mar 10, 2019 · 2 comments
Closed
Assignees
Labels

Comments

@RichMorin
Copy link
Contributor

A single link with a title works fine:

iex(1)> m1 = "[a link](/a_link 'a title')"        
"[a link](/a_link 'a title')"

iex(2)> Earmark.as_html(m1)
{:ok, "<p><a href=\"/a_link\" title=\"a title\">a link</a></p>\n", []}

However, a pair of links with titles (on the same line) fails:

iex(3)> m2 = "#{ m1 } #{ m1 }"
"[a link](/a_link 'a title') [a link](/a_link 'a title')"

iex(4)> Earmark.as_html(m2)
{:ok, "<p><a href=\"/a_link\" title=\"a title&#39;) [a link](/a_link &#39;a title\">a link</a></p>\n", []}

Both single links and pairs of links work ok, if no titles are used:

iex(5)> m1 = "[a link](/a_link)"          
"[a link](/a_link)"

iex(6)> Earmark.as_html(m1)
{:ok, "<p><a href=\"/a_link\">a link</a></p>\n", []}

iex(7)> m2 = "#{ m1 } #{ m1 }"
"[a link](/a_link) [a link](/a_link)"

iex(8)> Earmark.as_html(m2)
{:ok, "<p><a href=\"/a_link\">a link</a> <a href=\"/a_link\">a link</a></p>\n", []}
@RobertDober RobertDober changed the title Earmark doesn't like multiple links with titles on the same line. Earmark does only render first link with a title of a line correctly. Mar 10, 2019
@RobertDober
Copy link
Collaborator

Some more examples

iex(24)> as_html("[a](a 't') [b](b)")
{:ok, "<p><a href=\"a\" title=\"t\">a</a> <a href=\"b\">b</a></p>\n", []}
# OK

iex(25)> as_html("[a](a 't') [b](b) [c](c 't')")
{:ok, "<p><a href=\"a\" title=\"t&#39;) [b](b) [c](c &#39;t\">a</a></p>\n", []}
# KO

iex(26)> as_html("[a](a 't') [b](b) [c](c)")
{:ok,
 "<p><a href=\"a\" title=\"t\">a</a> <a href=\"b\">b</a> <a href=\"c\">c</a></p>\n",
 []}
# OK

iex(27)> as_html("[a](a 't') [b](b) 'xxx' [c](c)")
{:ok,
 "<p><a href=\"a\" title=\"t\">a</a> <a href=\"b\">b</a> ‘xxx’ <a href=\"c\">c</a></p>\n",
 []}
# OK

iex(28)> as_html("[a](a 't') [b](b) ('xxx') [c](c)")
{:ok,
 "<p><a href=\"a\" title=\"t&#39;) [b](b) (&#39;xxx\">a</a> <a href=\"c\">c</a></p>\n",
 []}
# KO

@RichMorin
Copy link
Contributor Author

I edited my mix.exs file as follows and the problem seems to have gone away:

  { :earmark, override: true,
      git: "https://github.com/pragdave/earmark.git" },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants