Forum Replies Created
-
AuthorPosts
-
Peter KahrelParticipantIn the object browser in the ESTK (or any of the other available object-model overviews) select textFrame. The in textFrame’s properties, look through the list — you’ll see fit at some point. Click it to follow through the properties/arguments of ‘fit’ and eventually you come up with something like this (where
myFrame
is a reference to a text frame):
myFrame.fit (FitOptions.FRAME_TO_CONTENT);
I didn’t know you can fit a frame by clicking twice on an anchor, and it doesn’t work for me. Could you elaborate?
Peter
January 18, 2016 at 6:16 pm in reply to: Apply Character Style to all Digits After First Sentence #80907
Peter KahrelParticipantYou’ll have to do it in two steps (that is to say that that’s the only way I can get it to work):
1. Apply the character style to all digits in the paragraph
2. Apply the character style [None] to ^.+?\.If you want to do that in a GREP style, bear in mind that [None] doesn’t have the same effect as applying it normally, outside a GREP style: it does nothing at all. Create a character style Black, set its colour to Black and use it instead of [None].
Peter
Peter KahrelParticipantGREP styles can change form, not substance: they can apply formatting, but can’t change the text itself. You suggested what would seem the most appropriate approach: use a word list to fix case after the change to sentence case. The very rudimentary script below does just that.
To use the script, open the word list that has all words in their correct case (PetSmart, InDesign, NATO, RSPB), each word on a new line. Then open the document that needs to be treated and change its content’s case to sentence case. Make sure that the text and the list are the only two open documents and that the text is the active document. Then run the script.
The script reads the list, then looks in the text for the lower-case instance of each list item, case-insensitive (?i) and whole word only (). Case-insensitive searches are needed because sentence case may have rendered unfindable words at the beginning of sentences, such as Nato and Indesign.
As I said, it’s rudimentary but the basics are there and it can be refined in all kinds of ways.
(function(){ app.findGrepPreferences = app.changeGrepPreferences = null; var list = app.documents[1].pages[0].textFrames[0].parentStory.contents.split('\r'); for (var i = 0; i < list.length; i++) { app.findGrepPreferences.findWhat = '(?i)b' + list[i].toLowerCase() + 'b'; app.changeGrepPreferences.changeTo = list[i]; app.documents[0].changeGrep(); } }());Peter
Peter KahrelParticipantShouldn’t be too hard. Did you ask Marc Autret (https://www.indiscripts.com)? It says in the script file that he rewrote the script, so he should be your first port of call.
Peter
Peter KahrelParticipantShould be fairly simple, though I haven’t seen your document. Prepare your document as follows: on each master page place a text frame for the page number and name it ‘folio’ (without the quotes) on the Layers panel. Then run this script:
(function () { var i, index; var frame; var n = 1; var pages = app.documents[0].pages.everyItem().getElements(); for (i = pages.length-1; i >= 0; i--) { n--; if (pages[i].textFrames.item('folio').isValid) { pages[i].textFrames.item('folio').remove(); } if (pages[i].appliedMaster !== null) { index = pages[i].side === PageSideOptions.LEFT_HAND ? 0 : 1; frame = pages[i].appliedMaster.pages[index].textFrames.item('folio'); if (frame.isValid) { frame = frame.duplicate (pages[i]); frame.contents = String(n); } } } }());When you add and/or delete pages, simply run the script again.
Peter
Peter KahrelParticipantI think the problem is the order in which you apply the GREP styles. Start with the descriptor, applying your style to .+$
Then do the other parts. The effect is that the descriptor style is applied to the whole paragraph, then the dollar sign, disappear, etc. styles override the descriptor at the beginning of the paragraph.Peter
Peter KahrelParticipantDelete the script’s configuration file. See the script’s web page for details.
November 29, 2015 at 9:20 am in reply to: Convert smart (curly) quotes to dumb (straight) quotes in InDesign using JS #79677
Peter KahrelParticipant(Without [code] and [/code], naturally. Forgot the correct format for those.)
November 29, 2015 at 9:19 am in reply to: Convert smart (curly) quotes to dumb (straight) quotes in InDesign using JS #79676
Peter KahrelParticipantYou’re replacing text content, which is dangerous because you may delete index markers, cross-references, etc. etc. And you might make a mess of formatting. It’s safer to let InDesign do the replacements rather than JavaScript. Something like this:
[code]app.documents[0].textPreferences.typographersQuotes = false;
app.findGrepPreferences = app.changeGrepPreferences = null;app.findGrepPreferences.findWhat = ‘(["’])’;
app.changeGrepPreferences.changeTo = ‘$1’;
imgtext.changeGrep();app.documents[0].textPreferences.typographersQuotes = true;[/code]
Peter
Peter KahrelParticipantI’m guessing that each page has four rows of three frames, and that you want to thread the frames in each row, so that you end up with four stories on each page. If the frames were placed left to right and top to bottom, then the threading is simple.
What’s less simple is the option to fit frames to their content. When you do that in the interface, text frames can be fitted only vertically. So how should the frames be fitted? That is, where should the text be after fitting it? Maybe a screenshot of the before and after situations might be an idea.
Peter KahrelParticipantThe string ‘differ’ that you see on screen doesn’t contain any underlying ligature: ‘ff’ is just rendered as a ligature on your screen. You can see that in (at least) two ways: you can place the cursor between the two f’s, and when you select the word, the Info panel reports 6 characters. So I don’t think it’s possible to get the dump you’re after.
Peter KahrelParticipantIn your (?<!.)0(?!.) the dot stands for ‘everything’. Try (?<!\.)0(?!\.) and see what happens. If there are more exclusions, do them as classes, as in (?<![\.,(])0(?![\.,)])
Peter
Peter KahrelParticipantThe two should prevent finding ‘just’ in ‘adjustment’, etc. matches only at word boundaries.
Peter KahrelParticipantMaybe if you take the time to explain yourself in some more detail, someone might decide if a simple script is possible or if you need a complicated one.
1. ‘select 3 text frames’ — which 3 frames?
2. ‘run the join text frame script’ — which script is that?
3. ‘the merge frame fitting button’ (desperately in need of a hyphen here) — which button? What do you mean by ‘merge frame’: threading?
4. ‘then move to the next three frames’ — which next three frames? Where are they?Peter
Peter KahrelParticipantProbably because in InDesign you enter them in the GREP tab of the Find/Change window, and it’s become a habit to referer to regexes as GREPS.
-
AuthorPosts
