camilo umaña wrote:
We need to tag only those numbers that are finishing the line...
I'm not sure I see the problem with applying a non-breaking space after the digit, wherever it falls. If it's at the end of the line it will move to the next line, if it's not at the end it will do no harm and you won't notice the non-breaking attribute.
GREP can't find things like that - it can only find at the beginning of a word/paragraph or at the end of a word or paragraph - but it doesn't know when something is approaching the end of a line within a story.
It will either find a string of numbers or nothing at all - it can't descriminate between, 1 apple, 100 mgs and 1000 mgs and 2004 (year).
It can find just a Number (\d) or a string of numbers (\d+) or you can instruct for (\d{3}) to find 1 or 3 digits etc.
The next piece of the puzzle is the space which is \s+ for a constant string of white space, which also includes tabs and other space characters. If you want just a Space then you have press the space bar so it looks like this (without the brackets) (_+) (the underline represents a blank space by pressing the space bar).
So the GREP solution would have to find any number followed by a space and either replace the space with a non-breaking space or a Apply a No Break in the style.
The problem with the Script Solution and the Find/Change is that I imagine you'd have to it multiple times and if you forget to do it once then you end up with a number being left behind on the line above.
I'd still be inclined to use a GREP style to change the Number followed by a Space into a Non-Breaking character style.
But a script can find the last word at the end of a page.
Why not at the end of a line? This seems scriptable.
Anyway, the situation is very clear: only numbers at the end of a line.
If a script just marks this numbers (as in the scripts made by Jong or InTools) the rest could be very easy with Grep.
For the moment the task has to be made manually, but almost 700 recipes and at least 1 1/2 occurrence the future is black.
Thank you for your tips.
You should not need to insert a hard or soft return. All that happens when you use a non-breaking space, or Eugene's No Break character style, is to guarantee that you will never have a number followed by a space at the end of a line unles it really is the end of a paragraph. Anytime there is something following that space the pargaraph composer will automatically keep the number and space together with that next character. If there is not enough space on the line for all of it to fit, it will move to the next line automatically. If recomposing will work, ID may bring additional charcates from the following line up. In any case, if the number and space fall anywhere other than the end of the line, a non-breaking attribute is irrelevant.
This is very similar to using a non-breaking space between the last two words in a paragraph to prevent the last line from having only one word.
North America
Europe, Middle East and Africa
Asia Pacific