Thread View: adobe.scripting.indesign
4 messages
4 total messages
Started by Siegfried_Kauschat
Fri, 30 Jan 2009 09:23
text replace and SpecialCharacters
Author: Siegfried_Kauschat
Date: Fri, 30 Jan 2009 09:23
Date: Fri, 30 Jan 2009 09:23
12 lines
1218 bytes
1218 bytes
Hi, I'm using xml-rules to place xml-content into my document. My problem is to replace paragraph breaks in an element by forced line breaks. I tried:
with (element) { app.findGrepPreferences = app.changeGrepPreferences =
null; app.findGrepPreferences.findWhat = "\r"; app.changeGrepPreferences.changeTo
= SpecialCharacters.FORCED_LINE_BREAK; changeGrep(false); }
Error: changeTo expects a String or NothingEnum but SpecialCharacters.FORCED_LINE_BREAK seems to be a number. Does anyone know a workaround?
Btw: insertTextAsContent(SpecialCharacters.FORCED_LINE_BREAK, XMLElementPosition.beforeElement) works fine - but it's not what I want.
Re: text replace and SpecialCharacters
Author: jongware
Date: Fri, 30 Jan 2009 10:29
Date: Fri, 30 Jan 2009 10:29
3 lines
1067 bytes
1067 bytes
findWhat and changeTo expect the same syntax as in the UI, that is, regular text strings with special characters escaping and wildcarding the same way. A Forced Line Break in regular Find (findTextPreferences) is "^n" and in GREP mode "\n" (findGrepPreferences). Take notice of proper backslash escaping; because you are programming in JavaScript, the backslash (as GREP Escape character) needs to be escaped (as JavaScript Escape character). You missed that one in your '\r' sample.
Re: text replace and SpecialCharacters
Author: Siegfried_Kauschat
Date: Fri, 30 Jan 2009 12:29
Date: Fri, 30 Jan 2009 12:29
11 lines
967 bytes
967 bytes
Take notice of proper backslash escaping
That's it, thank you!
JS-"\r" works accidentally because Indesign treats this JS-generated line break the same way than the escape sequence backslash-r (written "\\r" in JS).
But "\n" has a different effect than "\\n" so your hint made my day.
Re: text replace and SpecialCharacters
Author: Olav_Kvern
Date: Fri, 30 Jan 2009 19:28
Date: Fri, 30 Jan 2009 19:28
15 lines
1420 bytes
1420 bytes
Hi Siegfried, re: app.changeGrepPreferences.changeTo = SpecialCharacters.FORCED_LINE_BREAK; ...won't work, because you don't enter a forced line break in the Find What field of the Find/Change panel. Instead, you enter a metacharacter--so you also use a metacharacter when you perform the task from scripting. This is what jongware's saying (thanks jongware!), but I thought I'd expand on it a bit. In short: Don't use special characters enumerations in Find/Change. Sometimes, it'll work (when the characters are visible, non-control characters), sometimes it won't. Other than the need to enter escape characters (to produce valid JavaScript strings), The Find What and Change To properties of all of the find/change preferences objects exactly mimic the corresponding fields in the Find/Change panel. Thanks, Ole
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads