Hi, one never really escapes the escape tunnel. I have a new problem with escapes.
From the command line I can ask
TextMate to insert a backslash:
osascript -s 'tell app "TextMate" to insert ""'
I want to do the same from a javascript contained in an a href link. But I can not find the correct way to escape things. Allan's suggestion works perfectly with ordinary text; the following html code:
<a href="javascript:TextMate.system("/usr/bin/osascript &> /dev/null -e 'tell app \"TextMate\" to insert \"TEXTTOINSERT\"' &", null);"> TEXTOFLINK</a><br>
produces a link TEXTOFLINK and when I click on it, TEXTTOINSERT is inserted into TextMate. But if TEXTTOINSERT contains a backslash, it is ignored. A pity since I want to insert a tex command... What should I write instead of TEXTTOINSERT to get, say, "\eqref" to be inserted? Yes, I am escape-blind. Thanks for any help,
Piero
PS hm... no one seems to like my new idea for label completion. I'll keep it for personal use :)
On 26/9/2006, at 11:27, Piero D'Ancona wrote:
[...] osascript -s 'tell app "TextMate" to insert ""'
I want to do the same from a javascript contained in an a href link. But I can not find the correct way to escape things [...]
Use \ for one backslash in JavaScript strings.
Allan Odgaard <throw-away-1@...> writes:
On 26/9/2006, at 11:27, Piero D'Ancona wrote:
[...] osascript -s 'tell app "TextMate" to insert ""'
I want to do the same from a javascript contained in an a href link. But I can not find the correct way to escape things [...]
Use \ for one backslash in JavaScript strings.
I am not that blind, I tried \eqref, \eqref, \\eqref, \\eqref... up to six (!) but the backslash is not inserted: only "eqref" or nothing at all, depending on the number of slashes. I'll try again since the word of the master is beyond doubt, but...
Piero
On 26/9/2006, at 16:44, Piero D'Ancona wrote:
Use \ for one backslash in JavaScript strings.
I am not that blind, I tried \eqref, \eqref, \\eqref, \\eqref... up to six (!) but the backslash is not inserted: only "eqref" or nothing at all, depending on the number of slashes. I'll try again since the word of the master is beyond doubt, but...
Yeah, you would actually need 4 or 8 here. 2 for the actual AppleScript string, but this is inside a JavaScript string, so both needs escaping (so total is now 4) -- depending on how you produce the JavaScript, you may need to again escape each, making it now 8. This would be the case if you use e.g. echo with a double-quoted string. In single-quoted strings or here-docs you would not need to escape .
Lovely! eight escapes does the trick. My faith went only so far as six \\\, forgive me, master
Piero
On 26 Sep 2006, at 16:38, Piero D'Ancona wrote:
Lovely! eight escapes does the trick. My faith went only so far as six \\\, forgive me, master
It's always going to be 2^(number of times the slash is escaped) - so six would never be right :)
Allan Odgaard <throw-away-1 <at> ...> writes:
On 26/9/2006, at 11:27, Piero D'Ancona wrote:
[...] osascript -s 'tell app "TextMate" to insert ""'
I want to do the same from a javascript contained in an a href link. But I can not find the correct way to escape things [...]
Use \ for one backslash in JavaScript strings.
I confirm what I said: it does not work. Try the following html:
<a href="javascript:TextMate.system("/usr/bin/osascript &>/dev/null -e 'tell app \"TextMate\" to insert \"\\eqref\"' &", null);">try</a>
A link is produced but if you click on it nothing happens. (if you put \eqref instead of \eqref, the text "eqref" is inserted). Sorry! something here really escapes me, as usual
Piero