Image syntax

A. Pagaltzis pagaltzis at gmx.de
Wed Jul 27 14:31:12 EDT 2005


* John Gruber <gruber at fedora.net> [2005-07-27 17:55]:

> And I now think that putting the URL to image itself last was a

> mistake. Images aren't like links, and I no longer understand

> why I thought their Markdown syntaxes should be so similar.


In the text document, images inlined in the middle of a paragraph
and regular links are virtually identical. It seems only natural
to use virtually the same syntax for both.

In the HTML document, the alt text is supposed to *replace* the
image in contexts where the image cannot be viewed. (When they’re
not, ie whenever an image is merely decorative or illustrative,
but is not essential to understanding the document, the alt text
is supposed to be empty.)

For inline images, the syntax makes utter sense. For images at
the block level, it’s not nearly so clear-cut.


> No special punctuation at all. Just a URL pointing to an image,

> followed by an alt text description on the next line.

>

> The assumption here is that image URLs end with something like

> .png, .gif, .jpg, etc. It'd be easy to match those URLs. We

> could further specify that URLs need to begin with "http" or

> "/".


So long as there also exists unmagical syntax that will not
miraculously change nature depending on the thing being linked
to, that is fine. Currently, that’s the purpose the bang serves.

Shortcuts are fine, I’d just hate to have to jump through the
same hoops as on some wikis, where hacks like appending a `?` to
an image URL so I can make it a simple link, or appending
`&bogus=param.png` to the URL of a CGI script that generates
images to make it an inline image are the norm – because there’s
no other syntax for forcing a link vs an image than the last
couple of characters in the URL.

That is plainly B.A.D.


> And I now think that putting the URL to image itself last was a

> mistake. Images aren't like links, and I no longer understand

> why I thought their Markdown syntaxes should be so similar.


I still like the reasoning: that it’s because the alt text is
supposed to *replace* the image in contexts where the image
cannot be viewed. In other words, the image and its alt text are
supposed to be ![equivalent][1] and freely interchangeable.[^1]
That makes utter sense for inline images.


> These ideas look much more like how I would reference an image

> in a plain text email message or text document.


But what you’re providing as an alt text is not a replacement. It
is a title, or caption. alt is not meant for that. It is for a
replacement to be read in place of the image within the flow of
text. Illustrative images like a screenshot do not get an alt
text; they are not an equivalent replacement to anything, and
short of a thousand words, they cannot be described adequately.
99% of the images used on the web today should have `alt=""`.

If you take that into account, then the syntax already in
Markdown is already roughly as you want it:

![](http://example.org/foo.png
"A screenshot of whatever")

…well, except that it currently incorrectly includes the
linebreak (and any whitespace before it) in the src.

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>


More information about the Markdown-Discuss mailing list