Forum Replies Created
-
AuthorPosts
-
Zalman Friedman
MemberHi, i have a similar question, where the above would not work: I would like to apply a second paragraph style to the second paragraph of the footnotes.
I am working off an imported word doc that has no styles applied. So i found the majority of the footnotes using GREP: (?<=~F)ts(.+) and applied the footnote paragraph style (and also replace the tab with period, hence the extra code in the grep).
But there are some footnotes that have a second paragraph where i would like to use a first line indented paragraph style, but i cant figure out how to select that paragraph by itself – being that there is no unique characters here to look for.
I tried using this “(?<=~F.+\r).+” (thinking i can select any paragraph following a paragraph with a footnote reference, but it doesn’t seem to work.
Any advice? Thanks!
Zalman Friedman
MemberOk, so i had my web programmer create this script for me, though he has no experience with inDesign scripting!
The script looks for the X position of the word proceeding the text anchor and updates the anchored object offset to center it above the word.
If anyone has any suggestions on simplifying the script or making it run faster, please let me know.
Here is the script:
main();
function main(){
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if(app.documents.length != 0){
if(app.selection.length != 0){
//Get the first item in the selection.
var mySelection = app.selection[0];
//Process the selection. If text or a text frame is
//selected, do something; otherwise, do nothing.
switch(mySelection.constructor.name){
case “Text”:
case “InsertionPoint”:
case “Character”:
case “Word”:
case “Line”:
case “TextStyleRange”:
case “Paragraph”:
case “TextColumn”:
case “TextFrame”:
var story = mySelection.parentStory;
processStory(story);
break;
default:
alert(“Please select some text or a text frame and try again.”);
}
}
else{
alert(“Please select some text or a text frame and try again.”);
}
}
else{
alert(“Please open a document and try again.”);
}
return ‘done’;
}function processStory(story) {
story.recompose()
for (var iLine = 0; iLine < story.lines.length; iLine++) {
//if (iLine > 0) break;
var sLine = story.lines[iLine];
//alert(sLine.characters.length);
sLine.showText();
processLine(sLine);
//$.writeln(sLine.characters.length);
}
}function processLine(sLine) {
var iStart = 0, iEnd = 0, bGetStart = true, lEndOffset = 0;
var reIgnore = new RegExp(‘[ ,\.: ]’);
for (var iChar = 0; iChar < sLine.characters.length; iChar++) {
//if (iChar > 10) { break; }
var c = sLine.characters[iChar];
if (reIgnore.test(c.contents)) {
if (bGetStart) {
//do nothing, just ignore character
} else {
// add to offset
lEndOffset-= (c.endHorizontalOffset – c.horizontalOffset); //using – because we are going right to left and the endHorizontalOffset is less than the horizontalOffset
}
} else {
if (bGetStart) {
iStart = c.horizontalOffset;
bGetStart = false;
}
//$.writeln(c.endHorizontalOffset);
// $.writeln(iChar + ‘: ‘ + c.contents);
if (c.pageItems.length>0) {
var pi = c.pageItems[0];
if (pi.hasOwnProperty(‘anchoredObjectSettings’)) { //found anchor character
pi.anchoredObjectSettings.anchorXoffset = lEndOffset + ((iStart-iEnd)/2)
bGetStart = true;
lEndOffset = 0;
}
} else {
iEnd = c.endHorizontalOffset;
lEndOffset = 0; //reset offset if we find a regular character after an ignore character before the next anchor
}
}
}
} -
AuthorPosts
