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 easier for writing, since all source text references are the same, and then you just list out the destination URLs underneath the paragraph. But every now and then I need to number the links for compatibility with a system that doesn't understand lazylinks, such as [Leanpub][*]. (This paragraph is an example of lazylinks - the two links should be numbered 1 and 2.)
[*]: http://tidbits.com/ [*]: https://leanpub.com/ 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. I've looked at the BBEdit manual, but honestly, since I know only enough about AppleScript to tweak scripts, I haven't the foggiest idea how to use a RunFromBBEdit handler. Any suggestions on how to fix this script so I can embed it in a text factory? Thanks! (Text below, and here's a Dropbox link, if that's easier - not sure of the convention here.) https://dl.dropbox.com/u/574336/Number%20Markdown%20%2A%20Links.scpt cheers... -Adam *set* linkRef *to* "]\\[\\*\\]" *set* linkDest *to* "\\[\\*\\]\\:" *set* _cntr *to* 0 *tell* *application* "BBEdit" *tell* *text* *of* *text document* 1 *select* *insertion point* *before* *character* 1 *repeat* *set* refFnd *to* *find* linkRef options {search mode:grep, case sensitive: false} *if* (found *of* refFnd) = true *then* *set* _cntr *to* _cntr + 1 *tell* (*a reference* *to* found object *of* refFnd) *set* *its* *text* *to* "][" & _cntr & "]" *end* *tell* *set* deskFnd *to* *find* linkDest options {search mode:grep, case sensitive :false} *if* (found *of* deskFnd) = true *then* *tell* (*a reference* *to* found object *of* deskFnd) *set* *its* *text* *to* "[" & _cntr & "]:" *end* *tell* *select* *insertion point* *before* *character* 1 *else* *beep* *end* *if* *else* *exit* *repeat* *end* *if* *end* *repeat* *select* *insertion point* *after* *character* -1 *end* *tell* *end* *tell* -- -- You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at <http://groups.google.com/group/bbedit?hl=en> If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
