Fix deltext escape (#358)

* fix: deltext escape

* 0.0.207
main
bokuweb 2021-10-20 16:49:17 +09:00 committed by GitHub
parent 3579615cfa
commit 8a23be3c59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use crate::documents::BuildXML;
use crate::escape::escape;
use crate::xml_builder::*;
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
@ -13,7 +14,7 @@ pub struct DeleteText {
impl DeleteText {
pub fn new(text: impl Into<String>) -> DeleteText {
DeleteText {
text: text.into(),
text: escape(&text.into()),
preserve_space: true,
}
}
@ -41,4 +42,13 @@ mod tests {
r#"<w:delText xml:space="preserve">Hello</w:delText>"#
);
}
#[test]
fn test_escape() {
let b = DeleteText::new("<div />").build();
assert_eq!(
str::from_utf8(&b).unwrap(),
r#"<w:delText xml:space="preserve">&lt;div /&gt;</w:delText>"#
);
}
}