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

Adding Highlight to script Or Grep Style?

Advisor ,
Jul 20, 2016 Jul 20, 2016

Hi

Is it possible to Add a hightlight to a script?  Basically what i want it to do is Highlight text and the tricky part is that the text changes sizes depending on the size of file we're working on.  Say i want to automatically highlight this "FOR PROFESSIONAL USE ONLY" the way we do it now is Make a underline the like this in the underline options menu: Say my font size is 8, Leading 9.6 (These will always change).

Weight:  =   9.6

Offset:  =   -8*.33

Color = Yellow

That is the way we do it now.  Can it be scripted or Grep style even that will automatically do this for certain Lines of text only?  And no matter the size of font calculate what it needs to so whether its 2pt, 10pt 100pt etc... it will Highlight the specified text correctly?

hopefully this is possible.. 

Thank you

TOPICS
Scripting
7.4K
Translate
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

Mentor , Jul 25, 2016 Jul 25, 2016

The below one is a better.

I removes a bug and also if no "what" is provided to the highlight function and there's no entry in the find what of the find text panel and some text is selected then that text will be highlighted.

An idea in the script is that a keyboard short cut can be applied for it and it will get it's info from the find text panel.

So for the meantime change the correct answer to this one

// Highlight function by Trevor

// http://creative-scripts.com

// Custom Scripts for Adobe InDes

...
Translate
Mentor ,
Oct 13, 2018 Oct 13, 2018

use

highlight('\\d+-\\d+'); \\ you need to escape the escape, also extra brackets are not needed here so don't use them.

highlight('the word', app.activeDocument.swatches[4]); // you had to many 'quotes' in your expression

Translate
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
Participant ,
Jan 22, 2019 Jan 22, 2019

Hi,

The following greps are not working in script, but it's working by manual grep of find option.

highlight('-[\l\u]+');

highlight('(?<= \d)[\l\u]+\>');

please advice,

by

hasvi

Translate
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 ,
Jan 23, 2019 Jan 23, 2019

You need to escape the backslashes:

highlight('-[\\l\\u]+');

highlight('(?<= \\d)[\\l\\u]+\\>');

Translate
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
Participant ,
Feb 28, 2019 Feb 28, 2019

Hi Peter,

I am trying to find straight double quote and straight single quote in my text because both are not allowed as per guideline. Here, it works while using the below greps for straight double quote, but not able to find straight single quote text. I tried with two different grep option in my script but its not workout for me. (Because we are using the same straight quote to define the grep properties in the brackets, it may be reason).

highlight('^"'); -- finding well

highlight('^''); -- not finding and showing error in my script

any advice please.

by

hasvi

Translate
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 ,
Feb 28, 2019 Feb 28, 2019

> highlight('^''); -- not finding and showing error in my script

Use highlight ("^'") -- double quote / caret / single quote / double quote.

P.

Translate
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
Participant ,
Oct 15, 2018 Oct 15, 2018

Hi,

It is not running for grep changes as in below:

highlight('\\d+-\\d+'); \\ you need to escape the escape, also extra brackets are not needed here so don't use them.

I think we should add grep style in the code, because we added only for text that is:

app.findTextPreferences.findWhat = what;

(NOT: app.findGrepPreferences.findWhat = what;)

Please advice.

by

hasvi

Translate
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
Mentor ,
Oct 15, 2018 Oct 15, 2018

Yep the original code was pasted 2+ years ago, one would have to change all the app.text.... stuff to app.grep.... stuff in order for it to handle greps.

Translate
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
Participant ,
Oct 15, 2018 Oct 15, 2018

thanks...!!!!!

by

hasvi

Translate
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
Participant ,
Jan 23, 2019 Jan 23, 2019

Hi Kahrel, thanks and it works fine.

I am new learner of indesign script, so is there any guide to know about script writing?

Anyhow, thanks for your timing help.

by

hasvi

Translate
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 ,
Jan 23, 2019 Jan 23, 2019

See the first part of the list here: Scripting and GREP resources

P.

Translate
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
Participant ,
Jan 25, 2019 Jan 25, 2019

Hi Peter, thanks for your swift reply.

by

hasvi

Translate
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
Participant ,
Feb 28, 2019 Feb 28, 2019

Hi Peter,

thanks for your reply, but I want to find exactly only the straight single/double quote. While using this highlight ("^'") its finding all quotes.

by

hasvi

Translate
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 ,
Feb 28, 2019 Feb 28, 2019

Go to the GREP tab of the Find/Change dialog. Click the @ at the 'Find what:' field. Select 'Quotation Marks', then select 'Double straight quotation marks'. Now in the 'Find what:' field you see what you want to look for. Do the same with the single straight quatation mark.

P.

Translate
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
Participant ,
Mar 01, 2019 Mar 01, 2019

Hi Peter,

Did you mean this, but its finding all.

But I want only straight quotes not curly quote because our client will reject files if it has straight quotes.

by

hasvi

Translate
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 ,
Mar 01, 2019 Mar 01, 2019

No. You selected 'Any single quotation mark' from the list. You should take 'Straight single quotation mark'.

Translate
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
Participant ,
Mar 05, 2019 Mar 05, 2019

Yes, I selected but its searing all quotes including curly. I want to search only straight quote.

by

hasvi

Translate
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 ,
Mar 06, 2019 Mar 06, 2019

You did not select either of the straight single or straight double quotation marks. If you had, you'd have seen that they would have been entered as ~' and ~"

Translate
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
Participant ,
Mar 06, 2019 Mar 06, 2019
LATEST

Hi Peter,

Although, I selected from text it shows as in my screen shot. But I added the same grep in my script as below:

highlight('^"');

highlight("^'");

Now only I find it, that's my script is not working. But the same script I am using regularly to find the unwanted characters its suddenly stopped working...I am just blinking why this happened (this is new type of problem scripts not running)

Anyway, thanks for your swift reply.

by

hasvi

Translate
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