CreativePro Forum
Join our community of graphic designers, publishers, and production artists from around the world. Our members-only forum is a great place to discuss challenges and find solutions!
- You must be logged in to reply to this topic.Login
Apply style to every other/every third paragraph?
- This topic has 16 replies, 4 voices, and was last updated 14 years, 4 months ago by
Lala Lala.
-
AuthorPosts
-
-
April 16, 2011 at 11:03 am #59290
Lala Lala
ParticipantI have a copied/pasted block of text in this format:
PRODUCT NAME
product details
description text
Imagine about fifty of those, with a line of white space separating each one.
There are paragraph breaks after each line. What I want to do is bold just the product names. If I make a nested style that bolds everything up to the first paragraph break, then it of course bolds everything since each line is a new paragraph. Is there some trick with search and replace/grep that I could use? So far the best I can come up with is manually inserting an end-nested-style character in front of product details. But that's still tedious.
-
April 16, 2011 at 11:58 am #59292
Nenad Marinkovic
MemberInstead of paragraph breaks use line breaks ( shift+ enter), create bold character style, in nested style dialog box choose you character style and through 1 forced line break, then apply two empty {None} styles and then again your bold style with through 1 forced line break, then one more style and choose {repeat} last 3 styles. Maybe there's better way but try this, it should work just fine
-
April 16, 2011 at 12:11 pm #59293
Lala Lala
ParticipantI think I get what you're saying, I found a similar idea.
I didn't get how to use “next style” until I saw a tutorial on it here:
https://layersmagazine.com/usin…..esign.html
So basically this was what I created:
Paragraph Style 1 (bold) –> under general, set next style: Paragraph Style 2.
Paragraph Style 2 (normal) –> under general, set next style: Paragraph Style 3.
Paragraph Style 3 (normal) –> under general, set next style: Paragraph Style 4.
Paragraph Style 4 (normal) -> under general, set next style: Paragraph Style 1.
So it bolds the first line, the next two lines are normal. The 4th style is because the empty line between paragraps is considered a 4th paragraph. The style then loops back to the first style. For anyone else puzzled as to why their “next style” isn't automatically kicking in, you need to right click the style in your paragraph palette and then choose “Apply [stylename] then next style”.
-
April 16, 2011 at 2:53 pm #59294
Nenad Marinkovic
Memberhmmm , what do you mean by “empty line between paragraphs is considered a 4th paragraph”, you mean you hit Enter two times in the row? Isn't better to just adjust space after in 3rd paragraph style so you don't need 4th ?
-
April 16, 2011 at 4:07 pm #59296
Lala Lala
ParticipantI guess it wasn't clear but I didn't compose the original text. I had to copy and paste from someone else's text. I'm stuck dealing with mostly MS word documents, yuck.
-
April 16, 2011 at 5:33 pm #59297
Nenad Marinkovic
MemberYou can go to find/change dialog box and under query drop down menu choose Multiple Return to Single Return, that will clean up your text
-
April 16, 2011 at 9:23 pm #59298
Lala Lala
ParticipantI was actually wondering if there is any search/replace I could have done that would have changed the break for just the first line of each group. Right now every line ends with ^p. I was wondering if there's a grep I could do that would end the product line in each block (basically every 4th line) with ^n instead.
Then another search/replace would let me follow every line break with an “end nested style” character.
In retrospect that wouldn't have helped, it'd just apply the style to the very first line of the first block and then the style's done for the rest of the text. Too bad there's no “begin nested style” character.
Still, for my own education, is such a search and replace possible? Either change the ending character of just every 4th line, or maybe search for the pattern
^p^p [some random text] ^p, and replace with
^p^p [same random text] ^n?
-
April 17, 2011 at 5:38 am #59300
Theunis De Jong
MemberWatch it, you are using regular Find notation instead of GREP!
You could use (theoretically!) something like this: search for
^(.+r.+r.+r.+)r
and replace with
$1n
I don't think I would let such a replace go nuts on my text. You say it's a “product line”; I think I would play it safe and check what makes these a product line, rather than 'regular' text (i.e., a “Product name”, or Stuff With Capitals, or Added Serial Numbers-20B).
-
April 18, 2011 at 7:36 am #59302
Lala Lala
ParticipantCheers jong. I definitely need to learn grep, I only know the basic dos-ish wildcards. I think I can see at a glance how your example works, I just add or remove r. to adjust for more or fewer paragraph breaks? and then the $1 returns the original text (everything that matched within the parenthesis?) followed by a n?
-
April 18, 2011 at 1:25 pm #59305
Theunis De Jong
MemberWell, basically you got it, but it's a definite try-before-you-buy.
(Edit)
… Other than Peter Kahrel's GREP for InDesign e-book. That's a definite buy, for anyone venturing into the wonderful wizardry of GREP.
-
April 18, 2011 at 3:11 pm #59306
Lala Lala
ParticipantThat's a handy link and would no doubt do me a lot of good. But I'm a cheapskate. Would a general GREP tutorial I find online apply to indesign or is indesign's grep different?
-
April 19, 2011 at 2:09 am #59312
Theunis De Jong
MemberInDesign's GREP is different in the sense that it can also deal with typical InDesign attributes, and that's not something you can find anywhere else! (*)
But in general, the typical GREP commands are the same as anywhere else. There are a couple of 'dialects' of GREP, so not everything you find on https://www.regular-expressions.info/, for example, will work. I have a list of supported 'standard' functions at https://www.jongware.com/idgrephelp.html.
(*) It's also mentioned in the online help, of course. But you hardly can learn to use GREP from there, as it's just a list of commands.
-
April 19, 2011 at 8:08 am #59321
Lala Lala
ParticipantWell, it's nerdy to say but I'm excited to learn about grep. I'll probably be bringing stuff into indesign just to take advantage of the grep search.
-
April 19, 2011 at 4:02 pm #59330
Lala Lala
ParticipantI had to revisit this thread to plug this little course I found while searching for more resources. It's a very good, logically structured step-by-step to learning grep specifically for indesign. Professionally done and easy to follow.
https://www.lynda.com/InDesign-…..368-2.html
Not free but maybe worth the price of membership ($25.00) for anyone who has to use ID a lot and needs to waste a lot of time search-and-replacing or manually styling snippets of text in long documents.
-
April 20, 2011 at 6:24 am #59337
David Blatner
KeymasterCreeDo: Yes, no doubt that Michael Murphy's GREP course is good. If you want a shorter introduction to GREP, I would also humbly suggest my own movie there called “10 things you should know about grep and indesign”: https://www.lynda.com/tutorial/46812
-
April 20, 2011 at 9:18 am #59344
Lala Lala
ParticipantDavid I'll definitely give it a look. I'm currently struggling a little with GREP. In case you check back to this thread, maybe you or jong want to take a crack at this. Actually it's maybe mentioned in your tutorial.
I eventually solved the problem I was having with some imported text, but I still want to know if it's possible to style the first line of every paragraph using grep styles. Specifically I'm just curious if grep (within indesign) can ever work with multiple paragraph breaks as part of a match. Because as far as I can tell, it can't. It only applies to one paragraph at a time. You can't, as a condition, say “style everything that is preceded by 2 paragraph breaks”.
I tried a lot of ways and it seems like grep just stops within the boundaries of a paragraph break. I tried straight rr.+r or rr.+$ to style any line with two paragraph breaks in front of it. I tried a positive lookahead (?= rr).+$ …I tried seeing if I needed to specify the breaks as beginning of paragraphs using ^ rather than r …or maybe beginning then end of paragraphs like so: ^r^r.+$ or just …It simply doesn't match anything. Ever.
I found out about single line vs. multiline and tried enabling single line mode before the expression, it didn't help.
2. Another issue that I'm wondering about… No grep character can match an indesign “text box break” or whatever you'd call it. The natural word wrap that occurs when text hits the edge of the frame and goes to the next frame. Is there a known workaround for this other than manually breaking these lines?
My best solution, which I guess is perfectly ok, is to search and replace all paragraph breaks (r) with forced line breaks (n). Then the following works:
nn.+$
Any time I put a double line break, the next line of text is styled up til the end of line (but of course that's only to a break character, not to indesign's text frame breaking the line).
-
April 20, 2011 at 9:29 am #59345
Lala Lala
Participanterrr, all my backslashes got removed in the post and I can't seem to edit it. Oops. I guess I shoulda used a code tag of some sort.
Well the thrust of it is: grep doesn't seem to match backslash r backslash r.
-
-
AuthorPosts
- The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
