Defect #22323

Markdown newline rendering broken

Added by Viktor Berke over 3 years ago. Updated 2 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Text formatting
Target version:Candidate for next major release
Resolution: Affected version:3.2.1

Description

As per the specs Markdown should not insert <br /> for single line breaks. <br /> should only occur for:

- A line ending with 2 or more spaces, then a line break.
- One or more blank lines between paragraphs lines. In other words, 2 or more line breaks.

GitHub is consistent with this in wiki formatting. In GitHub issues a single line break also triggers a rendered line break, the reason for this is beyond me but that's also against the specs.

Please fix this. This actually breaks Pandoc conversion from Textile pages because Pandoc occasionally inserts line breaks even within paragraphs and this causes line breaks in the rendered text as well thus breaking the format.

22323-with-test.patch Magnifier (1.47 KB) Martin Cizek, 2019-08-20 16:28

22323-with-test-after-r18381.patch Magnifier (1.48 KB) Martin Cizek, 2019-08-22 15:02


Related issues

Related to Redmine - Feature #22005: Rake task for converting from Textile to Markdown New

History

#1 Updated by Viktor Berke over 3 years ago

Since I can't add related issues, I'll just link it: Rake task for converting from Textile to Markdown

#2 Updated by Go MAEDA over 3 years ago

  • Category changed from Wiki to Text formatting

#3 Updated by Toshi MARUYAMA over 3 years ago

  • Related to Feature #22005: Rake task for converting from Textile to Markdown added

#4 Updated by Pablo Yanez Trujillo 6 months ago

I'd like to know whether this has been fixed in the current 4.x releases. I still have an 3.3.7 installation and this is annoying, specially since I use text-aid-too (https://github.com/smblott-github/text-aid-too) to edit content with vim and I have line wrapping at 80 characters. When editing on github, or stackooverflow then there is no problem. But on my redmine pages, it's a problem, because redmine inserts <br /> where it shouldn't.

#5 Updated by Martin Cizek 3 months ago

On one hand, calling this a defect might not be fair, as it is apparently kind-of decision made in lib/redmine/wiki_formatting/markdown/formatter.rb with the setting :hard_wrap => true. Indeed, we do not know how intentional the decision was.

On the other hand, it breaks compatibility with GFM, especially on its two major implementations GitHub and GitLab (as said - except GitHub issues, but our developers are really angry about GitHub issues having different behaviour than the rest of GitHub). And as the author says, it is against Markdown specs.

I guess we are not that rare when we intend to share Markdown sources between Redmine and GitLab and among Redmine and other systems - using API, mirroring wiki to git and indeed with users' copy&pasting it.

So I would strongly vote to change the default behavior towards more standard Markdown / GFM to stay compatible with the world.

The patch is included including a unit test. :) P.S. The tests at the end of MarkdownFormatterTest seem to be commented out by private? Not sure why, but the tests work even after commenting it out to #private.

#6 Updated by Mischa The Evil 3 months ago

Martin Cizek wrote:

P.S. The tests at the end of MarkdownFormatterTest seem to be commented out by private? Not sure why, but the tests work even after commenting it out to #private.

I have reported this in a separate issue, #31929. Thanks for mentioning it here.

#7 Updated by Martin Cizek 3 months ago

Mischa The Evil wrote:

I have reported this in a separate issue, #31929. Thanks for mentioning it here.

You're very welcome. Attaching the patch updated against trunk (r18381).

#8 Updated by Go MAEDA 2 months ago

  • Target version set to Candidate for next major release

Also available in: Atom PDF