pub fn parse_document_blocks_with_options(
bytes: &[u8],
options: ExtractDocumentBlocksOptions,
) -> Result<StructuredDocument, String>Examples found in repository?
examples/parse_blocks.rs (line 18)
1fn main() -> Result<(), Box<dyn std::error::Error>> {
2 let mut path = None;
3 let mut options = extend_docx::ExtractDocumentBlocksOptions::default();
4 let mut positional_only = false;
5 for argument in std::env::args_os().skip(1) {
6 if !positional_only && argument == "--" {
7 positional_only = true;
8 } else if !positional_only && argument == "--include-words" {
9 options.include_words = true;
10 } else if path.is_none() {
11 path = Some(argument);
12 } else {
13 return Err("Expected one document path and optional --include-words".into());
14 }
15 }
16 let path = path.ok_or("A document path is required")?;
17 let bytes = std::fs::read(path)?;
18 let parsed = extend_docx::parse_document_blocks_with_options(&bytes, options)?;
19 serde_json::to_writer(std::io::stdout().lock(), &parsed)?;
20 Ok(())
21}