Muliple NBSPs in code secontion in markdown string are collapsed
See original GitHub issuePrettier 2.7.1 Playground link
--parser markdown
Input:
For example, the string `"a b"` (three spaces between _a_ and _b_) separates _a_ and _b_ more than `"a b"` (one space between _a_ and _b_).
Output:
For example, the string `"a b"` (three spaces between _a_ and _b_) separates _a_ and _b_ more than `"a b"` (one space between _a_ and _b_).
Expected behavior:
I replaced regular spaces with Non-breaking spaces to prevent the collapsing of the spaces that occurs with regular spaces, but if you look at "a b"
it shouldn’t be collapsed as it renders correctly.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Is there a markup for multiple spaces in code?
I would like to put a string of spaces in code in an SO answer: ddl1.Items.Add("12 34"). Without code, I can use ...
Read more >How do I ensure that whitespace is preserved in Markdown?
Markdown is used primarily to generate HTML, and HTML collapses white spaces by default. Use instead of space characters.
Read more >Multiple spaces in backticks - Spec - CommonMark Discussion
I use inline backticks only to show code portions or string constants. Dropping spaces for such cases looks very bad idea. At least,...
Read more >Markdown Syntax - dotCMS
Learn about markdown that allows you to write using an easy-to-read and write plain text format, which converts to valid HTML for viewing...
Read more >Allow for preserving non-semantic whitespace and softbreaks
Problem Using the library I noted that the content of the markdown is not dealing properly with multiples whitespaces.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Potential fix: https://github.com/prettier/prettier/pull/13590
It’s collapsed by the browser. In the HTML markup, it’s still 3 spaces. I’d vote for removing this
replace
unless there really is a case when it’s doing the right thing.Actually, according to the CommonMark spec, the only correct replacement would be to replace line endings with spaces.