Skip to main content
Inspiring
June 28, 2021
Answered

Hyperlink shifts when replacing preceding characters

  • June 28, 2021
  • 1 reply
  • 854 views

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 topic has been closed for replies.
Correct answer Peter Kahrel

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.

 

 

1 reply

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
June 28, 2021

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.

 

 

Inspiring
June 29, 2021

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-shifts-when-replacing-preceding-characte

 

Roland

Inspiring
June 29, 2021

Addendum:

My version of the workaround works for single replacements via UI but unfortunately not with changeGrep in the script. 🙁