I saw the following line of code in this post on AppleScript coding of HTML class data.

do shell script "osascript -e 'try' -e 'get the clipboard as «class HTML»' -e 'end try' | awk '{sub(/«data HTML/, \"3C68746D6C3E\") sub(/»/, \"3C2F68746D6C3E\")} {print}' | xxd -r -p | textutil -convert rtf -stdin -stdout > " & quoted form of theRichTextFileName

I assume the awk command is changing «data HTML to <html> and » to </html>.

What is the reason for doing this? Does it mean that you do not put <html> and </html> in applescript HTML class data?

  • 1
    Yes, awk was making those substations in order for textutil to recognize the incoming stream of HTML data coming from xxd which converted the Hex data stream to is ASCII Text equivalent. – user3439894 May 2 at 21:05
  • 1
    @historystamp, you won't find yourself putting anything in AppleScript HTML class data, not even <HTML> tags, as «class HTML» is not a container that allows the user to manipulate its contents inside AppleScript at all. «class HTML» and «class RTF » both house an AppleScript data class object that is used to wrap hexadecimal representations of the HTML or rich text, which AppleScript can transport but doesn't have the tools to decode and make use of (although, that said, you can actually write the data object out to file and then, of course, edit the file). – CJK May 2 at 22:57
  • @CJK glad you ferreted out my "real" question. – historystamp May 3 at 18:43

You must log in to answer this question.

Browse other questions tagged .