Is there such a thing as a non-breaking underscore?

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Is there such a thing as a non-breaking underscore?

Post by ChoccieMuffin »

I have assorted items in my documents that are sets of letters separated by underscores (for example VAR_M, or CR_MINV_VNP). When one of these items appears at the end of a line I want the whole thing to move to the next line rather than break at the underscore. It would be so much easier if they were hyphens, then I could use a non-breaking hyphen! (I tried including the item inside a div within the paragraph but that didn't work as the item just appeared on its own line.)

At the moment I'm having to do this manually by inserting a linefeed before the item, but that then hard-codes a linefeed which doesn't look good in my online output.

Is there any way to force these items to always stay together? For example a non-breaking underscore? Any suggestions welcome.

:)
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there such a thing as a non-breaking underscore?

Post by ChoccieMuffin »

Well I see there was no response to my question so I'm not in the least bit surprised to discover that there isn't such a thing as a non-breaking underscore, confirmed by MadCap Tech Support.

That leads me to my second question which is, do any of you have a suggestion on how I can force a bit of text (e.g. CR_MINV_VNP) NOT to break? I tried wrapping it in a div (no go, divs don't work like that) and the only thing I'm left with is to insert a linefeed before the offending item.

Any suggestions? Or am I just, as they say, stuffed?
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
SKamprowski
Sr. Propeller Head
Posts: 277
Joined: Fri Feb 13, 2015 8:25 am
Location: Germany

Re: Is there such a thing as a non-breaking underscore?

Post by SKamprowski »

Hi ChoccieMuffin,

have you ever considered to use "custom hyphenation" for your words.
I assume you did, still I wonder why this is not a solution.
Kind regards,
Sabine Kamprowski
DocToHelp MVP (by ComponentOne)
Feebeegeebee
Sr. Propeller Head
Posts: 213
Joined: Wed Aug 08, 2012 8:38 am
Location: UK

Re: Is there such a thing as a non-breaking underscore?

Post by Feebeegeebee »

have you ever considered to use "custom hyphenation" for your words.
I think that if you highlight a word/phrase that has an underscore in it and try to create a custom rule, only the part before the underscore will be treated as a word.
So, for example, for "MY_CUSTOM_PARAMETER" I think the rule would only be applied to "MY".

However, would it be an option to highlight the paragraph containing your word and try Format > Paragraph > Hyphenation and under Enable Hyphenation choose Never?

Feebeegeebee
-----------------------------------------------------
Using Flare 2022 on Windows 11 (64-bit)
-----------------------------------------------------
King_Haggard
Jr. Propeller Head
Posts: 4
Joined: Thu Nov 28, 2019 8:12 am

Re: Is there such a thing as a non-breaking underscore?

Post by King_Haggard »

It is possible to fake a non-breaking underscore by repurposing three non-breaking hyphens and do some stylesheet magic. With this method you format the hyphens as subscript and remove the gap between the first two hyphens (but not between the last hyphen to the following character).

What you need to do:
  • Create a new span in your stylesheet:
span.subscript

{

vertical-align: sub;

letter-spacing: -2px;

}
  • Create another span:
span.subscript_2

{

vertical-align: sub;

}
  • Insert three non-breaking hyphens in the text where you want your non-breaking-underscore to be.
  • Assign span.subscript to the first two hyphens.
  • Assign span.subscript_2 to the last hyphen.
You can create a new snippet with the three characters for future use.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there such a thing as a non-breaking underscore?

Post by ChoccieMuffin »

That sounds like a really cool fix, but unfortunately it would mean that a user who copies from my output would then have MY---ITEM rather than MY_ITEM. But I do like your thinking! :lol:
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
Chicago_HPT
Sr. Propeller Head
Posts: 133
Joined: Sun Feb 03, 2013 6:01 pm

Re: Is there such a thing as a non-breaking underscore?

Post by Chicago_HPT »

.
Is this for online only, or do you have a print output as well?

I've had some good success for HTML5 output using the CSS white-space property, with a value of pre. I set up a span style as follows:

Code: Select all

span.no-wrap
{
	white-space: pre;
}
Then to implement it, simply span the text you don't want to wrap, for example:

Code: Select all

<p class="bodyText">Lorem ipsum dolor sit amet, consectetur adipiscing elit. <span class="no-wrap">Etiam augue nulla, convallis vel gravida at, feugiat</span> in dui. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc congue nec purus sit amet eleifend. Nulla euismod ex a cursus convallis.</p>
The first line should break after "adipiscing elit." Unfortunately, I haven't had much luck using white-space for print (PDF) output.

I hope that helps,
-jeff
oceanclub
Sr. Propeller Head
Posts: 277
Joined: Thu Oct 10, 2013 4:45 am
Location: Dublin

Re: Is there such a thing as a non-breaking underscore?

Post by oceanclub »

Is there really no proper fix for this? It's a problem developers have highlighted in our documentation that variable names containing underscores are breaking across two lines.

P.
Post Reply