Skip to content

Commit

Permalink
Merge pull request #44 from ImJeremyHe/jh/fix
Browse files Browse the repository at this point in the history
fix: not trim the text
  • Loading branch information
ImJeremyHe authored Apr 6, 2024
2 parents 7579d55 + cb6f82e commit bce4028
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["ImJeremyHe<[email protected]>"]
edition = "2018"
name = "xmlserde"
version = "0.8.0"
version = "0.8.1"
license = "MIT"
description = "useful tool for serializing and deserializing xml"
repository = "https://github.com/ImJeremyHe/xmlserde"
Expand All @@ -13,4 +13,4 @@ readme = "README.md"
quick-xml = {version = "0.31", features = ["serialize"]}

[dev-dependencies]
xmlserde_derives = {path = "./derives", version = "0.8.0"}
xmlserde_derives = {path = "./derives", version = "0.8.1"}
2 changes: 1 addition & 1 deletion derives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xmlserde_derives"
version = "0.8.0"
version = "0.8.1"
description = "macros that help xmlserde serde the xml files"
authors = ["ImJeremyHe<[email protected]>"]
license = "MIT"
Expand Down
3 changes: 1 addition & 2 deletions derives/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ fn children_match_branch(
Ok(Event::Text(t)) => {
use ::xmlserde::{XmlValue, XmlDeserialize};
let _str = t.unescape().expect("failed to unescape string");
let _str = _str.trim();
if _str != "" {
if _str.trim() != "" {
#untag_text_enum
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ mod tests {
pub cnt: u32,
}
let xml = r#"<root cnt="2">
<f age="15">Tom</f>
<f age="15"> Tom</f>
<f age="9">Jerry</f>
</root>"#;
let result = xml_deserialize_from_str::<Aa>(xml);
Expand All @@ -131,7 +131,7 @@ mod tests {
let mut child_iter = result.f.into_iter();
let first = child_iter.next().unwrap();
assert_eq!(first.age, 15);
assert_eq!(first.name, String::from("Tom"));
assert_eq!(first.name, String::from(" Tom"));
let second = child_iter.next().unwrap();
assert_eq!(second.age, 9);
assert_eq!(second.name, String::from("Jerry"));
Expand Down Expand Up @@ -654,14 +654,14 @@ mod tests {
}

let xml = r#"<text:p>
<text:span>text1</text:span>
<text:span> text1 </text:span>
<text:span>text2</text:span>
</text:p>"#;
let text_p = xml_deserialize_from_str::<TextP>(&xml).unwrap();
let content = &text_p.text_p_content;
assert_eq!(content.len(), 2);
if let TextPContent::TextSpan(span) = content.get(0).unwrap() {
assert_eq!(&span.t, "text1")
assert_eq!(&span.t, " text1 ")
} else {
panic!("")
}
Expand All @@ -674,7 +674,7 @@ mod tests {
let expect = xml_serialize(text_p);
assert_eq!(
expect,
"<text:p><text:span>text1</text:span><text:span>text2</text:span></text:p>"
"<text:p><text:span> text1 </text:span><text:span>text2</text:span></text:p>"
);

let xml = r#"<text:p>abcdefg</text:p>"#;
Expand Down

0 comments on commit bce4028

Please sign in to comment.