Forum Replies Created
-
AuthorPosts
-
Peter KahrelParticipantSorry, Bob, I should have looked better. I think the problem is that you use \u in JavaScript GREP — it doesn’t exist. Instead, use [A-Z] to test for capital letter, e.g.
if (/_\d\d[A-Z](?=\.tif$)/.test (f[i].name))
P.
Peter KahrelParticipantMaybe you should give some examples of what you want to do. Your find and replace string don’t make a lot of sense: you search for \.tif and replace that with \dd\u\.tif — which means that a string like screen.tif is replaced with screen\dd\u\.tif
Peter KahrelParticipantIt’s possible to do that but it’s a bit flakey. You can place a small frame with text wrap at the bottom right of a frame if a footnote continues on the next page, and a similar small frame at the top left of the first line of a footnote continuation. Naturally, placing those frames may cause reflow and when there are changes in the text, notes are bound to reflow. You could ask someone to do a script for you that places (and re-places) those frames in a text. That’s about the best you can do I think.
Peter
Peter KahrelParticipantTry this one:
(function () {
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '[S]+?(?=@)';
var found = app.documents[0].findGrep();
for (var i = found.length-1; i >= 0; i--) {
found[i].changecase (ChangecaseMode.LOWERCASE);
}
}());Peter
July 30, 2017 at 7:55 am in reply to: Replace tabs on the same selected line to A) B) C) D) E) #96426
Peter KahrelParticipantTo remove anchored objects, look for ~a and replace with nothing.
Peter KahrelParticipantYelena — Unlike Microsoft Word, InDesign doesn’t do tables of authority and other tables. Those tables are in fact indexes. The problem in InDesign is further that you can do just one index per document/book. The standard way to get around that is by coding your topics in such a way that you in effect create several index in the general index. It works as follows: mark up the subject index as usual. Table of statute items you can prefix with e.g. ##, tables of cases items, with e.g. @@. Then when you generate the index you get something like
##item (table of statutes)
##item
@@item (table of cases)
@@item
item (subject index)
itemThen all you need to do is to move the ##items and @@items to where they should appear, and remove ## and @@.
Peter
Peter KahrelParticipantScott — How is that for multi-tasking, with two approaches assailing you?
Sorry, the second line in the script should be
app.findGrepPreferences.findWhat = ‘[$d,]+.ddKd+’;
(and if you copy this line. mind the quotes).
P.
Peter KahrelParticipant
Peter KahrelParticipantNo dictionary has all the words you’re after. Word divisions are more problematic because of the different traditions. But in my experience, when you start adding words and divisions, you soon have a pretty good dictionary. It doesn’t take all that long to train one or more dictionaries.
Peter KahrelParticipantSomething went wrong earlier, a whole line of code disappeared (and what is a leekahead, one wonders). This is what it should have been:
To find Greek immediately following some Latin character, place Latin in a lookbehind:
[\x{0000}-\x{00FF}\x{0100}-\x{024F}\x{1E00}–\x{1EFF}]\K[\x{1F00}-\x{1FFF}\x{0370}-\x{03FF}]+
And/or to find Greek immediately followed by a Latin character, place the Latin in a lookahead:
[\x{1F00}-\x{1FFF}\x{0370}-\x{03FF}]+(?=[\x{0000}-\x{00FF}\x{0100}-\x{024F}\x{1E00}–\x{1EFF}])
> This means that it will also find all the instances of space between two Greek words?
It does and it doesn’t. It would now match spaces between Greek words, but it doesn’t match Greek words separated by spaces (or punctuation, for that matter). So those grep expressions need some tweaking.
Peter KahrelParticipant> or should I leave one of the scripts set to 3 decimal places and use the GREP find/change to remove the 3rd number.
That’s the only way to go about it as far as i can see.
> I can do that, and I’ve tested it and it works so far, but it’s still another step (albeit faster than doing the pricing by hand).
It’s only a small step. You can save the GREP query (in the Find/Change window) for future use, or you can put it in a separate script:
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences = ‘[$d,]+.ddKd+’;
app.documents[0].changeGrep();There are many ways in which numbers can be finished. I’ve had requests for rounding everything up, rounding everything down, rounding up or down to the next 5 cents, not rounding. And your requirement is a bit different again. It’s not really possible to build all that into the script. Almost all these things can be handled by either a GREP query or a simple script.
P.
Peter KahrelParticipantScott,
To subtract a percentage, multiply the number by 100 minus the percentage. So to subtract 25% off prices, multiply by 0.75. I can’t remember if NumberAdjuster lets you set the number of decimals — if it can, use that. If it can’t, use this script:
https://www.kahrel.plus.com/indesign/price_adjuster.html
(which is a merge of NumberAdjuster and Olav Kvern’s PriceUpdateByString script). Indicate that you want two decimals. If that doesn’t give you the desired rounding (can’t remember now what the script does), then run it and use three or even four decimals.To get rid of the third and maybe the forth decimal, use this GREP query:
Find what: [$\d,]+\.\d\d\K\d+
Change toThis query says ‘match any digits that are preceded by a dollar symbol followed by any digits and commas followed by a dot and two digits and delete them’. So it chops the third and any following digits off your prices.
Peter
Peter KahrelParticipantJoel,
Basic Latin, Latin-1 supplement, Latin Extended-A, Latin-Extended-B, and Latin Extended Additional are captured by this expression:
[\x{0000}-\x{00FF}\x{0100}-\x{024F}\x{1E00}–\x{1EFF}]
To find Greek immediately following some Latin character, place Latin in a lookbehind:
And/or to find Greek immediately followed by a Latin character, place the Latin in a leekahead:
[\x{1F00}-\x{1FFF}\x{0370}-\x{03FF}]+(?=[\x{0000}-\x{00FF}\x{0100}-\x{024F}\x{1E00}–\x{1EFF}])
You’ll need two passes if you want Greek followed or preceded by Latin. And you may have to add some punctuation to the Latin ranges. Note that I changed you Greek matcher a bit to make it more efficient (you’ll need efficiency when you’re looking in 720,000 words!
Peter
Peter KahrelParticipantI know the problem. But you can’t activate any page in InDesign Server. In a desktop installation you’d do
app.windows[0].activePage = app.activeDocument.pages[0];
For you, on ID Server, all you can do is to make sure that before your template is uploaded to the server, it’s saved with a document page active.
Peter KahrelParticipant> Have now added your old script, IndexFmCharStyle.js
That’s not my script, it’s Martin Fischer’s. The two scripts do more or less the same, though by the looks of it, Martin’s script doesn’t do subtopics. Use only one of the scripts. If you want to do subtopics (genera/species), reflecting style groups, you’re stuck with mine.
To update an index, do the same as generating one, but click ‘Replace existing index’ in InDesign’s ‘Generate Index’ dialog.
As to formatting, you can format page numbers (e.g. to indicate principal references); see the article linked above. The entries themselves you can’t format directly. For instance, to apply italic to certain topic names you’ll have to use a rounabout way. There is a good workaround using GREP styles, see e.g. https://creativepro.com/formatting-in-indesign-index-entries.php
-
AuthorPosts
