Copy link to clipboard
Copied
Hi,
While replacing the close quotes with GREP to one-by-one, its working fine. But useing replace all, the issue happen occuring, the same in coding also (Para breaking). Is this CC2020 bug or any connection with the endnote?
app.selection = NothingEnum.NOTHING;
app.findGrepPreferences = app.changeGrepPreferences = null; app.findChangeGrepOptions.includeFootnotes = true;
app.findChangeGrepOptions.includeHiddenLayers = false; app.findChangeGrepOptions.includeLockedLayersForFind = true; app.findChangeGrepOptions.includeLockedStoriesForFind = true; app.findChangeGrepOptions.includeMasterPages = false;
app.findGrepPreferences.findWhat = "(\\[LSQ\\].+?)~]";
app.changeGrepPreferences.changeTo="$1[RSQ]";
myFoundItems =app.documents.item(0).changeGrep();
Kindly guide and share if any alternate. Recorded file is attached for your reference.
Thanks,
Selva
Your Grep syntax is correct and works for me even if I prefer:
app.findGrepPreferences.findWhat = "\\[LSQ\\].+?\\K~]";
app.changeGrepPreferences.changeTo = "[RSQ]";
(^/) The Jedi
Copy link to clipboard
Copied
What exactly do you mean with 'goes wrong near endnote reference'? Where is the endnote reference and what goes wrong with it?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The problem is that . (the dot) doesn't match the endnote marker. It should not-match only the paragraph mark. That's an InDesign bug that's been around since CS3 and causes a lot of trouble.
But even if it worked, you can't match some text with an endnote (or a footnote, for that matter, same behaviour), and use it in a variable for a replacement: you just lose the note.
Instead, use this query:
Find what: "\\[LSQ\\][^~]]+\\K~]"
Change to: "[RSQ]"
The [^x] notation means 'not x' and can always be used as an alternative for .+?x
As a bonus, it's more efficient!
P.
Copy link to clipboard
Copied
"The problem is that . (the dot) doesn't match the endnote marker."
Peter, no problem with end notes!
(^/)
Copy link to clipboard
Copied
Crikey, you're right! What do I know about notes, anyway?
Doesn't matter much in this case, but thanks for pointing that out.
P.
Copy link to clipboard
Copied
As Footnotes can be converted to Endnotes (and Endnotes to Footnotes), it could be simple, if the user has both, to apply a "label" to the right endnotes, convert all to endnotes, play the regex and finally convert the "not-right" endnotes to footnotes! … By Script of course! 😉
(^/)
Copy link to clipboard
Copied
That's flirting with disaster. Endnotes are flakey. Better work around the footnote problem:
^.+~F?.*
matches paragraphs with any footnotes.
Copy link to clipboard
Copied
Right! 😉
So:
app.findGrepPreferences.findWhat = "\\[LSQ\\].*~F?.*\\K~]";
app.changeGrepPreferences.changeTo = "[RSQ]";
(^/)
Copy link to clipboard
Copied
Yes, but I'd still use [^~]]+ instead of .*~F?.* because it's more efficient and less messy.
Copy link to clipboard
Copied
Peter,
That doesn't work if there's a foonote in the para!
(^/)
Copy link to clipboard
Copied
Ugh! Back to .*~F.*
Copy link to clipboard
Copied
Hi Peter,
Thanks for the suggestion. Yes, most of the grep replacements are not good results. Kindly give the advice to avoid this kind of issue globally.
app.selection = NothingEnum.NOTHING;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findChangeGrepOptions.includeFootnotes = true;
app.findChangeGrepOptions.includeHiddenLayers = false; app.findChangeGrepOptions.includeLockedLayersForFind = true; app.findChangeGrepOptions.includeLockedStoriesForFind = true; app.findChangeGrepOptions.includeMasterPages = false;
app.findGrepPreferences.findWhat = "["']";
app.changeGrepPreferences.changeTo="[Q1C]";
myFoundItems =app.documents.item(0).changeGrep();
Before replacement:
After replacement:
Thanks,
Selva
Copy link to clipboard
Copied
This is a different problem, please start a new discussion in future.
If you search "["']", how do you find the closing quote and the endnote closing code? If what you show in your screenshot is the result of several queries you should list them all.
Copy link to clipboard
Copied
Hi Peter,
Acknowledged, I'll follow this.
I'm trying to replace the tag instead of the quote, but the partial tag is misplaced in the next paragraph.
Thanks,
Selva
Copy link to clipboard
Copied
Ah, well, that's an InDesign bug: when you look for ["'] you match the the tag. Not much that you can do about it, other than collecting them all, then processing all found items and replace the first (possible only) character in an item with your text tag.
Copy link to clipboard
Copied
Your Grep syntax is correct and works for me even if I prefer:
app.findGrepPreferences.findWhat = "\\[LSQ\\].+?\\K~]";
app.changeGrepPreferences.changeTo = "[RSQ]";
(^/) The Jedi
Copy link to clipboard
Copied
Hi Jedi,
Thanks for this, I'll check and get back you shortly.
Thanks,
Selva