Skip to content

Markdown: Preserve double-space line break syntax #3319

Description

@infotexture

In the original Markdown syntax description, two spaces at the end of a line create a line break:

When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.

This syntax is also supported in the CommonMark spec:

A line break … that is preceded by two or more spaces and does not occur at the end of a block is parsed as a hard line break

Prettier currently replaces this with CommonMark's single-backslash notation (which works fine in some places like GitHub issue comments), but this syntax is not supported by kramdown, the default Markdown parser used by GitHub Pages, so the lines are joined and the backslash characters are visible in output when prettied Markdown is rendered via GitHub Pages.

The kramdown syntax requires two backslash characters at the end of the line for line breaks, but this renders elsewhere as two visible backslashes rather than a line break: \\.

Prettier 1.8.2
Playground link

--parser markdown

Input:

* **bold bullet one**  
    list continuation one
* **bold bullet two**  
    list continuation two

Output:

* **bold bullet one**\
   list continuation one
* **bold bullet two**\
   list continuation two

Expected behavior:

The double-space line breaks should be preserved for maximum source compatibility with a broad range of Markdown implementations.

Activity

  1. added
    lang:markdown
    on Nov 26, 2017
  2. azz commented on Nov 26, 2017

    @azz
    Member

    Trailing whitespace affecting output is... Unpleasant. But, alas, it is a bug.

  3. added
    status:has pr
    and removed on Nov 27, 2017
  4. ikatyang commented on Nov 27, 2017

    @ikatyang
    Member

    For reference, we followed the CommonMark spec, which is not 100% compatible with Kramdown.

  5. infotexture commented on Dec 7, 2017

    @infotexture
    ContributorAuthor

    👍 Looks like this was fixed for 1.9.

    Might be worth tagging with the milestone for future reference so people know which versions of Prettier will support the ··\n syntax.

  6. ikatyang commented on Dec 7, 2017

    @ikatyang
    Member

    Oops, missed this one.

  7. added this to the 1.9 milestone on Dec 7, 2017
  8. added
    locked-due-to-inactivity
    on Jul 6, 2018
  9. locked as resolved and limited conversation to collaborators on Jul 6, 2018
  10. added theissue type on Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:markdownlocked-due-to-inactivitystatus:has pr

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions