Skip to content

markup: keep line breaks in issues and comments like GitHub - #8607

Merged
unknwon merged 4 commits into
mainfrom
markdown-hard-line-breaks
Nov 16, 2026
Merged

unknwon merged 4 commits into
mainfrom
markdown-hard-line-breaks

Conversation

@unknwon

@unknwon unknwon commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Describe the pull request

Markdown written in Gogs now keeps its line breaks, like GitHub's issues and comments. Markdown files keep joining the lines of a paragraph, like GitHub's files.

Fixed the login loop
Thanks @demo

Before, this comment rendered as "Fixed the login loop Thanks @demo". Now it renders as two lines.

Renders every line break Joins the lines of a paragraph, unless ENABLE_HARD_LINE_BREAK is set
Issues, comments, release notes, milestone descriptions, issue emails, the comment preview, API POST /markdown READMEs, .md files, wiki pages and their preview, the server notice banner, API POST /markdown/raw
  • markup.Markdown always renders hard line breaks. The new markup.MarkdownFile follows [markdown] ENABLE_HARD_LINE_BREAK, which is still off by default, and the file call sites use it.
  • Behavior change: existing issues and comments written with single newlines now show those line breaks, as they would on GitHub. Setting ENABLE_HARD_LINE_BREAK no longer affects them.
  • This also makes emoji shortcodes at the start of a wrapped line render in comments, as on GitHub: x\n:tada: gives x<br>🎉.
  • FuzzMarkdown now covers both modes, and its reference render now sets the emoji table, which markup: render emoji shortcodes in Markdown like GitHub #8600 forgot. Without that, fuzzing reported a false difference on any shortcode.

Screenshots

Issue: line breaks kept

Issue body with three lines

README: lines of a paragraph joined

README paragraph joined

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code and provided the test plan below.
  • I have added an entry to CHANGELOG.

Test plan

  1. go test ./internal/markup/... passes. TestMarkdown_LineBreaks checks that Markdown keeps line breaks with the setting off, that MarkdownFile and RawMarkdown join lines with it off, and that MarkdownFile keeps them with it on. The task list test now expects GitHub's comment output (review<br>). The emoji and code-in-list tests, which compare with GitHub's file rendering, now use MarkdownFile.
  2. go test -fuzz FuzzMarkdown ran 1.8 million inputs in both modes with no difference from bluemonday.
  3. Ran a -tags prod build with the default config and checked:
    • A three-line issue body renders as three lines.
    • The comment preview shows line one<br>line two.
    • A README with wrapped lines and a wiki page with two lines each render as one paragraph.

Markdown written in Gogs, e.g., issues, comments, release notes and
milestone descriptions, now renders every line break as written, as on
GitHub. [markdown] ENABLE_HARD_LINE_BREAK now only applies to Markdown
files, e.g., READMEs and wiki pages, which keep joining the lines of a
paragraph by default.
unknwon added a commit that referenced this pull request Nov 16, 2026
@unknwon
unknwon merged commit 0277dcf into main Nov 16, 2026
11 checks passed
@unknwon
unknwon deleted the markdown-hard-line-breaks branch November 16, 2026 02:18
unknwon added a commit that referenced this pull request Nov 16, 2026
The editor's Preview tab rendered a Markdown file like an issue, which
keeps line breaks since #8607, with links resolved against the
repository root. It now renders like the file does, with links and
images resolved against its directory, as the legacy editor did.
unknwon added a commit that referenced this pull request Nov 17, 2026
Since #8607, markup.Markdown keeps line breaks the way issues do.
Notebook cells are documents, so they render with MarkdownFile like
Jupyter and GitHub.
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

Successfully merging this pull request may close these issues.

1 participant