fix: remove \n in text (#461)
parent
0af4da71b8
commit
fbe0d73ecb
|
@ -4,11 +4,11 @@ use std::fs::File;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut file = File::open("./hello.docx").unwrap();
|
let mut file = File::open("./#3276.docx").unwrap();
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
file.read_to_end(&mut buf).unwrap();
|
file.read_to_end(&mut buf).unwrap();
|
||||||
|
|
||||||
let mut file = File::create("./hello.json").unwrap();
|
let mut file = File::create("./#3276.json").unwrap();
|
||||||
let res = read_docx(&buf).unwrap().json();
|
let res = read_docx(&buf).unwrap().json();
|
||||||
file.write_all(res.as_bytes()).unwrap();
|
file.write_all(res.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
|
|
|
@ -107,13 +107,15 @@ impl Run {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_text(mut self, text: impl Into<String>) -> Run {
|
pub fn add_text(mut self, text: impl Into<String>) -> Run {
|
||||||
self.children.push(RunChild::Text(Text::new(text)));
|
self.children
|
||||||
|
.push(RunChild::Text(Text::new(text.into().replace('\n', ""))));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_delete_text(mut self, text: impl Into<String>) -> Run {
|
pub fn add_delete_text(mut self, text: impl Into<String>) -> Run {
|
||||||
self.children
|
self.children.push(RunChild::DeleteText(DeleteText::new(
|
||||||
.push(RunChild::DeleteText(DeleteText::new(text)));
|
text.into().replace('\n', ""),
|
||||||
|
)));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue