Hi, 
Am 24.08.2011 um 24, 01:25 schrieb DaveHein:

> The problem I'm running into is that Balance Tags will select the
> innner HTML but not the span tags themselves. So if I put the cursor
> somewhere on or in "<span>some normal text here</span>" and did a Cmd-
> B, the "some normal text here" would be selected, but the opening
> "<span>" and closing "</span>" would not be selected.
> 
> I cannot see any way to get the tags that delimit the selected text to
> be selected as well.

The following script does exactly what you want. I think this script was a 
result of a similar discussion on this list years ago. I didn't write it myself 
but unfortunately I do not know who's to be credited for it:


tell application "BBEdit"
        if (balance tags) then
                set x to characterOffset of selection
                set y to x + (length of selection)
                inside tag start range (x - 2) end range (x - 2)
                set tagLength to (end_offset of tag of result) - (start_offset 
of tag of result)
                set x to x - tagLength - 1
                inside tag start range (y + 1) end range (y + 1)
                set tagLength to (end_offset of tag of result) - (start_offset 
of tag of result)
                set y to y + tagLength
                select characters x thru y of window 1
        else
                beep -- script beeps if it could not create an initial balance
        end if
end tell


happy balancing,
Roland

-- 
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>

Reply via email to