Forum Replies Created
-
AuthorPosts
-
Kai Rübsamen
MemberLookarounds find positions, not text. Therefore it is possible to find something, but not to include it.
Assume you are the ‘space’ ;-) and you are sitting on a time ray. If you want to find something left from you (in the past), you will have a look to your left (lookbehind). If you want to find something in the future, you will have a look to your right (lookahead).
The code that you provide, is the shortcut for a lookbehind. So it will find a space, if it is preceded by a number.
But what you need is a lookahead:
\x20(?=\d)
Kai
Kai Rübsamen
MemberWait, there is even more ;-)
I really like those tasks, since a simple script could combine everything together. The script will not check, if your para styles are valid. It assumes, that the cursor is blinking in your story.
if (app.documents.length == 0 || app.selection.length != 1 || /InsertionPoint/.test(app.selection[0].constructor.name) == false) { alert ('Click in your story!'); exit(); } var curStory = app.selection[0].parentStory; curStory.paragraphs.everyItem().appliedParagraphStyle = "Day entries"; var changeList = [ [ "^d{1,2}u", NothingEnum.NOTHING, "Date Headings" ], [ "(?s).(?!.)", "Day entries", "Day entries LAST" ] ]; app.findGrepPreferences = app.changeGrepPreferences = null; for ( var j = 0; j < changeList.length; j++ ) { var curSearch = changeList[j]; app.findGrepPreferences.findWhat = curSearch[0]; app.findGrepPreferences.appliedParagraphStyle = curSearch[1]; app.changeGrepPreferences.appliedParagraphStyle = curSearch[2]; curStory.changeGrep(); } app.findGrepPreferences = app.changeGrepPreferences = null;One last comment: You should avoid ‘indent to here’ for all your entries (sometimes multiple?), since you can easily do it with a positive and negative indent.
Kai
Kai Rübsamen
MemberAris Skript assumes, that you apply ‘Day entries’ and ‘Date headings’ by hand. I’ve no idea, why he collect first insertionPoints and did it this way …
What I did manually:
1. This is clear.2. Find the beginning of a paragraph, followed by a number, that consists of 2 digits, followed by a uppercase letter. This will find 22 Monday’, but also ’99Chicken wings’. Since I didn’t find those chicken wings-problems in your document, I decide to do it the easy way. Otherwise the search must be more specific.
3. (?s) choose the so called ‘Single line mode’ and affected the scope of the wildcard ‘.’ So in this special case, it finds a character with applied style ‘Day entries’, if the next character has not this style applied. So it finds the last line and give us the chance to apply another style.
To your last question:
Sure, this could be done by F/C or could be part of a grepstyle: (?i)week\x20\d+$
Will find caseless week(WEEK), followed by an space, followed by any number at the end of a paragraph.best
KaiAugust 5, 2016 at 4:47 am in reply to: GREP to find any sentence with a list sep by commas & missing comma before "and" #87090Kai Rübsamen
MemberFirst of all, I can recommend the “Highlight GREP-Skript” from Roland Dreger: https://www.rolanddreger.net/de/249/highlight-grep-in-indesign/#
Here you can see all founds in your document, without moving step by step.To find only the word before comma …
\w+(?=,.+(and|or).+?[.?])To find the whole sentence:
\w+,.+(and|or).+?[.?]best
KaiKai Rübsamen
MemberAha! :) If you are able to read scripts, it is sometimes very easy to make minor changes, e.g. put your text after the para style name …
Kai Rübsamen
MemberTry it by yourself! Since this is a easy script, it should not be so difficult to change paragraph to character ;-)
Kai Rübsamen
MemberHi Cindy,
yes this is possible:
var allParaStyles = app.activeDocument.allParagraphStyles; var before = "2016_"; for (var i = 2; i < allParaStyles.length; i++) { var curStyle = allParaStyles[i]; var curName = curStyle.name; if (curName.indexOf(before) == -1) { var newName = before + curName; curStyle.name = newName; } }Kai
Kai Rübsamen
MemberA bit dirty, but why not insert a right indent tab after the headline and give this tab a white thick underline with offset. The underline can be applied with a grep style.
Advantage:
– the numbered list must not be converted to text
– the stroke above adapts dynamicallyDisadvantage:
– you must insert a right indent tab
– it works only, if you print on white paperKai Rübsamen
MemberTry this one and try to avoid all those try/catch things :)
var sel = app.selection[0]; // check your selection if (sel != undefined) { var textHeaderTf = sel; } // the parent story var parStory = textHeaderTf.parentStory; // insert text at the end (realize, that there is no space before the new word) parStory.insertionPoints[-1].contents = 'myNewText'; // a fill and a stroke color var props = { fillColor: app.activeDocument.swatches[4], strokeColor: app.activeDocument.swatches[5] } // give the first word in the story a fill and a stroke color var firstWord = parStory.words[0]; // since you insert something above, therre is always a word firstWord.properties = props; // give the frame a fill and a stroke color textHeaderTf.properties = props;Kai Rübsamen
MemberAri, the new version doesn’t step up and down the omv anymore :), but it does nothing in the test doc. So it would be helpful, if the op give an information, if it works for him.
To do it manually:
1. Select the text and apply ‘day entries’ to everything
2. Find what: ^\d{1,2}\u , Change to: nothing + applied style ‘Date headings’
3. Find what: (?s).(?!.) + applied style ‘Day entries’ , Change to: nothing + applied style ‘Day entries Last’Kai
Kai Rübsamen
MemberAri, your script doesn’t work with his testfile, even if I remove the textflow on the page, I get several errors?
Kai Rübsamen
MemberI would assume, that you could automate everything here, so please provide a example (as screenshot with show invisibles turned on or better as idml > before after)
best
KaiKai Rübsamen
Member“Doesn’t work” isn’t a detailed description of a problem ;-)
First, there a more examples needed, that one line
Second, did you read the comments in Davids post?It is surely not a problem to bring 3-13 to the front. The sorting order would then be 3 and so on.
best
KaiKai Rübsamen
MemberHm, the problem is, what controls the different informations on the page, since masterpages would display only static content or content from a textvariable.
So how to collect things and display them in dependance of even and odd pages?
To give a good answer a example document before / after is needed. First I would look, what is possible with InDesign, then I would think about a script, that put things together.So, please provide a example for all or sent me a testfile with some comments to infoATruebiarts.de
Kai Rübsamen
MemberHi,
why not use different masterpages for right and left?
Otherwise it is not possible to distinguish between even and odd pages, but a script can do this.
Kai
-
AuthorPosts
