-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown: Preserve non-breaking spaces in inline code #6402
Comments
/cc @ikatyang |
It seems we should only process normal whitespaces (0x20), tabs (0x9), and newlines (0xA, 0xD): prettier/src/language-markdown/preprocess.js Lines 31 to 41 in 2314640
|
I think we should leave inline code untouched, because we don’t know in which language it is so anything we do may break it. Suppose, for example, that I’m writing Markdown to document Prettier, and I want to write about how Prettier would convert multiple tabs. |
According to the CommonMark spec "Line endings are treated like spaces", newlines are always valid to process. As for the whitespaces and tabs, it is hard to decide if we should process them given that browsers typically render them as single spaces, or should we respect the |
Yes, you’re right. Normal whitespaces (0x20), tabs (0x9), and newlines (0xA, 0xD) may all be processed. I don’t see a point in respecting |
Those whitespaces are sensitive if you apply CSS (e.g., |
If we were to consider that case, then we couldn’t change whitespace anywhere because of, for example, |
Just wanted to chime in that a fix for this would be great. My use case is aligning fixed-width text with spaces, e.g.
|
Whether or not newlines are significant to the output, replacing them with spaces can result in extremely long source lines that make editing unpleasant. I opened #11372 for this. |
Also experiencing this. Being a two year old issue, I'm kinda surprised I'm only just now encountering it. Use case: I'm trying to write documentation for GitHub and VSCode and don't want some inline code examples broken up across multiple lines. What I typed: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis dignissim massa ex. What prettier outputs: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis dignissim massa ex. (view on desktop in a maximized window rather than mobile to see the difference) |
Fixed by #13590 in |
Since #3320 non-breaking spaces are preserved in Markdown prose, but they still aren’t preserved in inline code, which would have been useful to avoid line breaks in things like
x = 2
.In the listings below
␣
represents a regular space, and•
represents a non-breaking space.Prettier 1.18.2
Playground link
Input:
Output:
Expected behavior:
The text was updated successfully, but these errors were encountered: