Re: text appears, but styling is gone
Re: text appears, but styling is gone
- Subject: Re: text appears, but styling is gone
- From: Paul Skinner <email@hidden>
- Date: Sun, 12 Jan 2003 08:18:39 -0500
On Sunday, January 12, 2003, at 08:05 AM, has wrote:
Philippe GRUCHET wrote:
> BTW, is it just me, or do Safari, TextEdit, etc. lose style
information when you get the text of a document?
tell application "Safari" to get text of document 1
tell application "TextEdit" to set text of document 1 to result
--> text appears, but styling is gone
Yes, styles are ignored, even with Jon's Commands.osax:
tell app "Safari" to text of document 1 as styled text
just returns as plain text.
But not unstyled text: what comes back is styled Unicode text, but the
style is plain (and always the same). Which doesn't make sense to me.
If it's by design, I'd like to know why; if not, I'd assume it's a bug
of some sort.
(This stuff might be old news to everyone else, so forgive me if I
seem a bit slow. But I've never worked much with styled text - and
this is the first time I've done it in OSX - and I'm thoroughly
confused and frustrated by it. Any help would be much appreciated.)
Thanks,
has
I assume it's a bug as the dictionary says...
text text [r/o] -- (inherited from the document class) Rich
(styled) text of the document. Is a copy. Modications to text aren't
reflected on the web page.
Well the styling is available, although I don't know the best thing to
do with it. At least it's there...
tell application "Safari"
set textList to attribute runs of text of document 1
set sizeList to size of attribute runs of text of document 1
set fontList to font of attribute runs of text of document 1
set colorList to color of attribute runs of text of document 1
end tell
set AppleScript's text item delimiters to ASCII character 1
set {textList, AppleScript's text item delimiters} to {textList as
text, ASCII character 10}
set {textList, AppleScript's text item delimiters} to {text items of
textList, ""}
set {textList, AppleScript's text item delimiters} to {textList as
text, ASCII character 1}
set {textList, AppleScript's text item delimiters} to {text items of
textList, return}
tell application "TextEdit"
activate
set the text of document 1 to (textList as text)
repeat with i from 1 to length of textList
set size of paragraph i of document 1 to (item i of sizeList)
set font of paragraph i of document 1 to (item i of fontList)
set color of paragraph i of document 1 to (item i of colorList)
end repeat
end tell
I obviously don't script TE often. I'm sure someone will straighten me
out.
--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.