JNSoftware
script icon
Convert Script to Markup Code (source code available upon request)
Version: 2.7.1
Release Date: March 15, 2004
Requirements: Mac OS X 10.2+ and either Script Editor 2 (including the beta released for Mac OS X 10.2) or Script Debugger. Certain functions may also require either Xcode or Project Builder.
Script Type: Read-Only
License: Freeware (GPL)
Installation: To install this application, copy it to your Applications folder (or anywhere, really).
screenshot
Description: This application allows you to easily convert your AppleScripts into either HTML, BBCode (the HTML-like code used on many BBS including the MacScripter BBS—a great resource, by the way), or the new AppleScript URL protocol and place the result on the clipboard. The AppleScript URL protocol is for embedding scripts in web pages and PDFs to automatically open code in the Script Editor.
You can paste the BBCode into a message on the MacScripter BBS to have the script displayed with color coded syntax. Unfortunately, the tags don’t work within the “code” blocks but they do work in the “quote” blocks rather nicely (the quote tags are automatically added when using this application—you can adjust this via the header & footer settings in the BBCode tab of the preferences).
If you opt for HTML, you can paste the HTML code into a new or existing HTML document to get a great representation of your formatted script in a web browser. If you paste into an existing document, be sure to strip the header and footer of the script HTML so your document will not have multiple headers and footers—again, like the BBCode, you can adjust the HTML header & footer settings in the HTML tab of the preferences. If you’d like, via the “Utilities” menu (in the menu bar or below the convert button in the main interface window), you can save the converted HTML as a file. It will be saved in the same location as the script (or the desktop folder if the script has not been saved). All of the script source files on this site were automatically created using this application.
With a quick modification of the preferences, you can also use this application to convert AppleScripts created in Script Debugger. Scripts converted using Script Debugger will also include bold and italic formatting as appropriate. Another feature available via the preferences is the ability to try and compile your script using terms from either Xcode or Project Builder. This is handy if you want to convert code from an AppleScript Studio project.
Use:
Simply launch the application and a utility palette will appear. This palette will appear only when the default editor (set via the preferences) is the frontmost application. With a script open in Script Editor, from the utility palette, choose to either convert your script to an AppleScript URL protocol or to HTML or BBCode (you can also include an AppleScript URL protocol in either the HTML or BBCode conversion), choose how you want the AppleScript URL protocol configured (if you’ve opted to include it), then click the round “C” button (“C” for Convert). If your script is valid, it will be converted. If it contains syntax errors, you will be notified of the errors. If there are errors, by default, the application will try to wrap your script in a “using terms from application Xcode” block. This makes it easy to copy code from your AppleScript Studio project, paste into the Script Editor, and still get the benefits of the conversion even if your code contained syntax specifically targeted to your project. When converted, even if your script is now wrapped in the “using terms...” block, that code will not be included in the converted script. If your script still won’t compile, then you will receive the error notification. (You can opt to not try to compile the script with the “using terms...” block by disabling the feature via the preferences.)
When using the AppleScript URL protocol, there is a bug acknowledged by Apple (see https://www.apple.com/applescript/scripteditor/12.html) when encoding high ASCII characters such as “¬” or “Å”. If your code contains these characters, the link will not open properly in Script Editor. To account for this, Convert Script to Markup Code provides an option via the preferences to convert high ASCII in AppleScript URLs. If you enable this (it is disabled by default), then all the high ASCII characters in the AS URL (including “¬”) will be converted to pseudo-encoded entities and will work in AppleScript URLs. (This will only effect the AppleScript URL conversion, not the conversion to BBCode or HTML.) The caveat to this is that once an AppleScript URL that contains these pseudo-encoded entities is opened in Script Editor, those pseudo-encoded entities must be converted back. This conversion is done via the application: click on the palette to make it active then from the “Utilities” menu, select “AS URL High ASCII Cleanup”.
To change your preferences, click on the utility palette to make the application active. Then, from the application menu, select “Preferences...” (or use the hotkey Command-;). Among the options available from the preference window, you can opt to use Script Debugger instead of Script Editor, turn off the option to try and compile by adding the “using terms from application Xcode” block (and also changing Xcode to Project Builder), change the notification behavior of the application, choose HTML & BBCode headers & footers, enter a default signature and credit line (this is optional but highly encouraged!) to add to the end of your BBCode formatted code, and more.
What’s New in 2.7.1:
  • Added a “Revert to Default Settings” button in the General preferences tab.
  • Added an “Edit” menu so you an now copy & paste data in & out of the text fields of the preference tabs.
  • Added an option to set the creator type of saved HTML files.
What’s New in 2.7:
  • Added a batch feature for converting a folder full of scripts into HTML files.
  • Added more options when converting to HTML.
  • Added basic support for CSS. (This requires that the syntax formatting is set to the defaults—either the Mac OS X 10.3 defaults or the earlier defaults carried over from classic.) This should make the converted code more manageable and easier to customize down the road.
  • Several minor bug fixes.