-- Clipboard2HTML 1.0
-- This script converts selected or dropped AppleScripts to HTML, when user copies them to the clipboard.
-- Save as "Stay open" application with Script Editor.
-- The Script Editor is not scriptable, but the clipboard is, with standard additions of Mac OS 8.*.
-- Requires styled text editor Style by Marco Piovanelli, <http://www.merzwaren.com> and
-- script "Convert to HTML" by Bill Cheeseman, included in Style distribution. Newer versions of
-- Script2HTML at <http://www.AppleScriptSourcebook.com>
-- Quick 'n' dirty written by Tuomas Rosberg <vanhentunut>
-- This source code is free and has been placed into the public domain 2000-1-31.
-- This source code is made available in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
on run
tell application "Finder"
set theList to selection
if theList is {} then
display dialog ¬
"Please select some scripts to open. " buttons "Sorry" default button 1
else
my toHTML(theList)
end if
end tell
end run
on open (theList)
my toHTML(theList)
end open
to toHTML(theList)
tell application "Finder"
set theScriptEditor to (application file id "ToyS") --the Script Editor.
set thisScript to ""
try
set thisScript to (get file of me) --file of the application running this script.
on error
end try
set avoidThese to {(theScriptEditor as alias), (thisScript as alias)} --to make it impossible to open it using it:-)
repeat with x in theList
if creator type of x is in {"dplt", "aplt", "ToyS"} then -- the creator types of the Script Editor.
if (x as alias) is not in avoidThese then
open x using theScriptEditor
end if
end if
end repeat
--
activate
set the clipboard to "" -- puts an empty string to the clipboard.
end tell
end toHTML
on idle
tell application "Skriptieditori" -- the Script Editor. EDIT THIS!
activate
set theData to the clipboard -- theData gets current contents of the clipboard.
set theData to theData as text
set the clipboard to ""
end tell
if theData is "" then
return 5
else if theData is not "" then -- the user has copied some text to the clipboard.
--make a name for a new document
set delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set theName to text item 2 of theData -- with the commenting conventions of mine, returns the name of the script. EDIT THIS!
set AppleScript's text item delimiters to delims
tell application "Style"
make new document with properties {name:theName}
tell front document
activate
set selection to theData
set the clipboard to ""
end tell
run script alias "Hupu:Style 1.6 folder:Style Scripts:HTML:Script2HTML" -- EDIT THIS with the location of script "Convert to HTML".
end tell
end if
return 5
end idle