• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSAttributedString producing malformed XHTML
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSAttributedString producing malformed XHTML
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: Why the need for the id type?
  • Next by Date: Re: Concerns about changing NSManagedObjectContext
  • Previous by thread: Re: Cocoa documentation feedback
  • Next by thread: Re: NSAttributedString producing malformed XHTML
  • Index(es):
    • Date
    • Thread