Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 2, 2018

Conversation

lilyball
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor Author

lilyball commented May 2, 2018

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

lilyball added 2 commits May 2, 2018 08:48
This changes the plist writer output to more closely match Apple's plist
output. More specifically, we capitalize the encoding, emit a doctype,
and use hard tabs for indentation.
This matches how Apple's plist output works.

In order to do this without completely taking over indentation duties
ourselves, we just include the <plist> tag in the prologue, so xml-rs
doesn't know about it, and then go ahead and emit an end event for the
</plist> anyway since xml-rs doesn't particularly care.
@ebarnard ebarnard merged commit 2f00fa6 into ebarnard:master May 2, 2018
@ebarnard
Copy link
Owner

ebarnard commented May 2, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants