ebarnard / rust-plist

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

`XmlWriteOptions` should allow users to specify the root element they expect (consumer-specified plist root) #80

Closed ctrlcctrlv closed 2 years ago

ctrlcctrlv commented 2 years ago

Although I am now aware that the plist format has a long and storied history in the realm of Apple's proprietary software, I only came across them because they form an integral part of the UFO font format standard.

You will notice that the great majority of UFO uses of plist see the plist sit at the root of the file, so no problem is had.

However, in UFO, there is an even more obscure format, .glif, the individual glyph standard, around which I based MFEKglif and its glifparser.

This format is prescribed as XML, not plist, unusual for the spec. But it has a plist—an internal plist called <lib>. Your library thankfully lets us write these internal plist's due to @cmyr's work. Colin undoubtedly had the same problem I'm having, but probably wisely chose not to bother you about it. Nevertheless, I lack his wisdom, and here I am. Could the XML root element itself, or else its name and attributes, find themselves added to XmlWriteOptions?

https://github.com/ebarnard/rust-plist/blob/4643d95b2ec21257214976edd7655edda19acd55/src/stream/xml_writer.rs#L16-L19

cmyr commented 2 years ago

I think it's best to implement this outside of the plist library; it's really just a weird UFO thing. There's code here that you can borrow :)

https://github.com/linebender/norad/blob/master/src/glyph/serialize.rs#L148

ebarnard commented 2 years ago

At the moment, the xml declaration and \ root element are just written as strings.

I wouldn't object to having an option to omit the root \ element and xml declaration.