Skip to content

Instantly share code, notes, and snippets.

@jasonwiener
jasonwiener / tag.scpt
Created August 4, 2017 15:43
BBEdit wrap selection (or create empty) HTML tag with CSS class using AppleScript
-- tag input options:
-- div -> <div>{SELECTED TEXT IF ANY}</div>
-- div.myclass -> <div class="myclass">{SELECTED TEXT IF ANY}</div>
on splitText(theText, theDelimiter)
set AppleScript's text item delimiters to theDelimiter
set theTextItems to every text item of theText
set AppleScript's text item delimiters to ""
return theTextItems
end splitText