Skip to content

image short-reference links not supported #894

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

Closed
erez-o opened this issue Jan 12, 2020 · 2 comments · Fixed by #994
Closed

image short-reference links not supported #894

erez-o opened this issue Jan 12, 2020 · 2 comments · Fixed by #994
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code.

Comments

@erez-o
Copy link

erez-o commented Jan 12, 2020

Hi,

I've encountered an unexpected behavior:

Markdown:

[![Build Status]](https://travis-ci.org/commonmark/cmark)


[Build Status]: https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat

Produces

<p>
  <a href="https://travis-ci.org/commonmark/cmark">![Build Status]</a>
</p>

Expected behavior: (inserted the above markdown snippet as is into this issue)

Build Status

or in html:

<p>
  <a href="https://travis-ci.org/commonmark/cmark"><img src="https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat" alt="Build Status"></a>
</p>

In babel:

https://babelmark.github.io/?text=%5B!%5BBuild+Status%5D%5D(https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Ftravis-ci.org%2Fcommonmark%2Fcmark)%0A%0A%0A%5BBuild+Status%5D%3A+https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fimg.shields.io%2Ftravis%2Fcommonmark%2Fcmark%2Fmaster.svg%3Fstyle%3Dflat

@waylan
Copy link
Member

waylan commented Jan 12, 2020

I'm not sure this is a bug. I understand why one might think it is, but short reference links (where the label is the ref) are an undocumented feature of Markdown and, as demonstrated by Babelmark, this does not work in the reference implementation either.

Interestingly, the PHP and Python implementations parse the outer link, but miss the image, while markdown.pl (the reference implementation) misses the outer link but parses the image.

However, what is more interesting is the behavior when we separate the image link out from the wrapping link (see babelmark. It appears that Python-Markdown and markdown.pl 1.0.1 are the outliers in that neither recognize the short ref for images (markdown.pl also doesn't recognize the short ref for links as that was added in 1.0.2). This is clearly a bug. Why would we recognize short refs for links but not images?

@waylan waylan added bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code. labels Jan 12, 2020
@erez-o
Copy link
Author

erez-o commented Jan 13, 2020

Ok,

If I understand, you correctly, I think that once you recognize short refs as images, you would get the expected behavior I described above:

If

![Build Status]

[Build Status]: https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat

Becomes

<img src="https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat" alt="Build Status">

Then:

[<img src="https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat" alt="Build Status">](https://travis-ci.org/commonmark/cmark)


[Build Status]: https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat

Becomes (currently in python-markdown):

<p>
  <a href="https://travis-ci.org/commonmark/cmark"><img src="https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat" alt="Build Status"></a>
</p>

Build Status

See babel

@waylan waylan changed the title image + reference image short-reference links not supported Jul 1, 2020
waylan added a commit to waylan/markdown that referenced this issue Jul 1, 2020
waylan added a commit that referenced this issue Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. core Related to the core parser code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants