-
Notifications
You must be signed in to change notification settings - Fork 38
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
Document to string with xmlSaveOptions #58
Comments
Certainly possible and welcome! The only reason it hasn't been added is that no one needed it yet. On a related note, I have been recurrently reminded by clippy that the libxml I could see a publicly visible struct pub struct SaveOptions {
save_no_empty_tags: bool,
save_as_html: bool,
// ...
}
pub fn to_string_custom(&self, options: SaveOptions) -> String {...} You could also implement a default for the option set, and then make the simple to_string be an alias for using it: impl Default for SaveOptions {
fn default() -> Self {
SaveOptions {
save_no_empty_tags: false,
save_as_html:false,
// ...
}
}
impl fmt::Display for Document {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.to_string_custom(SaveOptions::default()))
}
} If you feel upto creating a PR and adding a couple of tests with the default serialization, as well as one or two advanced serialization setups, I would be happy to assist+merge. |
Thank you for that quick reply. Don't expect something in the next 1-2 days, but I will definitely try to come up with a PR :) |
I would very much welcome some way to serialize a Document that is able to take
xmlSaveOptions
into account.I hacked together a branch of rust-libxml locally that does exactly what I need for my application:
It would be cool to somehow generalize this and upstream it. Since there is already
to_string()
that usesxmlDocDumpFormatMemoryEnc
I'm not sure how something that uses thexmlSaveCtxt
would fit into the picture.Is the functionality something that could find its way into the code base? And if so, how would you implement it?
I'd like to submit a PR, but think I need some guidance on how this should be implemented.
The text was updated successfully, but these errors were encountered: