1 Reply Latest reply on Sep 19, 2008 2:28 AM by Peter Kahrel

    Removing surrounding brackets from selected text (Java Script or AppleScript)

    Level 1
      Someone on this list kindly provided a JS (below) which would place brackets or anything else around selected text.

      I use braces for provisional text in the editing process,for example [renewable energy], and if the text is made final then the braces are removed.

      Not all braces are removed in the same version so it is really difficult to do a find/replace. Also for some reason, when a word is double-clicked for selection, InDesign won't select the surrounding brackets (but it does select $ or £ signs) and it is really fiddly selecting a narrow little [ and then the ].

      The JS I have to place braces is as follows:

      var myObject = (app.selection[0].parent.constructor.name == "Cell") ? app.selection[0].parent.texts[0] : app.selection[0];

      with (myObject)
      insertionPoints[-1].contents = "]";
      insertionPoints[0].contents = "[";

      Can this be changed to deletion rather than insertion? Yes, I have tried changing it to deletionPoints, but this does not work.

      I am afraid I know very little about Java Script.

      Thx for any help.