6

Here is the comment I wrote, but the back ticks do not display as code. It works in this post. How to fix?

No, I got => ["this", "is", "the", "string", "to's", "split", "real", "", "ok", "", "nice-like"] which has one empty string.

6
  • No, I got => ["this", "is", "the", "string", "to's", "split", "real", "", "ok", "", "nice-like"] which has one empty string.
    – N.N.
    Mar 15, 2012 at 14:32
  • 3
    I'm able to reproduce this only if there's a space between the backtick and =. Like this: ` = broken` ... Working: = Working Mar 15, 2012 at 14:34
  • 2
    Though, everything with a space between the backtick and the first character of the code breaks...not sure if that's a bug. Mar 15, 2012 at 14:35
  • No, I got => No, I got => ["this", "is", "the", "string", "to's", "split", "real", "", "ok", "", "nice-like"] Mar 15, 2012 at 14:40
  • Wow, this is a really awful bug. In this comment, a space after the backtick was necessary to explain the code.
    – myrdd
    Dec 4, 2018 at 16:17
  • Look at this example: I'm going to write <backtick><space><...some text...><backtick><dot>. The <dot> will function as ”end of sentence“. After that, I'm going to write <backtick><...some more text...><backtick><dot>; this time there's no space. In the demo you will see that the text between the two code sections (!) will be monospace. — Here's the demo: ` ...some text.... Here comes the second code section: ...some more text...`
    – myrdd
    Dec 4, 2018 at 16:17

2 Answers 2

16

You must not have blank space after the first backtick or before the last backtick.

In your comment to that answer you do have space before the last backtick:

comment space

Apparently the code filter in the comments is different and more "strict" than the filter in the posts but this explains this issue.

Whether by design or a bug, only developer can tell. :)

2
  • Thanks, that worked. I think it's a bug because the functionality is different when posting a question and posting an comment. Also, I don't see any reason that a space should prevent it from formatting code.
    – B Seven
    Mar 15, 2012 at 15:31
  • 1
    I agree so you can leave it tagged as a bug and hopefully mod or dev will come along and post official answer soon. Mar 15, 2012 at 16:06
0

If you do want a space as the first or last character in between the backticks, there's a (quite ugly) workaround:

Write

<backtick><U+2060><space>...some code...<backtick>

or

<backtick>...some code...<space><U+2060><backtick>

Note the U+2060, which is the Unicode word joiner (WJ). It's zero width (hence invisible) and non-breaking. You can copy-paste it from here:

«⁠»

It's enclosed in between « and ». You may need to select/copy the whole line (all three characters) to catch it, and then remove the enclosing characters after pasting.

Warning: there is a chance that when someone copies the code (⁠ ...some code... ⁠) including the invisible word joiner and pastes that into a code editor or a terminal, something won't work and, since the WJ is invisible, it's not obvious why it doesn't work. (I don't know if there's a solution to this..)

1
  • demo: ⁠ ...some code..., ...some code... ⁠
    – myrdd
    Dec 4, 2018 at 19:15

You must log in to answer this question.

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