On Jan 28, 2010, at 9:19 AM, LuKreme wrote:

> On 28-Jan-2010, at 07:32, TGC wrote:
>> 
>> Last I checked, WebKit is not curses-based.
> 
> Yeah, I have no idea why you said that the first time. What are you on about? 
> We're talking about converting an HTML to a plain text message. This has 
> nothing to do with a 'curses-based web browser'. lynx -dump is fast and 
> efficient and is certainly an option (I used to use it in procmail to deal 
> with messages that were tagged as text/html in the headers); though I think 
> using WebKit for 'free' is a much better idea.

Which is what we'll do if we need to, and it's incredibly simple in Cocoa:

// incoming html
var html = @"<b>Hello World<br/>This is a new line";
var htmlData = [html dataUsingEncoding:NSUTF8StringEncoding];


// we will "render it"
var attributedHTML = [[NSAttributedString alloc] initWithHTML:htmlData 
options:nil documentAttributes:nil];

// and convert it.
var plainText = [attributedHTML string];

print(plainText);

/*
Hello World
This is a new line
*/

(That's JSTalk, not objc for the curious.  Still Cocoa though)

-gus

--  

August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/

_______________________________________________
[email protected] mailing list
List help: http://lists.ranchero.com/listinfo.cgi/email-init-ranchero.com

Reply via email to