🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
7 messages
7 total messages Started by federico_platon Sat, 17 Jan 2009 20:00
MapStylesToTags script
#1799
Author: federico_platon
Date: Sat, 17 Jan 2009 20:00
11 lines
1151 bytes
I would like to create automatically XML Tags using the naming of Paragraph (and Character if possible) styles used in an InDesign document.

I have tried a CS2 script from The Real World InDesign CS3 book, but gives an error (in IDCS3 on a Mac the .as, and the .js, also in CS4 in Windows)

I have found a demo example but it creates some tags in a new document named as detailed in the script)

What I need to find is an script that takes the names of my text styles and makes tags with the same names.

I have checked the Adobe Exchage site but have not found it either.

Anyone can point me to somewhere. TIA
Re: MapStylesToTags script
#1800
Author: loic_aigon
Date: Sat, 17 Jan 2009 20:34
6 lines
856 bytes
Hi
Sth like :

var doc = app.activeDocument;
var myPgSt = doc.paragraphStyles.everyItem().getElements();
for(i=2;i<myPgSt.length;i++) { 	doc.xmlTags.add(myPgSt[i].name); } I needed to start the loop to 2 to avoid the two basic styles as No paragraph & basic paragraphs Loic
Re: MapStylesToTags script
#1802
Author: loic_aigon
Date: Sun, 18 Jan 2009 00:01
13 lines
868 bytes
And in case you may want to relaunch the script...

var doc = app.activeDocument;
var myPgSt = doc.paragraphStyles.everyItem().getElements();

for(i=2;i<myPgSt.length;i++) {

	if(doc.xmlTags.item(String(myPgSt[i].name))==null)
	{
		doc.xmlTags.add(String(myPgSt[i].name));
	}

}
Re: MapStylesToTags script
#1804
Author: federico_platon
Date: Sun, 18 Jan 2009 10:07
12 lines
1153 bytes
Loic,

Thank you, thank you very much. Yes it works perfectly, but it requires well formed names, style names cannot start with numbers, include some invalid characters or use spaces.

I would like to be able to start with names of paragraph styles that include an space between two words, and replace it with a low dash.

I think I should add a GREP search/replace, but the code strings I have found use a differnt syntax:

var myRegEx = new RegExp (' ', 'gi') ;
myStyleName = myStyleName.replace(myRegEx, '_');

Could you please adapt it? Again, Thanks in advance
Re: MapStylesToTags script
#1805
Author: Thomas_Bolbro_Nielsen
Date: Sun, 18 Jan 2009 16:13
1 lines
624 bytes
myTagName = myStyleName.replace(" ", "_");
Re: MapStylesToTags script
#1806
Author: loic_aigon
Date: Sun, 18 Jan 2009 19:55
1 lines
739 bytes
And what about changing paragraph styles 's names itselves ? Soon or later, won't you want to map tags to styles ?
Re: MapStylesToTags script
#1807
Author: federico_platon
Date: Sun, 18 Jan 2009 22:01
3 lines
920 bytes
Thanks Thomas I will check it later.

Loic thanks again, you are right. At the end when I prepare the layout for importing an XML data file I may need to map tags to styles and to assign them automatically, by using the same naming, paragraph style names should not include an space or other invalid characters.
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