Defect #22323

Markdown newline rendering broken

Added by Viktor Berke over 5 years ago. Updated about 1 month ago.

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

0%

Category:Text formatting
Target version:-
Resolution:Duplicate 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
Duplicates Redmine - Patch #32424: CommonMark Markdown Text Formatting New

History

#1 Updated by Viktor Berke over 5 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 5 years ago

  • Category changed from Wiki to Text formatting

#3 Updated by Toshi MARUYAMA over 5 years ago

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

#4 Updated by Pablo Yanez Trujillo over 2 years 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 about 2 years 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 about 2 years 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 about 2 years 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 about 2 years ago

  • Target version set to Candidate for next major release

#9 Updated by Martin Cizek almost 2 years ago

Target version set to Candidate for next major release

Now, when there is #32424, I'd vote for keeping the markdown format as is and deprecate it. This would be actually a cleaner solution for users who rely on its current behavior, which includes hard line breaks.

#10 Updated by Mischa The Evil over 1 year ago

  • Related to Patch #32424: CommonMark Markdown Text Formatting added

#11 Updated by Marius BALTEANU about 1 month ago

  • Related to deleted (Patch #32424: CommonMark Markdown Text Formatting)

#12 Updated by Marius BALTEANU about 1 month ago

  • Duplicates Patch #32424: CommonMark Markdown Text Formatting added

#13 Updated by Marius BALTEANU about 1 month ago

  • Status changed from New to Closed
  • Target version deleted (Candidate for next major release)
  • Resolution set to Duplicate

The current Markdown implementation based on RedCarpet is deprecated and it is going to be dropped in the future versions and it will be replaced by the CommonMark Markdown (Github Flavoured) formatter that was just committed for 5.0.0.

Hardbreaks behaviour will be configurable at instance level, please follow the discussions from #32424.

Also available in: Atom PDF