Copy link to clipboard
Copied
Hello!
If I replace a character in front of a hyperlink with multiple characters using Find/Change, the hyperlink shifts.
Before:
After:
If only one character is replaced, no shift occurs. Tested with InDesign CS6, 2020 and 2021, MacOS.
Does anyone know a workaround for this?
Background:
Special characters are to be encoded in an InDesign document via script, which can then be replaced in the exported ePub.
Roland
This is clearly a bug. Did you report it? (https://indesign.uservoice.com)
There is a workaround though, you need InDesign 16.2.1 or later for that. It uses the fact that you can now insert text at an insertion point without making an actual replacement. It works like this. You need two passes:
Find what: (?=~m)
Change to: <#1#>
The Find what expression is just the lookahead, nothing else. The query says 'insert the tag before em-spaces'. The whole text tag stays out of the hyperlink.
Then d
...Copy link to clipboard
Copied
This is clearly a bug. Did you report it? (https://indesign.uservoice.com)
There is a workaround though, you need InDesign 16.2.1 or later for that. It uses the fact that you can now insert text at an insertion point without making an actual replacement. It works like this. You need two passes:
Find what: (?=~m)
Change to: <#1#>
The Find what expression is just the lookahead, nothing else. The query says 'insert the tag before em-spaces'. The whole text tag stays out of the hyperlink.
Then delete the em-dash in a separate pass.
P.
Copy link to clipboard
Copied
That's a good idea, thanks Peter!
My customer is still using InDesign 2020. But your idea has put me on the right direction. It also works with:
Find what: ~m
Change to: <#1#>$0
And than remove the em-dash in a second pass.
I reported it. Here is the link:
https://indesign.uservoice.com/forums/601180-adobe-indesign-bugs/suggestions/43720893-hyperlink-shif...
Roland
Copy link to clipboard
Copied
Addendum:
My version of the workaround works for single replacements via UI but unfortunately not with changeGrep in the script. 🙁
Copy link to clipboard
Copied
For those stumbling across this solution, it doesn't work in all circumstances. Specifically I'm trying to replace characters inside a hyperlink as opposed to before a hyperlink (so we can retain proper unicode spacing in the epub)
Find: (?:~>)
Replace: START_OF_HEX2009END_OF_HEX
I tried using javascript insertionPoints[0] and it worked!
Test code below:
app.findGrepPreferences.findWhat = "~<";
thinSpaces = app.activeDocument.findGrep();
for (i = thinSpaces.length; i > 0; i--) {
thinSpaces[i-1].insertionPoints[0].contents = "START_OF_HEX2009END_OF_HEX";
}
Peter, as always, thanks SO MUCH for setting me on the right path! (Sorry to any non-scripters who stumble across this)