Creating non-breaking phrase in Github Markdown

I have a repository in which the formatting of the README.md results in an inappropriate line break that I’m trying to defeat. The specific failure is a break between a hyphen and a compiler option, what should be -lreadargs is instead rendered as - at the end of a line, with the lreadargs at the beginning of the next line.

I’ve made several attempts to wrap the text in some non-breaking element:

  • <nobr> I enclosed the offending text in <nobr>. When that failed to fix the problem, I looked at the HTML source and saw that the <nobr> was not included in the translation. It’s non-standard HTML, so fine.
  • <span style=“white-space:nowrap”> also failed. Looking at the HTML source, I could find the span element enclosing my text, but the white-space attribute was left out.
  • <span class=“svg-tip-one-line”> I looked at the CSS file included at the top of the HTML source, and looked for a simple class that included white-space:nowrap. The style attribute was omitted from the span element.

I think most people would agree that having a line break between an option’s hyphen and option name is unacceptable. Is there any way to prevent it?

It currently displays fine in Firefox 81.0.2:

Note: You have a typo in “lising” it’s missing a “t”.

Other options:
Re-write the text:

The following code listing is a complete program that can be compiled with the option gcc -lreadargs.

Specifically leverage a bullet:

The following code lising is a complete program that can be compiled with:

  • gcc -lreadargs

Add it in the code listing as a leading comment.

I’m sure there are other options too, but hopefully that gives you a few workable ideas.

1 Like

Thank you for your reply. I fixed the typo.

My screen may be the only place where this particular unwanted line break is manifested, with it’s specific font-size, screen width, etc. I didn’t include a screen print because it only shows that there’s a problem. The proof of the problem is found in the generated HTML code that has been stripped of the normal solutions. I’m hoping for a solution to remove line breaks for future cases where the offending line break falls in the middle of the sentence.

That isn’t one that I know of, aside from working around the issue in various ways as mentioned. Since it’s markdown not full HTML only a subset of HTML tags are supported.

If you’re really worried then I guess you could publish the content via GitHub pages, then you’d have more control over the formatting.