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

Get Text's case mode

Contributor ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

Hi,

     We can get the capitalization of the selected text using the below code.  How can we get the case mode(Title Case, Sentence Case) of the selected text.

          app.selection[0].capitalization

  How can we check what kind of case mode is applied to text??

TOPICS
Scripting

Views

1.0K

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
People's Champ ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

Well you evaluate text capitalization property against its possible enums:

https://www.indesignjs.de/extendscriptAPI/indesign10/#Capitalization.html

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
Contributor ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

Hi,

     I can get the capitalization for text.

Screen shot 2017-12-20 at 12.06.39 PM.png

    I don't know how to get changeCaseMode for text.

Screen shot 2017-12-20 at 12.06.59 PM.png

I need to check whether a paragraph has sentence case or title case... So i need to get Case of text. If i use capitalization of selected text return for that case is Normal based on paragraph style property. How can I check a paragraph is sentence case or title case??

  alert(app.selection[0].capitalization );

returns the below value.

Screen shot 2017-12-20 at 12.21.31 PM.png

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
Guide ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

Hi,

You are checking the attributes under Capitalization

Screen Shot 2017-12-20 at 12.28.18 PM.png

so if you need to check the Capitalization means you have to use IF condition with all attributes available in the changecase

Screen Shot 2017-12-20 at 12.28.30 PM.png

Please take a look of the following threads, you may get some idea..

Re: ChangeCase [JS]

Re: Cleaning up script

Re: Make a words Sentence Case?

Re: How to check the words of next characters is Capital Leter or not its Urgent!

Re: Re: Re: Script to replace small caps that are typed as capital letters with non-capital letters ...

Re: GREP to convert first letter of all paragraphs from lowercase to uppercase?

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
Contributor ,
Dec 19, 2017 Dec 19, 2017

Copy link to clipboard

Copied

Hi,

     thanks for the links... I will check and come back...

     I need to check the case of a paragraph contents based on paragraph style.  If the paragraph contents does not have specified case (eg., Sentence case) , i need get those as report.  How can i check the case applied to text (paragraph) with my inputs (eg., Title 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
Contributor ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

Hi,

     I checked links which you gave...  From tat what i understood is, we can change the case of a paragraph using paragraph style.

     1. Can we get and check the paragraph case with specific case (user input).

     2. If suppose, we are applying cases to the paragraph, how can we handle the text like 2a. (If we apply all caps it will convert 2A, in that case how to handle 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
Guide ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

Yes  checking and converting is possible, you can try a basic script from the link I gave

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
Contributor ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

I read the links which u gave...  For tat we need both paragraph style and also case.  Based on style and case, we can one case to another case based. But what i need is,

1. Get paragraphs based on style (We can get using findtext with style).

2. Get the case of the paragraph or resultant of step 1.     - How to get these??

3. Need to check the case of step 2 with the specific (user case).

    If i use both style and case means wrong cases in that specified style will get miss...

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 ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

I think you are assuming that the changeCase function is something like the All Caps attribute. That is not the case so. The function changes the actual text, the attribute merely sets a flag so InDesign knows how to display it.

So you cannot "get the case" as an enumeration or some other predefined value.

2. Get the case of the paragraph or resultant of step 1.

Make a copy. Convert this copy to Sentence Case. Compare the plain text. If the result is equal, the original was correct.

It is also possible to read the plain text into a Javascript string and compare this against your desired Sentence or Title Case. For that, read the links tpk1982  provided and adjust so it does not write the result back into the document.

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
Guide ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

For your first question.. the link which I provided have the solution.. Please check again

Re: Make a words Sentence Case?

Screen Shot 2017-12-20 at 3.40.11 PM.png

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
Contributor ,
Dec 22, 2017 Dec 22, 2017

Copy link to clipboard

Copied

LATEST

Hi,

     From the posts, what i can understand is, we can change the case using style or grep. We can get the capitalization value but  cant get the case of the paragraph.  So we cant check paragraph case with specific one and generate report.  But we change the case.

Thanks all...

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