rsc / markdown

Basic Markdown parser and HTML generator
BSD 3-Clause "New" or "Revised" License
81 stars 4 forks source link

Replace newlines with spaces in alt text #4

Closed matloob closed 8 months ago

matloob commented 8 months ago

Here's a go program that runs markdown and goldmark on the following input: https://go.dev/play/p/zZ0vWAgKB0c:

[![Line
Break](https://line.break/image)](https://line.break)

Which is rendered on github with a space instead of the newline in the alt text:

<p dir="auto"><a href="https://line.break" rel="nofollow"><img src="https://camo.githubusercontent.com/743b6218bc25f78b5f7f654f1ce773766351a2e3605cf8b47c60659055c218ac/68747470733a2f2f6c696e652e627265616b2f696d616765" alt="Line Break" data-canonical-src="https://line.break/image" style="max-width: 100%;"></a></p>

The output is

markdown:
<p><a href="https://line.break"><img src="https://line.break/image" alt="LineBreak" /></a></p>

goldmark:
<p><a href="https://line.break"><img src="https://line.break/image" alt="Line
Break" /></a></p>

It seems like goldmark's behavior is also different from github's as goldmark preserves the line break.