Forum Replies Created
-
AuthorPosts
-
Peter KahrelParticipantYes, sure, you could use the GREP query to apply a paragraph style, but I would find it easier to use one paragraph style and the GREP is simple. But if you prefer you can look for
^[^~F], leave the Change To field empty, Find Format ‘footnote 1’, Change Format ‘footnote 2’. Be aware though that when you do that, you lose all local formatting.
Peter KahrelParticipantThe expression says ‘at the beginning of a paragraph (
^), match and capture a character that not (^) a footnote marker (~F). Then replace that character with a tab () and itself ($1). The caret^means ‘not the following chracter(s)’ when it is used inside a character class ([ ]), and ‘beginning of paragraph’ when used outside a class and at the beginning of the expression. Character by character:^start of paragraph
(begin capture
[begin character class
^~Fnot (^) footnote marker (~F)
]end character class
]end capture
Peter KahrelParticipantAri,
I don’t think that you can do this entirely automatically. I would do this: set up the footnote style with left indent and negative first-line indent. This will cause the second and following paragraphs to be set with negative first-line indent too. Then at some stage run this Find/Change:
Find what:
^([^~F])
Change to:$1
Find Format: <the note paragraph style>
And include the footnotes in the searchSave it as a GREP query. If you run that query frequently, you can assign it to a keyboard shortcut as follows. If you saved the query as
footnote indent, save this one-line script in your script folder:app.loadFindChangeQuery ('footnote indent', SearchModes.grepSearch); app.activeDocument.changeGrep();Then in the Keyboard Shortcuts window, apply a shortcut to that script. Peter
March 18, 2016 at 10:50 am in reply to: Part 2: Calculation of Paragraph length(s) in a document #83071
Peter KahrelParticipantI did that, Ahmad. It didn’r work. But we sorted it out outside the forum.
P.
Peter KahrelParticipantThat little script works fine on a sample I put together. Your document may have some structure that I’m not aware of, but what the script has to do is simple so I had expected it to work. I also don’t understand the error message, I can’t reproduce it.
If the numbers aren’t always plain digits, and if brackets are used for footnote references only, you could try replacing line 2 with this one:
app.findGrepPreferences.findWhat = '[.+?]';
As to all the backslashes, to use a basckslash as a literal you have escape it, as the saying goes. Thus, in InDesign’s Find/Change window you’d use
\[.+?\], but when you define a string with that GREP, you have to use ‘[.+?]‘. If you don’t, and use'\[.+?\]', then \[ and \] will be interpreted as special characters, not as the string \[. Compare that with e.g. $: it has a special meaning in GREP (‘end of string’) and in order to use it literally, as a currency symbol, you have to escape it and use \$.Peter
Peter KahrelParticipantHere is a script that places empty footnotes at the fake footnote references and removes the references:
app.findGrepPreferences = null; app.findGrepPreferences.findWhat = '[d+]'; found = app.activeDocument.findGrep(); for (i = found.length-1; i >= 0; i--) { found[i].insertionPoints[0].footnotes.add(); found[i].remove(); }What’s left to do is move the fake footnote texts to the real footnote frames at the foot of each frame.
Peter
March 17, 2016 at 10:57 am in reply to: Part 2: Calculation of Paragraph length(s) in a document #83035
Peter KahrelParticipantStill doesn’t work. Maybe there’s something in that script I include that throws off the forum software. Why don’t you give me your email address and I’ll send it straight to you. We’ve been spending enough time on this by now.
Peter
Peter KahrelParticipantStill no luck. Now there’s a message saying “ERROR: Duplicate reply detected; it looks as though you’ve already said that!”
Not sure what’s going on. Maybe David Blatner can fix this.
Peter KahrelParticipantThat one line worked, but a longer reply doesn’t.
This thread clearly doesn’t like me any longer!
Peter KahrelParticipantI’m trying to answer to this one but the reply doesn’t appear. . .
Peter KahrelParticipantYou can’t do that with Find/Change: because the footnotes don’t exist as InDesign footnotes, you’ll have to create them. Manually, you’s go to the text of footnote 1, cut it, go to the reference [1], delete that, and add a footnote, pasting the text you cut earlier. All that could be scripted, but it’s not trivial.
Peter
Peter KahrelParticipantMaybe existing style utilities can determine paragraph length globally. As far as I can see, InTools’s style utility doesn’t, but a basic version is not difficult to script. The example below creates a text file Paragraph_count.txt on your desktop with the name of each document followed by a list of stories, each with a list of paragraph index and word count. The file is opened after script finishes.
I said ‘basic’ because, well, it’s basic. It doesn’t do footnotes or tables, it includes stories on master pages, and you get just a raw count. And that’s the reason why general utilities tend not to include what you want: there are endless ways to customise the presentation of the data, so the script you’re after will typically be a custom job.
(function () { var i, j; var report; var stories, par; var f; report = []; for (i = 0; i < app.documents.length; i++) { report.push (app.documents[i].name); stories = app.documents[i].stories.everyItem().getElements(); for (j = 0; j < stories.length; j++) { report.push ('Story ' + stories[j].id); par = stories[j].paragraphs.everyItem().getElements(); for (k = 0; k < par.length; k++) { report.push ('Par. ' + k + ':' + par[k].words.length); } } } f = File ('~/Desktop/Paragraph_count.txt'); f.encoding = 'UTF-8'; f.open('w'); f.write(report.join('\r')); f.close(); f.execute(); }());
Peter KahrelParticipantHow is it supposed to look? One language after the other, e.g. first Hebrew (pp. 1-100), then English (pp. 101-200) (or the other way around)? Or is it a parallel text, with English on the left-hand pages and Hebrew on the right-hand pages?
Peter KahrelParticipantSetting up paragraph styles for English and Hebrew is the easy part. The problem in any set-up is the binding: Hebrew starts on a left-hand page, English on a right-hand page. How are you going to deal with that?
Peter KahrelParticipantPaul,
> but for some reason either one works in my document?
I guess you meant ‘neither’ :)
Before sending any files, could you tell me what goes wrong? When you enter the GREP expression in the Find What field of the GREP tab (you are using the GREP tab aren’t you?) and click the Find button, what happens?
1. InDesign shows an alert saying ‘Cannot find match’.
2. InDesign finds something, and highlights it, but it’s not what you expected or intended.Please be clearer about ‘It doesn’t work’.
Peter
-
AuthorPosts
