Re: formatting AS source for web
Re: formatting AS source for web
- Subject: Re: formatting AS source for web
- From: Chris Adams <email@hidden>
- Date: Sat, 11 Aug 2001 06:45:31 +0000
On 8/1/01 11:53 AM Robert J. Rust wrote:
>
Does anybody know of a good way to format AppleScript source code for the
>
web (including retaining syntax hilighting)? The only way I've found so far
>
is to copy and paste from Script Editor into MS Word, then save as HTML.
>
Unfortunately Word creates excessively bloated HTML documents. I'm hoping
>
there's a better way.
>
>
Robert
I realized after writing that this is a similar technique, but it can be
automated with a script (which follows). The code is a little bit bloated,
but error free. To attempt this with style sheets and lists of keywords is
agony - I tried it for another project.
=======
The easiest way to do this is:
1) open the script in Script Editor
2) Cut and paste into Appleworks
3) Save as HTML
This maintains your formatting and color. Another advantage is that the
scripts can be selected from your web page and pasted right back into a
script editor as ASCII.
There are examples of this technique here:
http://www.cypresslakestudios.com/applescript/index.html
This script automates the process for AW 5.x:
(it is online here:
http://www.cypresslakestudios.com/applescript/makescripthtml.html
)
-- start script
(*
When you select the contents of an applescript, run this script to get an
HTML version saved
in the To Post & drafts folder. This streamlines the process of building
applescript
example pages for the web.
*)
set to_post_folder to "Current projects:Web site files:Cpress Lake
studios:To Post & drafts:" as string -- whatever folder
set filename to the text returned of (display dialog ,
"set HTML file name:" default answer ,
"test.html")
set HTML to "HTML" as string -- this is important
set file_location to to_post_folder & filename
tell application "AppleWorks"
activate
set thedoc to (make new document at front with properties {document kind:WP,
name:filename})
paste
save thedoc as file type text using translator HTML in file_location
end tell
-- end script
Hope that this helps.
--
Chris Adams
Cypress Lake Studios
Hypermedia, Quicktime, and Internet Design
http://www.cypresslakestudios.com
email@hidden