Fix table align reader (#88)
* fix: table align reader * 0.0.87 * fix: spec * chore: add fixturemain
parent
146a6d799c
commit
4bce99003f
|
@ -3,7 +3,7 @@ use std::fs::*;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut file = File::open("./6.docx").unwrap();
|
let mut file = File::open("./from_doc.docx").unwrap();
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
file.read_to_end(&mut buf).unwrap();
|
file.read_to_end(&mut buf).unwrap();
|
||||||
dbg!(read_docx(&buf).unwrap().json());
|
dbg!(read_docx(&buf).unwrap().json());
|
||||||
|
|
|
@ -26,10 +26,10 @@ impl FromStr for TableAlignmentType {
|
||||||
type Err = errors::TypeError;
|
type Err = errors::TypeError;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
match s {
|
||||||
"left" => Ok(TableAlignmentType::Left),
|
"start" | "left" => Ok(TableAlignmentType::Left),
|
||||||
"right" => Ok(TableAlignmentType::Right),
|
"right" | "end" => Ok(TableAlignmentType::Right),
|
||||||
"center" => Ok(TableAlignmentType::Center),
|
"center" => Ok(TableAlignmentType::Center),
|
||||||
_ => Err(errors::TypeError::FromStrError),
|
_ => Ok(TableAlignmentType::Left),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,3 +199,18 @@ pub fn read_textbox() {
|
||||||
file.write_all(json.as_bytes()).unwrap();
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
pub fn read_from_doc() {
|
||||||
|
let mut file = File::open("../fixtures/from_doc/from_doc.docx").unwrap();
|
||||||
|
let mut buf = vec![];
|
||||||
|
file.read_to_end(&mut buf).unwrap();
|
||||||
|
let json = read_docx(&buf).unwrap().json();
|
||||||
|
|
||||||
|
assert_debug_snapshot!(&json);
|
||||||
|
|
||||||
|
let path = std::path::Path::new("./tests/output/from_doc.json");
|
||||||
|
let mut file = std::fs::File::create(&path).unwrap();
|
||||||
|
file.write_all(json.as_bytes()).unwrap();
|
||||||
|
file.flush().unwrap();
|
||||||
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "docx-wasm",
|
"name": "docx-wasm",
|
||||||
"version": "0.0.86",
|
"version": "0.0.87",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"browser": "dist/web/index.js",
|
"browser": "dist/web/index.js",
|
||||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue