Skip to content

--prose-wrap=preserve should preserve line breaks in Markdown inline code spans #11372

@andersk

Description

@andersk

Prettier 2.3.2
Playground link

--parser markdown

Input:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod `tempor
incididunt` ut labore et dolore magna aliqua. Ut enim ad minim veniam, `quis
nostrud` exercitation ullamco laboris nisi ut aliquip ex ea commodo `consequat.
Duis` aute irure dolor in reprehenderit in voluptate velit esse cillum dolore `eu
fugiat` nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Output:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod `tempor incididunt` ut labore et dolore magna aliqua. Ut enim ad minim veniam, `quis nostrud` exercitation ullamco laboris nisi ut aliquip ex ea commodo `consequat. Duis` aute irure dolor in reprehenderit in voluptate velit esse cillum dolore `eu fugiat` nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Expected behavior:

This input should not be changed. Even though the line breaks are not significant to the output, their removal results in extremely long source lines that make editing unpleasant.

One can of course manually rewrap paragraphs to avoid line breaks inside code spans, but that means fighting against the default behavior of the automatic rewrap function in most editors.

This isn’t an issue when Prettier is given charge of wrapping (--prose-wrap=always or --prose-wrap=never), but with the default --prose-wrap=preserve, Prettier should preserve the existing line breaks inside inline code spans.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions