I would rather see inline code not wrap at all when possible. If an inline code block doesn't fit on the current line, it should be moved to the start of the next line.
That said, this is still problematic because inline code could still be too long for one line. For a well formatted post, these should be in a separate code block; then they would be scrollable. But there's no way to enforce that. So what can we do?
I considered suggesting that it should split only on whitespace. That would certainly help, but there's no reason that such a long code block even has to contain whitespace. What would we do in those cases? Any kind of splitting scheme based on the characters involved would run into this same problem: what do we do when an inline code block does not contain a character qualified for splitting?
There's also the notion that we should just make these code blocks scrollable when they pass the end of the line, but this seems to largely defeat the entire purpose of having inline code blocks. Inline code blocks are supposed to be short blocks that you want to flow with the rest of your text. Making an inline block scrollable would be jarring and ugly at best.
We shouldn't try to work around this with weird unicode characters, either. This would make it impossible to copy/paste portions of the code. Note that this isn't the same as "blindly copying and running code off the internet." You might copy/paste a single argument like in the example, for instance. If you make it a "non-breaking hyphen," my bet is that bash or your command would choke on it.
So it seems that we're always going to have weird cases where this can happen. I honestly don't think we can do any better than
- If an inline code block preceded by non-code text is too long for the current line, move it to the start of the next one.
- If it's already at the start of the line and it's still too long, split it as we already do. This will be ugly and may split in places you don't want, but that's what you get for abusing inline code blocks with that kind of length.
In the mean time, a work around would be to insert a line break (<br>
) prior to the code block. This is very annoying, though. Substantial changes to your answer could make the manual line break cause a split to the line in a very weird place, essentially making your attempts to make your answer look nice backfire.
(I've expanded my answer to clarify. In retrospect, I think my original second paragraph seemed too dismissive of the issue. I understand this is an issue, but trying to find a good solution is fiddly at best.)
-
, the editor doesn't writeXDataKinds
asX
on one line andDataKinds
on the other.-XDataKinds
).white-space: nowrap
oncode
elements (if we're talking about my suggestion).