On Apr 24, 2015, at 11:13, Watts Martin <lay...@gmail.com> wrote: > «event ¶erlRFtr» markdown with «class o2sl» > … > Now, you may wonder what that line with "event garble markdown with class > garble" is, and the answer is: I don't know. ______________________________________________________________________
Hey Watts, Yes. That gook is the raw event syntax and typically means it's unavailable for compilation - e.g. broken for some reason. > I saw that the BBEdit 11 release notes include the note "The AppleScript > commands for running #! filters have been removed," which I suspect is the > culprit here. Yes; it is. I'm not entirely thrilled about this change, but on the other hand one can run shell scripts directly from AppleScript. > Okay: so what's the new way to accomplish this? See p. 35 of the manual (Text Filters). It's sparse but should be read. There may be a minor problem with the RunFromBBEdit handler, and I'm checking into it. Nevertheless this works. ---------------------------------------------------- on RunFromBBEdit(_range) if _range as text = "" then set _text to text of front document set text of front document to "•• " & _text & " ••" return "" else set selectedText to _range as text set myProcessedText to "•• " & selectedText & " ••" return myProcessedText end if end RunFromBBEdit ---------------------------------------------------- > Ideally, it should do what the old script did, which is apply the Unix script > to either selected text or the whole document if nothing is selected. In this case I don't see any point to running an AppleScript as a text-filter. My inclination would probably be to write the selection/document to a temp-file and pass that to your executable which would save a lot of grief in dealing with text fed to it - such as quoting and command-length. The following script is off-the-cuff and rough, but it works and may give you some ideas. ------------------------------------------------------------------------------------------- set tempFile to (POSIX path of (path to temporary items folder as text)) & "watts.temp.txt" set _script to POSIX path of ((path to home folder as text) & "test_directory:Watts-Martin-Test:Markdown.bbpackage:Contents:Text Filters:html2text") tell application "BBEdit" tell front text window set _text to selection if class of _text = insertion point then set _text to its text set outputType to "document" else if class of _text = character then set _text to _text as text set outputType to "selection" end if end tell end tell if _text ≠ "" then writeUTF8(_text, tempFile) set shCmd to quoted form of _script & space & quoted form of tempFile set outputText to do shell script shCmd tell application "BBEdit" tell front text window if outputType is "document" then set its text to outputText else if outputType is "selection" then set selection to outputText end if end tell end tell end if ------------------------------------------------------------------------------------------- --» writeUTF8() ------------------------------------------------------------------------------------------- -- Task: Write text to a file as UTF8 and overwrite any content. -- dMod: 2012/10/26 20:00 ------------------------------------------------------------------------------------------- on writeUTF8(_text, _file) try if _file starts with "~/" then set _file to POSIX path of (path to home folder as text) & text 3 thru -1 of _file end if set fRef to open for access _file with write permission set eof of fRef to 0 write _text to fRef as «class utf8» close access fRef on error e number n try close access fRef on error e number n error "Error in writeUTF8() handler!" & return & return & e end try end try end writeUTF8 ------------------------------------------------------------------------------------------- -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.