• 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 syntax highlighting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript syntax highlighting


  • Subject: Re: AppleScript syntax highlighting
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 26 May 2016 11:56:33 +1000

On 25 May 2016, at 1:45 AM, 2551phil <email@hidden> wrote:

I’ve been hunting around the web looking for a script (any language) that could take uncompiled AppleScript and return an html markup of that text that would replicate (or as near as possible) compiled “pretty” AppleScript syntax highlighting.

I see you found a solution, but here's a simple AppleScript version:

use AppleScript version "2.3"
use framework "Foundation"
use framework "AppKit"
use scripting additions

set thePath to POSIX path of (choose file of type {"scpt", "scptd"})
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set theScript to current application's NSAppleScript's alloc()'s initWithContentsOfURL:theURL |error|:(missing value)
set theAttSource to theScript's richTextSource()
set docTypeDict to current application's NSDictionary's dictionaryWithObject:(current application's NSHTMLTextDocumentType) forKey:(current application's NSDocumentTypeDocumentAttribute)
set theData to theAttSource's dataFromRange:{0, theAttSource's |length|()} documentAttributes:docTypeDict |error|:(missing value)
set newURL to theURL's URLByDeletingPathExtension()'s URLByAppendingPathExtension:"html"
theData's writeToURL:newURL atomically:true
display dialog "Finished"

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: AppleScript syntax highlighting
      • From: 2551phil <email@hidden>
References: 
 >AppleScript syntax highlighting (From: 2551phil <email@hidden>)

  • Prev by Date: functions as sort of first class objects
  • Next by Date: Re: AppleScript syntax highlighting
  • Previous by thread: Re: AppleScript syntax highlighting
  • Next by thread: Re: AppleScript syntax highlighting
  • Index(es):
    • Date
    • Thread