Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread John Delacour
On 24/01/2013 23:26, Adam Engst wrote: BBEdit and perl FTW! cheers... As a postscript to this thread I think it’s worth emphasizing how wonderfully simple it is to use Perl RE in text filters by explaining just what is happening. BBEdit has set things up so that the input to the text filte

Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread Adam Engst
On Thu, Jan 24, 2013 at 5:17 PM, LuKreme wrote: > This has turned into one of the most interesting threads on the list in a > long time. I've learned tons, so I've flagged it so maybe at some point in > the future I will refer back to it when I need to do something really > interesting and comp

Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread LuKreme
On 24 Jan 2013, at 12:04 , Patrick Woolsey wrote: > It's important to keep in mind here that such an AppleScript has no > document to work with; it must instead directly manipulate the text (i.e. > the string) it receives from BBEdit. This has turned into one of the most interesting threads on th

Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread Patrick Woolsey
At 09:16 -0800 01/23/2013, Adam Engst wrote: [...] >What I'm trying to do is create a text _factory_ that does a few standard >grep replacements, and then calls something else to do this renumbering >(since there's no other way to do the renumbering from within a text >factory that I can think of).

Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread Patrick Woolsey
At 14:46 -0500 01/23/2013, Adam Engst wrote: >I'm just being bloody-minded here, since I believe this should be >doable entirely within a text factory. :-) It is :-) and either John's or Ronald's scripts should work when applied from within a text factory. (NB: You will need to edit the shebang

Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread John Delacour
On 24/01/2013 14:51, Adam Engst wrote: Man, you're going to make me learn perl grep syntax, aren't you? :-) Perl regular expressions are the basis of the PCRE used in BBEdit, so there’s very little to learn if you’re familiar with PCRE. The main difference is that Perl uses $&, $1, $2 for

Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread Ronald J Kimball
On Thu, Jan 24, 2013 at 09:51:25AM -0500, Adam Engst wrote: > Man, you're going to make me learn perl grep syntax, aren't you? :-) > > I see roughly how to do it, and I can do simple substitutions in perl, > but I'm having trouble getting the more complex ones to run. I've > figured out that you n

Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread Adam Engst
On Thu, Jan 24, 2013 at 5:10 AM, John Delacour wrote: > I think the question is rather, why not do the whole thing with a Perl text > filter? Then your text filter to do the whole lot would be something like > the script below. This can be run, with or without a key shortcut, from the > Text Fil

Re: Help getting an AppleScript to run as a text filter

2013-01-24 Thread John Delacour
On 23/01/2013 17:16, Adam Engst wrote: What I'm trying to do is create a text _factory_ that does a few standard grep replacements, and then calls something else to do this renumbering...So the question becomes, how would such a perl script or AppleScript need to be written to work from within

Re: Help getting an AppleScript to run as a text filter

2013-01-23 Thread Rich Siegel
On Wednesday, January 23, 2013, Adam Engst wrote: > So the question becomes, how would such a perl script or AppleScript need > to be written to work from within a text _factory_? Here's a quick excerpt from the manual: When you use the Run AppleScript Filter operation, your script sho

Re: Help getting an AppleScript to run as a text filter

2013-01-23 Thread Adam Engst
On Wed, Jan 23, 2013 at 1:33 PM, Christopher Stone wrote: > On Jan 23, 2013, at 11:16, Adam Engst wrote: >> What I'm trying to do is create a text _factory_ that does a few standard >> grep replacements, and then calls something else to do this renumbering >> (since there's no other way to do t

Re: Help getting an AppleScript to run as a text filter

2013-01-23 Thread Christopher Stone
On Jan 23, 2013, at 11:16, Adam Engst wrote: > What I'm trying to do is create a text _factory_ that does a few standard > grep replacements, and then calls something else to do this renumbering > (since there's no other way to do the renumbering from within a text factory > that I can think of

Re: Help getting an AppleScript to run as a text filter

2013-01-23 Thread Adam Engst
Sorry for the delayed response here - Google Groups apparently decided not to send me email despite the Email Updates To Me setting, but since John cc'd me on his replies, I thought he was the only who had written back... On Wednesday, January 16, 2013 2:36:04 PM UTC-5, Rich Siegel wrote: > > On

Re: Help getting an AppleScript to run as a text filter

2013-01-22 Thread John Delacour
On 17/01/2013 16:10, Adam Engst wrote: ...Thanks, John! I've never learned any perl, so I can't really parse what your script is doing, but it's not doing quite what I need. Take a look at these two files for a before and after view: https://dl.dropbox.com/u/574336/AutoRip-original.md and http

Re: Help getting an AppleScript to run as a text filter

2013-01-17 Thread Ronald J Kimball
On Thu, Jan 17, 2013 at 11:10:05AM -0500, Adam Engst wrote: > Thanks, John! I've never learned any perl, so I can't really parse > what your script is doing, but it's not doing quite what I need. Take > a look at these two files for a before and after view: > > https://dl.dropbox.com/u/574336/Auto

Re: Help getting an AppleScript to run as a text filter

2013-01-17 Thread Adam Engst
On Wed, Jan 16, 2013 at 5:06 PM, John Delacour wrote: > I’m afraid I find AppleScript impossibly verbose for this kind of simple > text munging. I don’t know what your docs look like but, supposing each > link is on a separate line, then the Perl script below, saved as a text > filter, will chang

Re: Help getting an AppleScript to run as a text filter

2013-01-16 Thread Christopher Stone
Hey Adam, Hmm. That script doesn't work for me. [I believe I've figured it out.] Your script runs fine from BBEdit's script menu. ~/Library/Application Support/BBEdit/Scripts/Number Markdown * Links.scpt On Jan 16, 2013, at 11:32, Adam Engst wrote: > But every now and then I need to number

Re: Help getting an AppleScript to run as a text filter

2013-01-16 Thread John Delacour
On 16/01/2013 17:32, Adam Engst wrote: (This paragraph is an example of lazylinks - the two links should be numbered 1 and 2.) [*]: http://tidbits.com/ [*]: https://leanpub.com/ Adam, I’m afraid I find AppleScript impossibly verbose for this kind of simple text munging. I don’t know what

Re: Help getting an AppleScript to run as a text filter

2013-01-16 Thread Rich Siegel
On Wednesday, January 16, 2013, Adam Engst wrote: The problem is that the AppleScript works fine when run from AppleScript Editor, but throws an error when run as a text filter from within BBEdit. [...] Any suggestions on how to fix this script so I can embed it in a text factory? Thanks! W

Help getting an AppleScript to run as a text filter

2013-01-16 Thread Adam Engst
Hi folks, I have modified a found AppleScript to number the lazylinks in a Markdown file. Lazylinks are something we created for [TidBITS][*] that enables us to identify every link with an asterisk, and then associate the source text and destination URL via the order they appear. It's much easi