2 Replies Latest reply on May 29, 2012 2:06 PM by ukzembla

    Hyperlink Destination Characters




      I'm looking for a way to eliminate hyperlink destination characters (the blue colons) either with Javascript or via grep. The weird thing is that with the following grep:


      …if you select the character on its own and search the selection, it says it's not found (as you'd hope). But if you search a paragraph using that grep, it skips over and includes it (even for a replace). This has to be a bug. So I could loop through each character invoking an InDesign-style find on that selection, but that's a bit of a pain and would be super slow.


      ID's Javascript doesn't include POSIX support, so that's no good, and when I copy-paste the character in question into ID, it gives me


      which seems like it ought to work but is never found. This also seems like a probable bug.


      Any ideas, anyone? Alternatively, the problem I'm trying to solve is: I have a chapter heading (say) with a hyperlink text destination (usually) at the start of it. I duplicate this using JS, and the text destination is also duplicated, and I want to kill it in the duplicated, but not the original version. Hope that makes sense - it's for a table of contents.





        • 1. Re: Hyperlink Destination Characters
          [Jongware] Most Valuable Participant

          Rather than battling with the character placeholders -- a battle you will surely loose, as it's not possible to copy them and still keep their functionality --, you should look into manipulating the hyperlink destinations themselves.


          It's tricky stuff nevertheless. Look in the Object Model for clues: http://jongware.mit.edu/idcs5.5js_html/idcs5.5js/index_Hyperlinks%20Suite.html could be a good start.

          • 2. Re: Hyperlink Destination Characters
            ukzembla Level 1

            Thanks for the response. In a perfect world, I wouldn't copy them at all: I want to duplicate the text of a paragraph minus the text anchor but can't find a way of doing it. At least when it's duplicated, it becomes a new anchor rather than some weird copied-by-reference thing.


            Either way, I need to exclude them from duplication (in which case how can I find them to ignore them) or remove them afterwards (ditto). The only reliable way seems to be tediously going through the indexed position of the character in question against all the destinations, which is a bit of a drag. Something like (for one char - untested!)


            // with one anchor selected

            var char = app.selection[0];

            var dests = app.activeDocument.hyperlinkTextDestinations;

            for (var i = 0 ; i < dests.length ; i++) {

               if ((dests[i].destinationText.index == char.index) && (dests[i].destinationText.parent == char.parent)) {

               // delete char