How to display an AppleScript on a web page?

Hi,

I’d like to display my script on a web page, for the viewer to copy it. Is there a way to easily ‘convert’ the script so that it can be pasted in html, to display properly on a web page? Instead of simply pasting the text, it would be nice to have the commands in bold, etc, as they are displayed in Script editor.

Hi jakesm.

If you’re talking about posting in these fora, there are [applescript] and [/applescript] tags you can use which cause script text to be displayed with a clickable link that opens the text in the user’s default script editor.

I don’t know about converting HTML for display on a normal Web page. But bear in mind that script formatting is a user preference set in Script Editor (or whatever you’re using). What’s blue or bold for you may not be so for other people, so displaying your own colours and styles ” even if they’re the defaults ” isn’t really helpful.

The formatting is an system setting, not Script Editor setting per se. You can use AppleScriptObjC and NSAppleScript to get the NSAttributed string using the method richTextSource:. Then you can use AppKit.framework to convert an NSAttributedString into HTML source code.