• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Hyperlink shifts when replacing preceding characters

Contributor ,
Jun 28, 2021 Jun 28, 2021

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:

before_replacement.png

After:

after_replacement.png

 

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

TOPICS
Bug , Scripting

Views

558

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 28, 2021 Jun 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 d

...

Votes

Translate

Translate
Community Expert ,
Jun 28, 2021 Jun 28, 2021

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.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 29, 2021 Jun 29, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 29, 2021 Jun 29, 2021

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. 🙁

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

LATEST

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)

Screen Shot 2021-07-27 at 9.00.06 PM.png

Find: (?:~>)

Replace: START_OF_HEX2009END_OF_HEX

Screen Shot 2021-07-27 at 9.00.21 PM.png

 

I tried using javascript insertionPoints[0] and it worked!

Screen Shot 2021-07-27 at 9.21.23 PM.png

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines