commonmark/commonmark-spec

Clarification of soft breaks in image descriptions + request for test case

rmartine-ias opened this issue · 5 comments

Image descriptions can sometimes span multiple lines -- for example, if wrapping at 80 characters. This seems to be allowed by the spec, and works on the dingus.

Example:

![alt text
on two lines](image.png)

I am requesting two things:

  1. Clarification on whether the newline should be included in the rendered HTML, or if whitespace should be collapsed into a single space. Right now it is included:

    <p><img src="image.png" alt="alt text
    on two lines" /></p>
  2. A test case where the image description contains a newline

Why do you wonder about this?

A markdown-parsing tool I use panics with a newline in the image description: https://github.com/swsnr/mdcat/issues/194 (inline code so as to not link this issue and start any drama).

I wonder about the desired behavior mostly out of curiosity. I wanted a test so that this, and other tools, have something to reference for this case.

Apologies if this is the wrong forum for this, I haven't engaged with commonmark before.

So panics are no good of course!
But yeah, I'd say line endings are definitely supported. There's nothing that says otherwise. And it's out there in the wild.
Ik not opposed to a test case nut I'm more: its the only thing that makes sense, is it really/even needed!

jgm commented

They're definitely allowed, not just by commonmark but by every markdown implementation I've ever seen: Babelmark link.

On whether to collapse the newline to a space in the rendered output: I think we can leave this up to the renderer; in HTML the two options are completely equivalent.

@jgm that handling isn’t always true anymore, see #744.

That being said, only keeping the line ending, allows the renderer (such as a browser) to choose this. As the render might do things differently. Turning it into a space prevents the renderer (a browser) from doing that.