Skip to content

A fast, helpful, and open-source document parser

format

Logan Markewich9b5e873ddfcb
diff --git a/crates/liteparse/src/config.rs b/crates/liteparse/src/config.rs
index d47c9de..4e2badf 100644
--- a/crates/liteparse/src/config.rs
+++ b/crates/liteparse/src/config.rs
@@ -89,7 +89,10 @@ mod tests {
#[test]
fn test_parse_target_pages() {
- assert_eq!(parse_target_pages("1-5,10,15-20").unwrap(), vec![1, 2, 3, 4, 5, 10, 15, 16, 17, 18, 19, 20]);
+ assert_eq!(
+ parse_target_pages("1-5,10,15-20").unwrap(),
+ vec![1, 2, 3, 4, 5, 10, 15, 16, 17, 18, 19, 20]
+ );
assert_eq!(parse_target_pages("3").unwrap(), vec![3]);
assert_eq!(parse_target_pages("1,1,2").unwrap(), vec![1, 2]);
assert!(parse_target_pages("5-3").is_err());
diff --git a/crates/liteparse/src/conversion.rs b/crates/liteparse/src/conversion.rs
index 4e076ff..9d953dc 100644
--- a/crates/liteparse/src/conversion.rs
+++ b/crates/liteparse/src/conversion.rs
@@ -43,7 +43,10 @@ pub fn is_supported_extension(path: &str) -> bool {
///
/// Currently stubbed out — returns an error directing users to install
/// LibreOffice (for office documents) or ImageMagick (for images).
-pub fn convert_to_pdf(path: &str, _password: Option<&str>) -> Result<String, Box<dyn std::error::Error>> {
+pub fn convert_to_pdf(
+ path: &str,
+ _password: Option<&str>,
+) -> Result<String, Box<dyn std::error::Error>> {
let ext = Path::new(path)
.extension()
.and_then(|e| e.to_str())
diff --git a/crates/liteparse/src/main.rs b/crates/liteparse/src/main.rs
index 9b6d651..c10c4f7 100644
--- a/crates/liteparse/src/main.rs
+++ b/crates/liteparse/src/main.rs
@@ -6,7 +6,11 @@ use liteparse_rs::parser::LiteParse;
use liteparse_rs::render;
#[derive(Parser, Debug)]
-#[command(name = "lit", version, about = "OSS document parsing tool (supports PDF, DOCX, XLSX, images, and more)")]
+#[command(
+ name = "lit",
+ version,
+ about = "OSS document parsing tool (supports PDF, DOCX, XLSX, images, and more)"
+)]
struct Cli {
#[command(subcommand)]
command: Commands,
@@ -234,7 +238,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
render::screenshot(&cmd.file, page_number, cmd.dpi, &output_path)?;
if !cmd.quiet {
- eprintln!("[liteparse] screenshot page {} → {}", page_number, output_path);
+ eprintln!(
+ "[liteparse] screenshot page {} → {}",
+ page_number, output_path
+ );
}
}
}
@@ -243,7 +250,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let format = parse_output_format(&cmd.format)?;
let ext_filter = cmd.extension.as_ref().map(|e| {
let e = e.to_lowercase();
- if e.starts_with('.') { e } else { format!(".{}", e) }
+ if e.starts_with('.') {
+ e
+ } else {
+ format!(".{}", e)
+ }
});
let config = LiteParseConfig {
@@ -260,7 +271,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
};
let lp = LiteParse::new(config);
- let out_ext = if format == OutputFormat::Json { "json" } else { "txt" };
+ let out_ext = if format == OutputFormat::Json {
+ "json"
+ } else {
+ "txt"
+ };
std::fs::create_dir_all(&cmd.output_dir)?;
@@ -282,9 +297,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let t0 = std::time::Instant::now();
// Build output path: mirror directory structure
- let rel = file_path
- .strip_prefix(&cmd.input_dir)
- .unwrap_or(file_path);
+ let rel = file_path.strip_prefix(&cmd.input_dir).unwrap_or(file_path);
let out_path = std::path::Path::new(&cmd.output_dir)
.join(rel)
.with_extension(out_ext);
diff --git a/crates/liteparse/src/parser.rs b/crates/liteparse/src/parser.rs
index 594a0ee..455e507 100644
--- a/crates/liteparse/src/parser.rs
+++ b/crates/liteparse/src/parser.rs
@@ -1,4 +1,4 @@
-use crate::config::{parse_target_pages, LiteParseConfig, OutputFormat};
+use crate::config::{LiteParseConfig, OutputFormat, parse_target_pages};
use crate::conversion;
use crate::extract;
use crate::ocr::tesseract::TesseractOcrEngine;