markdown: does not render line break #4195

Closed
opened 2025-11-02 05:41:59 -06:00 by GiteaMirror · 11 comments
Owner

Originally created by @brandonkal on GitHub (Oct 27, 2019).

  • Gitea version (or commit ref): 1.9.4
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes
    • No
    • Not relevant
  • Log gist:

Description

Markdown renderer does not respect new lines created by a trailing \ slash.

Should break\
Line 2
Originally created by @brandonkal on GitHub (Oct 27, 2019). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.9.4 - Can you reproduce the bug at https://try.gitea.io: - [x] Yes - [ ] No - [ ] Not relevant - Log gist: ## Description Markdown renderer does not respect new lines created by a trailing <kbd>\\</kbd> slash. ```md Should break\ Line 2 ```
GiteaMirror added the type/bug label 2025-11-02 05:41:59 -06:00
Author
Owner

@warnat commented on GitHub (Oct 28, 2019):

I can find no trace inside markdown documentation to use a backslash for linebreaks.
2 spaces at the end of a line or
should do the trick.

@warnat commented on GitHub (Oct 28, 2019): I can find no trace inside [markdown documentation](https://daringfireball.net/projects/markdown/syntax) to use a backslash for linebreaks. 2 spaces at the end of a line or <br/> should do the trick.
Author
Owner

@brandonkal commented on GitHub (Oct 28, 2019):

@warnat It is part of the commonmark spec

https://spec.commonmark.org/0.29/#example-631

@brandonkal commented on GitHub (Oct 28, 2019): @warnat It is part of the commonmark spec https://spec.commonmark.org/0.29/#example-631
Author
Owner

@brandonkal commented on GitHub (Oct 28, 2019):

And because GitHub Flavored Markdown is an extension of commonmark it is also do documented there https://github.github.com/gfm/#example-655

@brandonkal commented on GitHub (Oct 28, 2019): And because GitHub Flavored Markdown is an extension of commonmark it is also do documented there https://github.github.com/gfm/#example-655
Author
Owner

@warnat commented on GitHub (Oct 28, 2019):

@brandonkal I appologize for not digging deep enough.

@warnat commented on GitHub (Oct 28, 2019): @brandonkal I appologize for not digging deep enough.
Author
Owner

@guillep2k commented on GitHub (Oct 28, 2019):

We're using github.com/russross/blackfriday to render Markdown. We're currently using v1 (v0.0.0-20180428102519-11635eb403ff), but there's a PR in progress to upgrade into v2. I'm not aware that this case is handled by the library on any version.

@guillep2k commented on GitHub (Oct 28, 2019): We're using [github.com/russross/blackfriday](https://github.com/russross/blackfriday) to render Markdown. We're currently using v1 (v0.0.0-20180428102519-11635eb403ff), but there's a PR in progress to upgrade into v2. I'm not aware that this case is handled by the library on any version.
Author
Owner

@brandonkal commented on GitHub (Oct 28, 2019):

@guillep2k According to the tests, blackfriday 1.7.4 should be rendering a <br/>.

blackfriday has a github_flavored_markdown renderer option. Using that should ensure it is closer to GitHub's renderer. So if the PR uses that option, that will likely resolve this.

No worries @warnat

@brandonkal commented on GitHub (Oct 28, 2019): @guillep2k According to the [tests](https://johnmacfarlane.net/babelmark2/?text=first%5C%0Asecond), blackfriday 1.7.4 should be rendering a `<br/>`. blackfriday has a github_flavored_markdown renderer option. Using that should ensure it is closer to GitHub's renderer. So if the PR uses that option, that will likely resolve this. No worries @warnat
Author
Owner

@lunny commented on GitHub (Nov 2, 2019):

Since we have update github.com/russross/blackfriday on a recent PR. Could you try if it's resolved on master?

@lunny commented on GitHub (Nov 2, 2019): Since we have update `github.com/russross/blackfriday` on a recent PR. Could you try if it's resolved on master?
Author
Owner

@guillep2k commented on GitHub (Nov 2, 2019):

I'v just tested with 1.11.0+dev-171-gad6886170 (uses "github.com/russross/blackfriday/v2") and it's not supported either; I couln't find code to support that in it either.

Sorry, @brandonkal you suggest we use github_flavored_markdown, but we can't use it because it has a big limitation:

It's not customizable, and its goal is to produce HTML output equivalent to the GitHub Markdown API endpoint, except the rendering is performed locally.

We need that said customizations that github_flavored_markdown does not provide (blackfriday.WithExtensions, blackfriday.WithRenderer) in order to generate links and references to other issues and PRs, mentions, etc.

There should exist the possibility of creating a line break by escaping it with two spaces before the end of line:

My line__      <--- replace "_" with spaces
other line

However it does not work either because all of our content uses "\r\n" (why?) and blackfriday expects "\n" for that function. 😔

Just for testing, I've tried replacing "\r\n" for "\n" in the database, and it makes it work for the two-spaces escaping, but it has no effect on the \.

@guillep2k commented on GitHub (Nov 2, 2019): I'v just tested with 1.11.0+dev-171-gad6886170 (uses "github.com/russross/blackfriday/v2") and it's not supported either; I couln't find code to support that in it either. Sorry, @brandonkal you suggest we use **github_flavored_markdown**, but we can't use it because [it has a big limitation](https://github.com/russross/blackfriday#other-renderers): > It's not customizable, and its goal is to produce HTML output equivalent to the GitHub Markdown API endpoint, except the rendering is performed locally. We need that said customizations that **github_flavored_markdown** does not provide (`blackfriday.WithExtensions`, `blackfriday.WithRenderer`) in order to generate links and references to other issues and PRs, mentions, etc. There should exist the possibility of creating a line break by escaping it with two spaces before the end of line: ``` My line__ <--- replace "_" with spaces other line ``` However it does not work either because all of our content uses `"\r\n"` (why?) and blackfriday expects `"\n`" for that function. 😔 Just for testing, I've tried replacing `"\r\n"` for `"\n"` in the database, and it makes it work for the two-spaces escaping, but it has no effect on the `\`.
Author
Owner

@stale[bot] commented on GitHub (Jan 1, 2020):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 1, 2020): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@lunny commented on GitHub (Jan 1, 2020):

I think this has been resolved since we have used goldmark to instead blackfriday. see https://gitea.com/lunny/test_markdown/src/branch/master/README.md

@lunny commented on GitHub (Jan 1, 2020): I think this has been resolved since we have used goldmark to instead blackfriday. see https://gitea.com/lunny/test_markdown/src/branch/master/README.md
Author
Owner

@brandonkal commented on GitHub (Jan 1, 2020):

Resolved

@brandonkal commented on GitHub (Jan 1, 2020): Resolved
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4195