Re: Styled text and non-Gregorian dates
Re: Styled text and non-Gregorian dates
- Subject: Re: Styled text and non-Gregorian dates
- From: Philip Aker <email@hidden>
- Date: Tue, 5 May 2009 15:24:27 -0700
On 2009-05-01, at 14:50:38, Christopher Nebel wrote: If you really meant specifically "paste", that is, working through the clipboard, then it's possible, but difficult, since it's not really supported. Basically, you have to come up with a raw-data representation of the text, and stuff that on to the clipboard. Pasting a link requires using RTF, which actually simplifies matters a little since it's based on ASCII text. This example puts "A link here" on to the clipboard, where "link" is a link to http://www.apple.com: set the clipboard to «data RTF 7B5C727466310A41207B5C6669656C647B5C2A5C666C64696E73747B48595045524C494E4B2022687474703A2F2F7777772E6170706C652E636F6D227D7D7B5C666C6472736C74206C696E6B7D7D20686572652E7D» (That's supposed to be all one line; there's a single space between "RTF" and the hex data.) Producing the appropriate stream of hex for your purposes is left as an exercise for the reader. =)
For those of you who don't feel like exercising, here's an example of converting HTML text to RTF on the clipboard [1]:
-- Watch out for emailer line breaks -- The HTML text is a single line. set html to quoted form of "<html><head><title>Regular Exercise</title><style type='text/css'>body {font-family:Papyrus;font-size:21pt;}</style></head><body>Visit the <a href=''">http://en.wikipedia.org/wiki/Giza_pyramid_complex'>pyramids</a></body></html>"
set rtf to (do shell script "echo " & html & "| textutil -stdin -stdout -convert rtf") set the clipboard to (run script (do shell script "tclsh <<< 'binary scan {" & rtf & "} H* res;puts \"«data RTF $res»\";'"))
In case there is a problem with the output formatting on your machine, try using the lowercase "h*" alternate specifier.
Philip Aker echo email@hidden@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch.
|
_______________________________________________
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