I want to add xml tags to a selection in TextWrangler using applescript
For a selection like “Heading 1”, I would like it to be fromatted as Heading 1
Thanks for any/all suggestions.
I want to add xml tags to a selection in TextWrangler using applescript
For a selection like “Heading 1”, I would like it to be fromatted as Heading 1
Thanks for any/all suggestions.
I have it figured out –
This works for me…
This applescript is attached to a shortcut on quickeys. That way every time I press F3,
Quickeys will press Cmd-C
applescript runs the text processing
Quickeys will press Cmd-V
& the current selection in Textwrangler is replaced by
to clearClipboard()
tell application "Finder"
set the clipboard to ""
end tell
end clearClipboard
tell application "Finder"
tell application "TextWrangler"
set mytext to the clipboard
set openTag to "<h1>"
set closeTag to "</h1>"
set finalText to openTag & mytext & closeTag
clearClipboard() of me
set the clipboard to finalText
end tell
end tell
HOWEVER I wished there was a way to do all of this(including copying the selection from TW) in applescript.
AND I am not sure if I could have avoided that subroutine…
Hi, dns278.
This works OK in Script Editor:
tell application "TextWrangler"
set selection to "<h1>" & selection & "</h1>"
end tell
Wow.
That was easy.
Thanx Nigel
When will I learn to script easily like that ??
Hi, dns278.
Don’t despair. Working out how to write for the different AppleScript implementations in different scriptable applications is an imprecise science. Often, as in this instance, it’s simply informed guesswork. You gradually get a feel for it.