I have a large HTML document containing C++ inline <code>
sequences like foo->bar
. Because hyphens are often used to induce line breaks, this sometimes results in output like:
blah blah
foo-
>bar
blah blah
which is undesirable.
- Replacing the
-
(U+002D) with a‑
(U+2011; non-breaking hyphen) isn't acceptable because it breaks searching for->
in common browsers. - Styling
<code>
elements withwhite-space:nowrap
is undesirable because some inline code segments are long enough that they really should wrap. - Manually styling each
->
operator with<span style="white-space:nowrap">
(or<nobr>
) is unacceptable because of the editorial burden, but it's possible to write a script to do this.
Is there a declarative way to specify that inside ->
isn't a good place to break a line?
(This question is not actually a duplicate of How can I use CSS to preserve line breaks in an HTML <code> block?: this question asks how to avoid line breaks, while that question asks how to create them.)