5

Problem: In a code block, a no-break space is substituted with a regular space. In certain cases, the writer's intention is to utilize a no-break space, not a regular space.

Situation: In this particular answer, the branch name input given to git command uses "no-break space" (non-breaking space, U+00A0 or  ). This is properly utilized in the code block. But in the rendered output, this is replaced with regular normal spaces.

For illustration, the non-breaking space is highlighted with pink blocks here. (Note that this is an illustration only, to show the difference. Stack Overflow is not expected to render like this.)

Markdown:

screenshot of markdown with no-break space made visible

Rendered output (if you copy this, you'll see that the no-break space has changed to a regular space):

git checkout -b US24024 Automated Tests - Profile A
Switched to a new branch 'US24024 Automated Tests - Profile A'
  1. Is there a particular reason that this choice of substitution is made?
  2. Is it possible to disable this substitution in the entire site?
  3. Is it possible to disable this substitution in a particular code block?

Important Notes:

  1. The linked answer is demonstrating the use of no-break space as a substitution for regular space for use in a Git branch name. (It is not an attempt to make the code block non-breaking.)
  2. The pink block is an illustration of the difference only. This bug report doesn't expect the rendering of no-break space in any style other than just a no-break space character in the HTML source code sent to the browser.
14
  • 1
    PS: This could be a problem of the browser (Firefox), and not necessarily the website.
    – ADTC
    Aug 25, 2022 at 8:52
  • The purpose of a no-break space is to ensure that the line doesn't wrap. The command will work fine with regular spaces, and probably should be typed with regular spaces (I'm not even sure how you'd produce a non-breaking space at the terminal without pasting it in, anyway). The line won't wrap anyway because it's preformatted text. So overall, I can't see how this has an actual meaningful impact. Aug 25, 2022 at 8:55
  • 2
    ...What? Non-breaking spaces are supposed to render as normal spaces. They're not supposed to render as some kind of reddish-pink block. Aug 25, 2022 at 8:57
  • @KarlKnechtel please take a moment to read and understand the linked answer and the question it's answering. Git branch names don't accept regular spaces, and the answer proposes using no-break spaces to achieve the effect of having a space in the branch name.
    – ADTC
    Aug 25, 2022 at 8:58
  • 1
    @CodyGray please take a moment to read and understand the problem I'm reporting. The pink block is for illustration only, to show that the non-breaking space was converted to a normal space in the rendered output. I'm not expecting you to render it as a pink block.
    – ADTC
    Aug 25, 2022 at 8:59
  • Is it actually a Git limitation, or it is a problem with the shell tokenization? Aug 25, 2022 at 9:01
  • Not allowing regular space in branch name is a valid Git limitation. The answer proposes a workaround using non-breaking space, but the code block is unable to demonstrate this workaround because the no-break space gets replaced by a regular space when it is rendered. That's what I'm saying is the bug here.
    – ADTC
    Aug 25, 2022 at 9:04
  • 1
    I see. So what, exactly, is the bug report? The site makes multiple substitutions of characters, even stripping out certain characters, as described here and here. There is no attempt made to make the rendered version match exactly, byte-for-byte, with the input. This is not a command shell, it is a Q&A site. (Also, when multiple people apparently find your post unclear, that might be a reason to wonder if it needs to be improved, rather than attack them for not reading it.) Aug 25, 2022 at 9:05
  • @CodyGray in simple terms, the bug report is "In a code block, a no-break space is substituted with a regular space. In certain cases like this answer, the writer's intention is to utilize a no-break space, not a regular space. So it's not a mistake that it's used here."
    – ADTC
    Aug 25, 2022 at 9:10
  • @CodyGray I have improved the question now, though perhaps I believed earnestly that the title alone (No-break space in code block renders as normal space) is clear of what I'm reporting, and the readers would read the description in the context of the title. Is it the word render that's somehow misunderstood, and the pink block exacerbated it by apparently making it seem that I want to see it as a pink block? (I don't.) What I mean is that the HTML source code of the website itself seems to have normal space characters where no-break space characters should be.
    – ADTC
    Aug 25, 2022 at 9:20
  • Note: Meta does support code blocks so you could demonstrate the problem in this post itself. Aug 25, 2022 at 9:49
  • TAB characters are also replaced by regular normal spaces (but preserved in the Markdown source). The only known instance where it matters is for Make files. Aug 25, 2022 at 9:51
  • Does this answer your question? Literal tab in code block renders as four spaces Note: I know this linked question is about tabs but a staff member has replied to that post mentioning that "we normalize whitespace in code blocks" Aug 25, 2022 at 10:03
  • Thanks @AbdulAzizBarkat. I thought in meta we also report problems, not just ask questions (though the report may have questions to facilitate discussion). I suppose your link gives me the resolution of WONT-FIX for this particular problem, and the solution is to warn the reader that copying from the code block won't work (and also direct them with an alternative solution). [Also I know about the code block here; after all it's the same editor. I was trying to show that the spaces changed. A picture is worth a thousand words, but not this one? But I will revise. Thanks for suggesting.]
    – ADTC
    Aug 25, 2022 at 10:18

1 Answer 1

-1

It seems that there is a prior decision to always normalize all other whitespace characters except new lines to a regular normal space. This affects tabs as well, which is cited as a problem for Make files. Perhaps it affects no-break spaces as well.

The suggestion is to make it clear to the reader of your answer that there are parts of the code block which aren't properly rendered by Stack Overflow, and to provide them with instructions or alternatives.

Reference question is here.

Not the answer you're looking for? Browse other questions tagged .