🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
8 messages
8 total messages Started by Miguel_Sanchez Tue, 31 Mar 2009 03:40
Headline caps change for a newspaper
#167
Author: Miguel_Sanchez
Date: Tue, 31 Mar 2009 03:40
1 lines
697 bytes
How can change the first letter to an uppercase of a word in headline (paragraph), except for words of 1,2 and 3 letter words, with a script?
Re: Headline caps change for a newspaper
#174
Author: jongware
Date: Tue, 31 Mar 2009 09:50
11 lines
1223 bytes
With the changecase function. JS can access individual words in paragraphs, in the following way



for (i=0; i<app.activeDocument.selection[0].paragraphs[0].words.length; i++)

	if (app.activeDocument.selection[0].paragraphs[0].words[i].length > 3)

		app.activeDocument.selection[0].paragraphs[0].words[i].changecase(ChangecaseMode.TITLECASE);

It is restricted to what InDesign counts as 'words' -- a combined word with a hyphen, "two-fold" for example, is taken as two words. Applying your three-letter word rule would yield a headline such as "The Dangers of sun Rays are two-Fold". So some careful post-editing is required.
Re: Headline caps change for a newspaper
#176
Author: Robert Tkaczyk
Date: Tue, 31 Mar 2009 10:39
6 lines
824 bytes
why not using NestedStyles ?

robin

-- 
www.adobescripts.com
Re: Headline caps change for a newspaper
#178
Author: jongware
Date: Tue, 31 Mar 2009 11:13
3 lines
805 bytes
Because I have no idea how to do that using nested styles :-)

Besides ... even if you can make it work, doesn't that apply the character style to every word? Nested styles cannot count the number of characters per word.
Re: Headline caps change for a newspaper
#182
Author: Peter Kahrel
Date: Tue, 31 Mar 2009 13:44
3 lines
821 bytes
You can use a GREP style: create a character style that sets All Caps, then let the GREP expression \b\l(?=\w\w\w) apply that character style to the first lower-case letter of words of four or more characters long.

Peter
Re: Headline caps change for a newspaper
#183
Author: jongware
Date: Tue, 31 Mar 2009 13:48
4 lines
1325 bytes
I first tried to mess with JavaScript cased changing -- using the built-in string function toUppercase. Then I remembered ID has a user interface function for title case, and wondered if it was the same in JS. And yes, it was -- Uppercase, Title Case, Sentence Case and Lowercase, appliable to Text, Paragraph, Characters (which is what you'd need) ... and Word. So I don't even have to extract individual characters.
There are no built-in fuctions to automatically add a character style to the first character of certain words.

If the requirements ever change -- adding color, or a font or something to the first character --, then you'd have to work around and add stuff 'manually'. I guess that's what you have in mind.
Re: Headline caps change for a newspaper
#180
Author: Robert Tkaczyk
Date: Tue, 31 Mar 2009 19:21
6 lines
981 bytes
sorry :) I mean - why not to apply new ParaStyle with NestedStyle or CharaterStyle (to only first character) - instead of local formatting

robin

-- 
www.adobescripts.com
Re: Headline caps change for a newspaper
#185
Author: Robert Tkaczyk
Date: Tue, 31 Mar 2009 21:47
8 lines
1055 bytes
ok - I misreaded Miguel's post - and your script - NestedStyle will not work :(

but applying CharStyle instead of local formatting ... shouldn't be so bad idea ;)

robin

-- 
www.adobescripts.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads