Re: styled text to html
Re: styled text to html
- Subject: Re: styled text to html
- From: Jeremy Dronfield <email@hidden>
- Date: Fri, 20 Feb 2004 22:19:49 +0000
I've found it, and it was right under my nose all the time - a
ready-cooked method of turning RTF into HTML. It's in
NSAttributedString-OAExtensions in OmniAppKit (even by Omni framework
standards, this file is very thin on documentation). The method
-htmlString parses RTF as Ryan suggested and returns a string of HTML
code. Just do:
NSString *html = [[myTextView textStorage] htmlString];
BOOL saveSuccess = html ? [html writeToFile:filename atomically:YES] :
NO;
And bingo - you've got HTML output. There are two drawbacks. It can't
handle RTFD, and the representation of font sizes is slightly wonky,
but it saves me a huge amount of very tedious coding. I'm going to see
what I can do to extend it's capabilities.
-Jeremy.
On 20 Feb 2004, at 11:10 am, Jeremy Dronfield wrote:
You'd also want to maintain a template to hold it all in. This
business of converting rich text to HTML is a task I've been looking
into over the past couple of days. Does anybody know of any sample
code which would help with parsing the text (and graphics)? I also
wondered about the possibility of using NSPrintInfo (which I'm
currently using to output text documents as PDF) - getting the style
and layout data out of that and parsing it to HTML. I can't see a way
to do it, though.
-Jeremy
On 20 Feb 2004, at 1:41 am, Ryan Bates wrote:
You can loop through every character in the text view's text storage
and compare the attributes with the previous character's attributes.
You can then insert the appropriate HTML tags depending upon what
attributes changed.
Ryan
On Feb 19, 2004, at 1:53 PM, Sascha Kuehn wrote:
hi,
is it possible to convert the contents of a text view (different
fonts, sizes and colors) into html code?
if yes, how can i do this?
sascha
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.