Copy link to clipboard
Copied
I make wine menus and I'm creating a template using GREP styles that will allow me to copy and paste a full menu from Excel into InDesign with character styles applied to all the right bits so they can be quickly personalised. I got it working perfectly on the prices, but on the wine descriptions which appear on the line after prices, I'm having no luck.
Here's basically what it looks like for a single wine:
Wine Name Here £2.50 £5.50 £8.50 £20.00
Wine description text here.
I'm trying to make it locate the description line by having it first find a price (£\d+.\d+) followed by a carriage return (~b), then start applying the character style (\K) to any set of characters till the end of the paragraph (.+\r)
I'm sure this should work, and it works just fine if I use this code in GREP find & replace instead, but it just won't apply it as a GREP style. Like I said, I've got formatting for the prices working perfectly. I've tried deleting the prices' GREP code to make sure it wasn't interfering, but I'm positive that it's down to the carriage return.
Can you just not apply GREP styles that involve carriage returns, or can anyone see if I'm doing something wrong?
Thanks
Hi, Joel. Thanks for the response. I went to Data Merge first because I've been using it for a lot of things recently, but it's not been useful for this specifically because I need all my records in the same text box and on the same page. Next Style seemed like a good call but didn't work either because it applies the first paragraph style to all of the copy-pasted content.
I've actually figured out a solution using GREP after sleeping on it by avoiding searching over the carriage return. Becau
...Copy link to clipboard
Copied
I think that the shortest answer possible is that a GREP style is part of a Paragraph Style, by definition. So that \r marks the end of the paragraph style. Your GREP style can't apply beyond the \r, because everything beyond that \r is in a different paragraph. That paragraph has its own paragraph style, right?
Would you like a longer answer? I can think of at least four different ways you can achieve your desired effect, but all of them involve very different workflows. How wedded are you to the copy-a-whole-Excel-spreadsheet part of your workflow? I'm guessing that you probably have already invested some effort into making layouts in Excel, because if I had a bunch of wine price lists trapped in Excel and I wanted to make it Very Easy to turn those Excel price lists into beautiful InDesign layouts, I'd use Data Merge. But if I had a bunch of well-formatted price lists in Excel and I needed for some reason to move them to InDesign, I'd... probably just destroy all of that formatting work in Excel, and use Data Merge.
If I had compelling reasons to not use Data Merge, I think I might try to use Next Style (which automatically applies a given paragraph style to the following paragraph). I don't know if that would work, never having ever copied entire Excel spreadsheets into InDesign. Perhaps you could tell us a little bit more about exactly how you are setting up your Excel file and your InDesign file. When I play around with it, I find that my clipboard brings in tab-delimited raw text when I copy and paste from Excel. If that's what you are doing yourself, then you can choose "Apply style, then next style" from the context menu when you right-click on a style in your Paragraph Styles panel.
Copy link to clipboard
Copied
Hi, Joel. Thanks for the response. I went to Data Merge first because I've been using it for a lot of things recently, but it's not been useful for this specifically because I need all my records in the same text box and on the same page. Next Style seemed like a good call but didn't work either because it applies the first paragraph style to all of the copy-pasted content.
I've actually figured out a solution using GREP after sleeping on it by avoiding searching over the carriage return. Because copying and pasting my list from Excel carries over a bunch of tabs into the end of my Wine Description line, I've located that line using this: ^.+\t+\r and it does the job just fine. Now I just need to make sure those tabs don't cause me any spacing issues!
Copy link to clipboard
Copied
Any chance you can show us an example of the Excel? Just for fun. We like brain teasers.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I'm not all all following your GREP description. I'd use a positive lookbehind to locate the end of the price string through the paragraph return, then select the next whole sentence. I am not quite sure what you're doing with \K, there. 🙂
Copy link to clipboard
Copied
I'm not all all following your GREP description. I'd use a positive lookbehind to locate the end of the price string through the paragraph return, then select the next whole sentence. I am not quite sure what you're doing with \K, there. 🙂
By @James Gifford—NitroPress
It's not about Find&Change - GREP Styles are limited to a single paragraph - but I'm pretty sure you know that.
Copy link to clipboard
Copied
> I am not quite sure what you're doing with \K, there.
\K is lookbehind. It differs from (?<=. . .) in that it (\K) can have variable-length matches, which the traditional lookbehind (?<=. . .) cannot.
Copy link to clipboard
Copied
Yes, I understand that — I sorted out that command to my satisfaction in updating my chart last week. But from the description of the string, I can't figure out how \K accomplishes anything after the prior element (the sentence through the prior carriage return) has been selected. There's no good approach using lookbehind I can think of — so my conclusion is that the OP's whole GREP strategy needs revision.
Copy link to clipboard
Copied
Agreed. As others have pointed out, the scope of a Grep style is a paragraph so any reference to the previous or next paragraph (either in a lookahead/behind or unconditionally) disables the Grep style. The only \r you can include is the one following the paragraph because it's part of the paragraph. So
\d+\r Works
\r\d+ Does not work
\r\d+\r. Does not work