Skip to content

Commit

Permalink
Update readme, add pretty_json option
Browse files Browse the repository at this point in the history
  • Loading branch information
driver-deploy-2 committed May 20, 2024
1 parent 20d07a3 commit f7c9bfc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

This package uses the [docx-rs](https://crates.io/crates/docx-rust) crate to parse docx files. It subsequently converts the parsed docx file into Markdown format. Alternatively, it can also be used to convert docx files into JSON format, where only the structure relevant for creating Markdown documents is kept.

It can be used as a library, or you can install it and use it from the command line.

## CLI application

```bash
$ git clone https://github.com/erikvullings/docx-parser.git
$ cargo install --path .
$ docx-parser -h

Processes a DOCX file and outputs as Markdown or JSON
Expand All @@ -14,12 +20,15 @@ Arguments:

Options:
-o, --output <OUTPUT> Sets the output destination. Default is console
-f, --format <FORMAT> Sets the output format. Default is markdown. Options: md, json
-f, --format <FORMAT> Sets the output format. Default is markdown. Options: md, json, pretty_json
-h, --help Print help
-V, --version Print version

# Example
$ docx-parser ./test/tables.docx -f pretty_json
```

## Example
## Library

```rust
use docx_parser::MarkdownDocument;
Expand All @@ -32,7 +41,7 @@ println!("\n\n{}", markdown);
println!("\n\n{}", json);
```

## Development
## Development commands

```bash
cargo update
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fs;

#[derive(Parser)]
#[command(name = "docx-parser")]
#[command(version = "0.1.0")]
#[command(version = "0.1.1")]
#[command(author = "Erik Vullings <[email protected]>")]
#[command(about = "Processes a DOCX file and outputs as Markdown or JSON", long_about = None)]
struct Cli {
Expand All @@ -17,7 +17,7 @@ struct Cli {
#[arg(short, long)]
output: Option<String>,

/// Sets the output format. Default is markdown. Options: md, json.
/// Sets the output format. Default is markdown. Options: md, json, and pretty_json.
#[arg(short, long)]
format: Option<String>,
}
Expand Down

0 comments on commit f7c9bfc

Please sign in to comment.