• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there a script for changing curly quotes to straight after numbers?

Community Beginner ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

I have found a number of posts with replies about using keyboard shortcuts for changing curly quotes to straight quotes, but that involves working sentence by sentence, paragraph by paragraph to find the specific quotes that need to change. Straight quotes are standard with numbers; curly or typographer's quotes are otherwise standard. I am working with a lengthy, nonfiction manuscript that has numerous instances of mapping coordinates, e.g., 33°31’18.47” N 111°24’56.96” W. Of course, typographer's quotes is turned on for general content, so I would need to search out every instance of the use of a coordinate or measurement and make the changes one at a time (and then pray that InD doesn't "auto-fix" them for me later). Is there a script through which I can search every instance where a curly single or curly double quote immediately follows a number and replace it with the straight single or double quote? I tried looking at Find and Change putting in ^9" (Wildcard-Any digit; Double Quotes) in Find, but Change does not offer any wildcards or numbers so I can't use this feature. A script would save me HOURS!!!

TOPICS
Scripting

Views

523

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 21, 2023 May 21, 2023

It would need a different GREP rule - but I would go for applying new CharStyle to the whole phrase as well - just in case. 

 

Votes

Translate

Translate
Community Expert ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

GREP will handle this, although the format string eludes me (I don't use it much).

 

You can also use simple Find-Replace, curly-quote for straight quote, and run it manually, unless the document has hundreds of quote marks. Sometimes just a manual/wetware operation is more reliable, and just as quick, as any elaborate automated one.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

Yes--hundreds...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

Hi @PacosMother, James is right—Find Grep will come to the rescue here.

 

Try searching for this:

 

(\d+°\s?\d+)[‘’']\s?(-?[\d\.]+)[“”"]

 

 

Change to:

 

$1'$2"

 

 

I'm not at my computer to test this, so step through a few times to check that it is working.

- Mark 

 

P.S. be careful when pasting the grep into the Find Grep panel in Indesign because sometimes the codes change when pasting. Have a close comparison between this and what you have in Indesign if it doesn't work. 

 

Edit 2023-05-21: okay after getting to my computer and trying it out, I noticed two things. (a) I had a typo. Fixed. (b) You need to turn OFF "Use Typographer's Quotes" in Preferences > Type. (You can turn it back on afterwards.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

I forgot to answer your simpler case, of a curly quote after a number ...

 

Find:

(\d+)[‘’]

Change to:

$1'

 

and for double quotes find:

(\d+)[“”]

Change to:

$1"

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

I will try both of these tomorrow since I just got home to see the suggestions y'all have made. Thanks M1B and James Gifford for your quick responses. I'll let you know how it goes. 🙂 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

It would need a different GREP rule - but I would go for applying new CharStyle to the whole phrase as well - just in case. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

simplify with \K and remove the $1 

\d+\K[“”]
"

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

Nice! I often forget \K because my brain's default regex flavour is javascript, which doesn't have it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

Being using GREP for years and only learned how to use \K last year, highly undocumented and found it difficult to find out what it was - people often posted it on the forums and it took me a while to figure it out. I'm not the brightest with coding but I love trying.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

LATEST

Thank you everyone--M1B, James Gifford, Eugene, and Robert--you've saved me so much time. I have a few saved Grep formulas (e.g., for runts, no-break at end of line) for little gremlins that don't look good in printed books. I need to remember that GREP is an option--seems I'm always looking for scripts when such an issue arises. I tried Eugene's suggestion first (since M1B thought \K was a good thing), and it worked beautifully. I remembered to turn off Typographer's quotes (Thanks M1B) before doing the search and replace. I did them one at a time for the first five or so and since it worked, I took a chance on Change All. That worked, too. Turned on Typographer's quotes again and did a simple search for " and then ' to confirm that all was well. It was. You guys are the best!! Thanks again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines