Set AppleScript's text item delimiters to "\\\""ĭo JavaScript (" = \"" & Bodytext & " \"") in document 1Īs you know, the complication arises from the fact that you’re creating, in an AppleScript string, a JavaScript command with its own string parameter. Set AppleScript's text item delimiters to "\"" Replace all quotes in the text with the characters backslash and quote. Replace all 'paragraph' endings in the text with the characters backslash and r. Set Bodytext to text of text window 1 as string The equivalent for quote characters (if you’re making the change in AppleScript) is probably “\"” ” the first backslash to escape the second and the third to escape the quoted quote! tell application "BBEdit" I’m glad the business with the returns actually works. I’m not quite sure of the correct syntax to have AS parse them in a similar way to the returns. Now… I’m running into a similar problem with code that contains quotes, which I need to transfer html and quotes in text back into Safari. (Edited the following morning to reduce the amount of code, by using the text’s ‘paragraphs’ instead of getting its ‘text items’ with a delimiter of return.) On receiving the two characters in a string, JavaScript interprets them as an escaped “r” and substitutes a return. Set AppleScript's text item delimiters to astidĭo JavaScript " = \"" & Bodytext & " \"" in document 1 Set Bodytext to Bodytext's paragraphs as string Set AppleScript's text item delimiters to "\\r" Set astid to AppleScript's text item delimiters Set Bodytext to contents of text window 1 as string You can either use BBEdit’s “Find & Replace” to replace “\r” with “\r”, or do it in the script: tell application "BBEdit" Have you tried changing each return to the sequence “\r”? To do that in BBEdit or AppleScript, you have to use two backslashes ” the first one to escape the second: “\r”. I don’t know if you’ve tried this or if it makes any difference anyway.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |