1pub mod assets;
2pub mod builder;
3pub mod container;
4pub(crate) mod dist;
5pub mod doc_info;
6pub mod error;
7pub mod faces;
8pub mod hwpx;
9pub mod model;
10pub mod ole_property;
11pub mod reader;
12pub mod record;
13pub mod shape;
14pub mod structure;
15pub mod styles;
16pub mod summary;
17pub mod table;
18pub mod text;
19
20pub use doc_info::DocumentProperties;
21pub use error::{Error, Warning, WarningCode};
22pub use hwpx::writer::write_hwpx;
23pub use model::{HwpDocument, Section};
24pub use shape::{Align, CharShape, ParaShape, ShapeTables};
25pub use structure::{NodeKind, StructureNode};
26pub use summary::Metadata;
27pub use table::{Cell, Table};
28
29pub fn open(path: impl AsRef<std::path::Path>) -> Result<HwpDocument, Error> {
30 let path = path.as_ref();
31 let mut magic = [0u8; 4];
33 {
34 use std::io::Read;
35 let mut f = std::fs::File::open(path)?;
36 let _ = f.read(&mut magic)?;
37 }
38 if magic == [0x50, 0x4B, 0x03, 0x04]
39 || magic == [0x50, 0x4B, 0x05, 0x06]
40 || magic == [0x50, 0x4B, 0x07, 0x08]
41 {
42 hwpx::read_hwpx(path)
43 } else {
44 reader::read_document(path)
45 }
46}