NSAttributedString producing malformed XHTML
NSAttributedString producing malformed XHTML
- Subject: NSAttributedString producing malformed XHTML
- From: Glen Simmons <email@hidden>
- Date: Tue, 19 Jun 2007 14:43:02 -0500
My app has an NSTextView for the user to enter notes, images, etc.
For storage, the notes are converted to XHTML like so:
NSArray* kExcludedElementsArray = [NSArray arrayWithObjects:
@"doctype", @"head", @"body", nil];
NSDictionary* attributesDict = [NSDictionary
dictionaryWithObjectsAndKeys:
NSHTMLTextDocumentType, NSDocumentTypeDocumentAttribute,
kExcludedElementsArray,
NSExcludedElementsDocumentAttribute,
[NSNumber numberWithInt: NSUTF8StringEncoding],
NSCharacterEncodingDocumentAttribute,
nil];
NSError* dataFromRangeError = nil;
NSRange fullRange = NSMakeRange(0, [attribString length]);
NSData* xhtmlData = [attribString dataFromRange: fullRange
documentAttributes: attributesDict
error:
&dataFromRangeError];
This works fine unless there happen to be two images with hyperlinks
next to each other. Then, the above produces XHTML with an extra </
font> tag after the second image. I know this is a really specific /
weird issue, but I thought I'd throw it out there and see if anyone
had any suggestions. Using XHTML is a requirement, so I'm afraid
"Don't do that" won't be overly helpful. :-) And yes, I'll file a bug.
Thanks,
Glen Simmons
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden