Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow customizing quote char in xml header #156

Closed
3 tasks done
cmyr opened this issue Aug 5, 2021 · 3 comments · Fixed by #157
Closed
3 tasks done

Allow customizing quote char in xml header #156

cmyr opened this issue Aug 5, 2021 · 3 comments · Fixed by #157
Assignees

Comments

@cmyr
Copy link
Member

cmyr commented Aug 5, 2021

  • add a quote_char method to WriteOptions
  • When serializing the .glifs, (which we serialize manually) write the header to the stream ourselves, using the specified character
  • When serializing plists, we don't control writing the header, so we'll have to rewrite. There are options here. All plist writing is now handled through a method in write.rs.
    • One option is to write to disk, and then use the unix/windows specific methods to go and overwrite the header in place, before closing the file handle: see std::os::unix::fs::FileExt and std::os::windows::fs::FileExt; you'll need slightly different impls on either platform.
    • the other option would be to have a custom Write type, that would wrap or replace the BufWriter; this would intercept the header and replace it, if needed, otherwise forwarding the bytes to the inner writer.

Thinking about this, I think the first option is totally reasonable. The second option is probably marginally more 'efficient', but I don't think it matters; the main thing we want to avoid is closing and reopening all the file handles.

Originally posted by @cmyr in #148 (comment)

@chrissimpkins
Copy link
Collaborator

Started

@chrissimpkins
Copy link
Collaborator

chrissimpkins commented Aug 6, 2021

#157

Let me know what you think of the builder enum definition approach.

e.g.,

let opt = WriteOptions::default().whitespace("  ").quote_char(QuoteStyle::Single);

Currently supports glif XML writes. I'll have a look into plist support as you suggested above.

@chrissimpkins
Copy link
Collaborator

chrissimpkins commented Aug 12, 2021

Optional XML declaration single quote formatting is supported in plist files as of 2a962cd

@cmyr cmyr closed this as completed in #157 Aug 15, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants