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

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

Closed
rmartine-ias opened this issue Oct 30, 2023 · 5 comments

Comments

@rmartine-ias
Copy link

rmartine-ias commented Oct 30, 2023

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

@wooorm
Copy link
Contributor

wooorm commented Oct 30, 2023

Why do you wonder about this?

@rmartine-ias
Copy link
Author

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.

@wooorm
Copy link
Contributor

wooorm commented Oct 30, 2023

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
Copy link
Member

jgm commented Oct 30, 2023

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 jgm closed this as completed Oct 30, 2023
@wooorm
Copy link
Contributor

wooorm commented Oct 31, 2023

@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.

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

No branches or pull requests

3 participants