Copier le lien dans le Presse-papiers
Copié
In my job, we create basically a phone book. Each entry is a paragraph, but each field of data is separated by a forced line break. If a company name is too long in the column, it will create a runt/cliff withing the boundary of the beginning of the paragraph to the end of the field of data (the forced line break). Is there a GREP I can run to identify when these happen? Note that I want to identify these, NOT do a change all.
In theory what I want is to search for a single word on a line that has a forced line break at the end, but has no "beginning" other than it being on a second line.
Does that make sense?
Just For Fun!
(^/) The Jedi
/*
_FRIdNGE-0728_LineRunt.jsx
by FRIdNGE, Michel Allio [30/07/2021]
*/
var myDoc = app.activeDocument;
var myCondition = myDoc.conditions.item("runt");
if (!myCondition.isValid) myCondition = myDoc.conditions.add ({name: "runt", indicatorMethod: ConditionIndicatorMethod.USE_HIGHLIGHT, indicatorColor: [255,186,131]});
var myStories = myDoc.stories,
S = myStories.length, s;
for ( s = 0; s < S ; s++ ) {
var myParas = myStories[s].paragraphs,
P = myP
...
Copier le lien dans le Presse-papiers
Copié
Well, I'm not completely certain that I understand exactly what you're not looking for, but I think that this will find what you are looking for:
\S+\n(?-m)
This will find any non-spaces followed immediately by a forced line break. I wrote this regex to look for non-spaces, but you may have to use something else, if you have single-word entries that you don't want your regex to find.
I did this by adding "multiline off":
(?-m)
This regex will not find anything other than that single word. If there is a trailing space after the word and before the forced line break, this won't match it.
Copier le lien dans le Presse-papiers
Copié
Think of it more so as:
^p
ABC Welding & Supply^n
Jane Doe^n
etc. etc.
But the column breaks it to look like:
^p
ABC Welding &
Supply^n
Jane Doe^n
etc. etc.
I want to find a single word (Supply) on it's own line, but has not been forced by a hidden character. Right now I don't know how to find any single word on it's own line. Is there a way to say "New Line" in text not made by a hidden character?
Copier le lien dans le Presse-papiers
Copié
This GREP expression should find a single word on a line by itself that is not preceeded by a line break and is followed immediatgely by another line break or a hard return:
(?<!~b)[\u\l]+(~b|$)
It will not find multiple words nor lines that have punctuation or trailing space, so you need to tell us if that is a possibility.
Copier le lien dans le Presse-papiers
Copié
The problem is that when I search within this selection alone, which has the runt I'm looking for. I does find Service, but it also found "Gentry" which is NOT on it's own line. What am I doing wrong? This new expression you've included does not find it either.
Copier le lien dans le Presse-papiers
Copié
Sorry.
I have to admit I'm a bit rusty with GREP. My query in fact finds the last word before a line break whether it is isolated or not, and thinking about it some more, I'm pretty sure it's not actually possible to find the beginning of a "naturally broken" line using GREP.
I think this was a topic of discussion many years back and there might have been a scripting solution suggested at the time.
Copier le lien dans le Presse-papiers
Copié
Thank you for the information. Is there an easy way to request this with Adobe?
Copier le lien dans le Presse-papiers
Copié
https://www.adobe.com/products/wishform.html
Understand that a feature request needs to have some explanation of how it will benefit large numbers of users. It's not entirely clear to me what exactly you want Adobe to do.
I did a quick forum search and came up with these two old threads that might help you:
Not being a scripter myself I can't really help with making changes, but it might be worth trying Jongware's script and seeing if it will work if you input my GREP expression in the prompt. My gut says it probably will not, but you can give it a shot.
Copier le lien dans le Presse-papiers
Copié
I'm unclear why you're using forced line breaks as I see in your screen shot? Doing so makes formatting your text with character styles much more work than if you'd used conventional paragraph styles. This kind of formatting also precludes you from using InDesign's Apply Next feature, which is a very fast and powerful tool for quickly applying sequential styles to a cascade of text. Unless there's a compelling reason to do so, I almost never use forced line breaks and don't teach their use to my students.
Copier le lien dans le Presse-papiers
Copié
This is how my company creates listings. We typically apply character styles using a table at the beginning of our import process. Not every field of data is used when we import these listings, so the apply next feature wouldn't work well. We also need to ensure that all lines in the paragraph are kept together. Also, we need this feature for more than just listings as we also use them in are articles
Copier le lien dans le Presse-papiers
Copié
We also tend to use paragraph shading/boxing en masse for a lot of our project which wouldn't work with multiple paragraph styles
Copier le lien dans le Presse-papiers
Copié
Also, I am still getting orphans/cliffs even if I converted my styles to a paragraph style. Other than balance ragged lines, it doesn't solve my issue that a single word sometimes ends on a line by itself. If I were able to convince my job to change to paragraph styles, we wouldn't be fixing the problem without a script or GREP being written to find this. My Scripting skills are null. So i'm not sure what I'm even writing when I attempt to solve this issue.
Copier le lien dans le Presse-papiers
Copié
Hmm. OK. Looks like a convoluted solution to me, but if it works for you so be it.
Copier le lien dans le Presse-papiers
Copié
I am a very slow scripter, but I'm about 1/3 of the way through a script that will analyze all paragraphs in a story, find all lines that have only one word, and then Do Something. I'm working this way because I don't think you've ever said what you want that Something to be.
But if it's as simple as "how do I prevent runts?" then it's comparatively easy to write a regex find/change query that applies No Break to the last two words before any forced line break, or that inserts a no-break space right before the last word before a forced line break, or that applies No Break to the last n characters before any forced line break.
Copier le lien dans le Presse-papiers
Copié
That is awesome thank you. The something I want to happen is only to find them. The goal is to help proof the layouts we're working in and find the errors easily to make whatever judgement to fix them. So I just need it to find the error. Maybe that will help make the script easier?
Copier le lien dans le Presse-papiers
Copié
In All reality, I don't know if a script can do a single find/change find/change like we can with the Find/Replace funtion. But If I can at least identify these runts, that would be most helpful
Copier le lien dans le Presse-papiers
Copié
Just For Fun!
(^/) The Jedi
/*
_FRIdNGE-0728_LineRunt.jsx
by FRIdNGE, Michel Allio [30/07/2021]
*/
var myDoc = app.activeDocument;
var myCondition = myDoc.conditions.item("runt");
if (!myCondition.isValid) myCondition = myDoc.conditions.add ({name: "runt", indicatorMethod: ConditionIndicatorMethod.USE_HIGHLIGHT, indicatorColor: [255,186,131]});
var myStories = myDoc.stories,
S = myStories.length, s;
for ( s = 0; s < S ; s++ ) {
var myParas = myStories[s].paragraphs,
P = myParas.length, p;
for ( p = 0; p < P ; p++ ) {
var myLines = myParas[p].lines,
L = myLines.length, l;
for ( l = 0; l < L-1 ; l++ ) if ( myLines[l].characters[-1].contents === " " ) myLines[l+1].appliedConditions = [myCondition];
}
}
Copier le lien dans le Presse-papiers
Copié
THIS WORKS EXACTLY LIKE I NEEDED IT! Thank you SO much!
On a side note, do you have a good resource for me to start learning what this coding means? Or where I should go to learn how to write my own scripts?
Copier le lien dans le Presse-papiers
Copié
Other way based on Grep!
/*
_FRIdNGE-0728B_LineRunt.jsx
by FRIdNGE, Michel Allio [30/07/2021]
*/
var myDoc = app.activeDocument;
var myCondition = myDoc.conditions.item("runt");
if (!myCondition.isValid) myCondition = myDoc.conditions.add ({name: "runt", indicatorMethod: ConditionIndicatorMethod.USE_HIGHLIGHT, indicatorColor: [255,186,131]});
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = ".+";
myFound = myDoc.findGrep();
var F = myFound.length, f;
for ( f = 0; f < F ; f++ ) if ( myFound[f].lines.length == 2 ) myFound[f].lines[1].appliedConditions = [myCondition];
app.findGrepPreferences = null;
(^/)
Copier le lien dans le Presse-papiers
Copié
Is there a way to go further with a "myWords" and have the word count be 1 on a line?
Copier le lien dans le Presse-papiers
Copié
In the 2nd Script, change this line:
for ( f = 0; f < F ; f++ ) if ( myFound[f].lines.length == 2 && myFound[f].lines[1].words.length == 1 ) myFound[f].lines[1].appliedConditions = [myCondition];
(^/)
Copier le lien dans le Presse-papiers
Copié
In the 1rst Script:
for ( l = 0; l < L-1 ; l++ ) if ( myLines[l].characters[-1].contents === " " && myLines[l+1].words.length == 1 ) myLines[l+1].appliedConditions = [myCondition];
(^/)
Copier le lien dans le Presse-papiers
Copié
I love this script that highlights runts. So perfect!
But after going throught the file fixing the runts I want to, I'd like to turn off the highlights but no clue how to do that. I never realized ID doesn't have a highlight text feature. Is there a script we can use that will unhighlight everything?
Thanks so much for you expertise and time 🙂
Copier le lien dans le Presse-papiers
Copié
I should add that I would like to use the 1st script, which works great. I tried the 2nd one but it only found runts in paras that only have 2 lines. It wouldn't find the runts in paras that had more than 2 lines.
Copier le lien dans le Presse-papiers
Copié
Oh! I found it now, just delete runt in the conditional text panel, to remove the highlights
Trouvez plus d’idées, d’événements et de ressources dans la nouvelle communauté Adobe
Explorer maintenant