12/16/2023 0 Comments Bbedit grepI tried again and got it to work by selecting a simpler chunk of text, and a little trial and error implicated a cross-reference in the original text that seems to be the culprit. Thanks Luis! – this worked – except that the first time I tried I got an error message when placing that basically said there was a missing “>” in the text (details below). Now you know what to watch out for, why it’s important, and some ways to possibly work around this limitation. With luck we’ll convince Peter to write up this technique in a future article for InDesign Magazine! Once there are tags around it, you can do the GREP Find/Change in InDesign itself. His method is to convert all the formatted text into tags inside the InDesign document itself! For example, italic text could be changed (by Find/Change or with a script) to be unformatted and with tags around it, such as this: I showed this method recently at The InDesign Conference, and Peter Kahrel (who was lurking in the back of the room) later said he prefers a different method that doesn’t require exporting tagged text. Tagged text is one method for managing already-formatted text with GREP. Gotta’ admit that’s pretty awesome, eh? But of course, it’s even better once we save the new tagged text file and import it into InDesign, replacing the original text: Here’s how it appears after we press Replace All: So the result is that all the characters in the family name (except the first one) are converted to lowercase. The code \L means “start converting text to lowercase,” and \E means stop the conversion. These are tags that, sadly, InDesign does not support at all. You may notice in the Replace field there are some other strange GREP tags: \L and \E. Here’s the Find dialog box from BBEdit, searching for the whole paragraph and then rearranging it with the proper formatting tags: For example, where we’d write $2 in InDesign (to replace with the second string of text it found), BBEdit uses the code \2. Note, however, that different programs use slightly different GREP commands. So if you’re using a text editor that understands GREP (such as BBEdit on the Mac), then you can easily work with this text. For example, on line 5 above, there’s a paragraph style called “names” applied to the paragraph, and then a character style called “lastName” applied to one word, and then the character style is turned off (disabled) for the rest of the paragraph. You can pretty much understand what’s going on. This setting makes it easier for humans to read.) (Note that the tagged text file above is exported using “Verbose” tags… that’s one of the options you’ll see when you export the story. However, this is different than markup (such as XML or HTML) where there is generally a beginning and ending tag. The formatting is all applied using tags. When you do that, you get a text file that you can open in any text editor: The first solution to this problem is to export the story in the “InDesign Tagged Text” format (using File > Export). But what if you need to use GREP Find/Change on formatted text? Two Solutions In general, you want to do all your text clean up (with find/change, etc) before you apply formatting. And obviously it can cause huge mistakes! This is the problem with GREP Find/Change on formatted text. See how the formatting stayed at the beginning of the paragraph? On the 3rd line, the original had 10 characters set to the bold style… and after the Find/Change, the first 10 characters are still bold - but it’s the wrong 10 characters! Oops! That’s easy to fix.īut the bigger problem is the formatting. That’s because I accidentally typed the comma in the Change To field. I should point out that this is just a simple approach… see this article for more on swapping names.Īnyway, when we click Change All, we find a couple of problems:įirst, the comma still separates the names. So we open Find/Change and use a relatively simple GREP expression to find the first word followed by a comma, followed by another word: Let’s say that we want to swap the names, so the first name comes at the beginning of each paragraph. For example, let’s look at a simple list, where the family names are tagged with a character style: The problem involves using the GREP tab of the Find/Change dialog box to alter text that already has formatting applied to it. I want to explain the problem and then share a couple of possible solutions. However, there is one significant problem with GREP that people rarely talk about… and if you aren’t aware of it, the problem can really bite you badly. It’s an incredibly powerful way to format or find or change a lot of text very quickly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |