ebarnard / rust-plist

A rusty plist parser.
MIT License
71 stars 42 forks source link

Emit doctype, better match Apple's plist output #27

Closed lilyball closed 6 years ago

lilyball commented 6 years ago

Change the plist output to match Apple's. This means uppercasing the XML encoding, including a doctype, indenting using hard tabs, and stripping one level of indentation from the file.

The implementation here isn't great, because xml-rs doesn't have any way of emitting a doctype directly (see netvl/xml-rs#168), but it works.

Fixes #26.

ebarnard commented 6 years ago

I've got no objections to fixing #26 and it would be good to have the output match Apple's native plist writer. But as this is hopefully a temporary fix I'd like it to be as minimal as possible.

I think it we set EmitterConfig::perform_escaping(false) and change EventWriter::write_value to call xml::escape::escape_str_pcdata on the text to be written we could just write an XmlEvent::Characters containing the DTD, XML header before the opening plist tag.

lilyball commented 6 years ago

Good idea. Not sure why that didn't occur to me. I'll try it out when I get a chance (hopefully tonight, but no promises).

lilyball commented 6 years ago

@ebarnard I've updated the PR to use the approach you suggested.

ebarnard commented 6 years ago

Thanks!