Re: AppleScript formatting & web page size
Re: AppleScript formatting & web page size
- Subject: Re: AppleScript formatting & web page size
- From: has <email@hidden>
- Date: Tue, 30 Oct 2001 01:05:01 +0000
Robert J. Rust wrote:
>
Forgive me if someone's already mentioned this, but has anybody noted the
>
amount of extra text that is added when you post a formatted AppleScript to
>
the web? I wrote a fairly long script for use in our computer labs and
>
spent a fair amount of time coming up with a way to put it into HTML with
>
syntax formatting intact. What I ended up with was a 264K HTML document.
>
The .txt version of the same is 16K. Stylesheets may help with this, but
>
even then I suspect a huge difference in size.
16x bigger? Nasty.
Disclaimer: I'm not a big fan of posting formatted code online in the first
place (see the recent thread on AS formatting).
That said, if it's gotta be done then for heaven's sake don't do it with
<font> tags. <FONT> tags are EVIL: they will kidnap your children and burn
down your house. And then they'll bloat your webpage to a quarter meg just
for kicks. Pure Evil.
CSS, done efficiently, would reduce that ugly swelling back down to maybe
2x original size:
1. You can get away with marking up just 6 out of the 8 keyword categories,
since unformatted is irrelevant and one of the remaining 7 can appear in
the default style (I'd suggest operators). That's a saving right there.
2. Although you could use markup of form:
<span class="applicationkeyword">some text</span>
you'll get a smaller html file by co-opting the following tags:
<b>, <i>, <em>, <tt>, <var>, <kbd> (note: all these tags are valid for
XHTML1.0)
Bit of a hotchpotch selection perhaps (and maybe someone can suggest a
better choice/arrangement), but they're compact and will do the job. You
can restyle them as you like via css (if css is not available the text will
render using the browser's default styling). For example:
***The Stylesheet***
/*my personal fave - the hippie rainbow stylesheet :)*/
.ascrpt, . ascrpt b, . ascrpt i, . ascrpt var, . ascrpt tt, . ascrpt kbd, .
ascrpt em {
font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt;
font-style: normal; font-weight: normal;}
. ascrpt b {color: red;}
. ascrpt i {color: orange;}
. ascrpt var {color: green;}
. ascrpt tt {color: blue;}
. ascrpt kbd {color: gray; font-style: italic; font-size: 11pt;}
. ascrpt em {color: purple;}
***The Markup***
<p class="ascrpt">
operator<br>
<b>language keyword</b><br>
<i>application keyword</i><br>
<var>variable</var><br>
<tt>value</tt><br>
<kbd>comment</kbd><br>
<em>reference</em>
</p>
I figure that any tool which can apply lousy rotten <font> tags to
applescript code can be easily persuaded (with a swift kick or two up the
compiler) to generate the above markup instead. The css can go in an
external stylesheet or in the page's <head>, whatever's most convenient.
HTH.
has