Here is an AppleScript that will do most of what you want: This will look at the current cursor position, and use the 'balance tags' command to select the content of the current tag.
It will then extend that selection to contain the <span> and </span>, and if it is indeed the tags is a <span> tag, it will remove it. It will not affect any nested tags. I wasn't able to find a scriptable version of the Remove Markup menu item. Feel free to use this as you see fit. *tell* *application* "BBEdit" *tell* *front* *window* *set* cursorPos *to* characterOffset *of* selection *balance tags* *set* startPos *to* characterOffset *of* selection *set* endPos *to* startPos + (length *of* selection) *select* (*characters* (startPos - 6) *thru* (endPos + 6)) *set* selectedText *to* selection *as* *text* *if* *characters* 1 *thru* 6 *of* selectedText *as* *text* *is* *equal to*"<span>" *then* *set* replaceText *to* *characters* startPos *thru* (endPos - 1) *as* *text* *set* selection *to* replaceText *end* *if* *select* *insertion point* *before* *character* (cursorPos - 6) *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 bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com 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 "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>