• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AppleScript --> HTML
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript --> HTML


  • Subject: Re: AppleScript --> HTML
  • From: John Delacour <email@hidden>
  • Date: Sun, 17 Aug 2003 23:16:20 +0100

At 3:57 pm +0100 14/8/03, Nigel Smith wrote:

Problems/suggestions/fixes eagerly awaited

Good work! I've thought a few times of doing something similar, but eventually I always come down in favour of plain text. I usually detest other people's colour schemes and I guess plenty of people would find mine not nearly garish enough, so I prefer just to present the scripts neatly and properly indented.

Here's a script that will produce an html document from an SE2 script encoded in UTF-8. the %tabl hash needs more items added to it and the whole thing is not well elaborated -- just another approach.


JD




choose from list (get name of documents)
set _script to result as Unicode text
set _html to "/tmp/_script.html"
set fU to "/tmp/_script"
set f to fU as POSIX file
set s to contents of document _script
open for access f with write permission
set eof f to 0
write s to f as +class utf8;
close access f
do shell script "perl -e '
open HTML,qq~>" & _html & "~;
print HTML <<END_OF_HEAD ;
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\";>
<html lang=\"en\">
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<title>script rendering</title>
<style type=\"text/css\">
<!--
body {
margin-left:10%;
margin-right:12%;
color:indigo;
font-family:georgia,palatino;
}
blockquote.as {
font-family:monaco,courier; color:navy;
border:solid;border-color:beige;
background:ivory;
padding-left:30px;padding-right:30px;
padding-top:30px;padding-bottom:30px;
}
div._1{margin-left:15px}
div._2{margin-left:40px}
div._3{margin-left:60px}
div._4{margin-left:80px}
div._5{margin-left:100px}
-->
</style>
</head>
<body>

END_OF_HEAD

%tabl = (
qq~ \\& ~ => qq~ \\&amp\\; ~,
qq~\\042~ => qq~\\&quot\\;~,
qq~etc~ => qq~etc~,
) ;

print HTML qq~<blockquote class=\"as\">\\n~;
open F, qq~" & fU & "~;
for (<F>){
for $x (keys %tabl){
$y = $tabl{$x} ;
s~$x~$y~g ;
}
s~^[^\\t]~<div>$&~;
s~^\\t\\t\\t\\t\\t~<div class=\"_5\">$&~;
s~^\\t\\t\\t\\t~<div class=\"_4\">$&~;
s~^\\t\\t\\t~<div class=\"_3\">$&~;
s~^\\t\\t~<div class=\"_2\">$&~;
s~^\\t~<div class=\"_1\">$&~;
s~$~</div>~ ;
print HTML ;
}
`open -a Safari " & _html & "`
'"
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: AppleScript --> HTML (From: Nigel Smith <email@hidden>)

  • Prev by Date: Dialog Monitoring
  • Next by Date: iTunes Location of Track Problem
  • Previous by thread: Re: AppleScript --> HTML
  • Next by thread: Applescript in HTML
  • Index(es):
    • Date
    • Thread