Copy link to clipboard
Copied
I am attempting to write the paragraph style name and its class as defined in the styleExportTagMap of all paragraphs in a document. Here is my javascript so far:
var path = '~/00_temp/';
var filename = 'styleMap.txt';
//Create File object
var file = new File(path + filename);
file.encoding = 'UTF-8';
file.open('w');
//gather data and write it to file
var ps = app.documents[0].allParagraphStyles
while(a = ps.pop())
file.write(a.name+'\t'+a.styleExportTagMaps.toSource()+'\n');
file.close();
Here is the line for the paragraph style TEXT_First_ParaDropCap
TEXT_First_ParaDropCap resolve("/document[@id=4]//paragraph-style[@id=291]/style-export-tag-map")
What I desire is Something like this:
TEXT_First_ParaDropCap class: body_dropCap
I will be up front. I am not sure how to manage toSource().
My bad, yes exportClass. You probably got an Object is Invalid error, which you would see if no export tag/class was applied.
Wrap it in a try/catch:
try { file.write(a.name+'\t'+a.styleExportTagMaps[0].exportClass+'\n'); }
catch(e) { file.write(a.name + "\tNo export tag applied!"; }
Copy link to clipboard
Copied
Assuming each style has only one tag map:
file.write(a.name+'\t'+a.styleExportTagMaps[0].class+'\n');
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I tried replacing .class with .exportClass and receive the same error.
file.write(a.name+'\t'+a.styleExportTagMaps[0].exportClass+'\n');
Copy link to clipboard
Copied
My bad, yes exportClass. You probably got an Object is Invalid error, which you would see if no export tag/class was applied.
Wrap it in a try/catch:
try { file.write(a.name+'\t'+a.styleExportTagMaps[0].exportClass+'\n'); }
catch(e) { file.write(a.name + "\tNo export tag applied!"; }
Copy link to clipboard
Copied
Thanks. That worked. You missed the closing parenthesis in the catch(e). Otherwise. Perfect! Thanks again.
{ file.write(a.name + "\tNo export tag applied!"); }