Skip to content

A fast, helpful, and open-source document parser

enable publishing of rust package

Logan Markewich2b52e1f92a12
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 97e1179..a2ddcc0 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -32,9 +32,9 @@ jobs:
- name: Publish to crates.io
run: |
- cargo publish -p pdfium-sys --allow-dirty
- cargo publish -p pdfium --allow-dirty
- cargo publish -p liteparse-rs --allow-dirty
+ cargo publish -p liteparse-pdfium-sys --allow-dirty
+ cargo publish -p liteparse-pdfium --allow-dirty
+ cargo publish -p liteparse --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
diff --git a/Cargo.lock b/Cargo.lock
index b6ef3af..9515e21 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1164,15 +1164,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0"
[[package]]
-name = "liteparse-rs"
-version = "0.1.0"
+name = "liteparse"
+version = "2.0.0"
dependencies = [
"anyhow",
"clap",
"image",
"infer",
- "pdfium",
- "pdfium-sys",
+ "liteparse-pdfium",
+ "liteparse-pdfium-sys",
"reqwest 0.13.3",
"serde",
"serde_json",
@@ -1181,6 +1181,23 @@ dependencies = [
"tokio",
]
+[[package]]
+name = "liteparse-pdfium"
+version = "1.0.0"
+dependencies = [
+ "liteparse-pdfium-sys",
+]
+
+[[package]]
+name = "liteparse-pdfium-sys"
+version = "1.0.0"
+dependencies = [
+ "bindgen",
+ "flate2",
+ "tar",
+ "ureq",
+]
+
[[package]]
name = "lock_api"
version = "0.4.14"
@@ -1412,23 +1429,6 @@ dependencies = [
"hmac",
]
-[[package]]
-name = "pdfium"
-version = "0.1.0"
-dependencies = [
- "pdfium-sys",
-]
-
-[[package]]
-name = "pdfium-sys"
-version = "0.1.0"
-dependencies = [
- "bindgen",
- "flate2",
- "tar",
- "ureq",
-]
-
[[package]]
name = "percent-encoding"
version = "2.3.2"
diff --git a/Cargo.toml b/Cargo.toml
index 7ff6614..76d02d1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,3 +5,8 @@ members = [
"crates/pdfium",
"crates/liteparse",
]
+
+[workspace.package]
+edition = "2024"
+license = "Apache-2.0"
+repository = "https://github.com/run-llama/liteparse"
diff --git a/crates/liteparse/Cargo.toml b/crates/liteparse/Cargo.toml
index 3bc9b9b..7cb9388 100644
--- a/crates/liteparse/Cargo.toml
+++ b/crates/liteparse/Cargo.toml
@@ -1,22 +1,32 @@
[package]
name = "liteparse"
version = "2.0.0"
-edition = "2024"
+edition.workspace = true
+license.workspace = true
+repository.workspace = true
+description = "Fast, lightweight PDF and document parsing with spatial text extraction"
+
+[lib]
+name = "liteparse_rs"
[[bin]]
name = "lit"
path = "src/main.rs"
+[features]
+default = ["tesseract"]
+tesseract = ["dep:tesseract-rs"]
+
[dependencies]
anyhow = "1.0.102"
clap = { version = "4.5.55", features = ["derive"] }
image = { version = "0.25", default-features = false, features = ["png"] }
infer = "0.19.0"
-pdfium = { path = "../pdfium" }
-pdfium-sys = { path = "../pdfium-sys" }
+pdfium = { package = "liteparse-pdfium", version = "1.0.0", path = "../pdfium" }
+pdfium-sys = { package = "liteparse-pdfium-sys", version = "1.0.0", path = "../pdfium-sys" }
reqwest = { version = "0.13.3", features = ["blocking", "json", "form", "multipart"] }
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
tempfile = "3.27.0"
-tesseract-rs = { version = "0.2", features = ["build-tesseract"] }
+tesseract-rs = { version = "0.2", features = ["build-tesseract"], optional = true }
tokio = { version = "1.52.3", features = ["full"] }
diff --git a/crates/liteparse/src/ocr/mod.rs b/crates/liteparse/src/ocr/mod.rs
index 11c39a8..cc9d760 100644
--- a/crates/liteparse/src/ocr/mod.rs
+++ b/crates/liteparse/src/ocr/mod.rs
@@ -1,4 +1,5 @@
pub mod http_simple;
+#[cfg(feature = "tesseract")]
pub mod tesseract;
/// A single word-level OCR result with bounding box and confidence.
diff --git a/crates/liteparse/src/parser.rs b/crates/liteparse/src/parser.rs
index 6f67dae..f715f1d 100644
--- a/crates/liteparse/src/parser.rs
+++ b/crates/liteparse/src/parser.rs
@@ -3,6 +3,7 @@ use crate::conversion;
use crate::extract;
use crate::ocr::OcrEngine;
use crate::ocr::http_simple::HttpOcrEngine;
+#[cfg(feature = "tesseract")]
use crate::ocr::tesseract::TesseractOcrEngine;
use crate::ocr_merge;
use crate::output::{json, text};
@@ -71,12 +72,17 @@ impl LiteParse {
// OCR pass
if self.config.ocr_enabled {
- let engine: Box<dyn OcrEngine> = if self.config.ocr_server_url.is_none() {
- Box::new(TesseractOcrEngine::new(self.config.tessdata_path.clone()))
+ let engine: Box<dyn OcrEngine> = if let Some(ref url) = self.config.ocr_server_url {
+ Box::new(HttpOcrEngine::new(url.clone()))
} else {
- Box::new(HttpOcrEngine::new(
- self.config.ocr_server_url.clone().unwrap(),
- ))
+ #[cfg(feature = "tesseract")]
+ {
+ Box::new(TesseractOcrEngine::new(self.config.tessdata_path.clone()))
+ }
+ #[cfg(not(feature = "tesseract"))]
+ {
+ return Err("OCR enabled but no --ocr-server-url provided and tesseract feature is disabled".into());
+ }
};
ocr_merge::ocr_and_merge_pages(
&mut pages,
diff --git a/crates/pdfium-sys/Cargo.toml b/crates/pdfium-sys/Cargo.toml
index 18600ff..28c2b40 100644
--- a/crates/pdfium-sys/Cargo.toml
+++ b/crates/pdfium-sys/Cargo.toml
@@ -1,7 +1,10 @@
[package]
-name = "pdfium-sys"
-version = "0.1.0"
-edition = "2024"
+name = "liteparse-pdfium-sys"
+version = "1.0.0"
+edition.workspace = true
+license.workspace = true
+repository.workspace = true
+description = "Raw FFI bindings to PDFium for liteparse"
links = "pdfium"
[build-dependencies]
diff --git a/crates/pdfium/Cargo.toml b/crates/pdfium/Cargo.toml
index d04b7bd..61270bd 100644
--- a/crates/pdfium/Cargo.toml
+++ b/crates/pdfium/Cargo.toml
@@ -1,7 +1,10 @@
[package]
-name = "pdfium"
-version = "0.1.0"
-edition = "2024"
+name = "liteparse-pdfium"
+version = "1.0.0"
+edition.workspace = true
+license.workspace = true
+repository.workspace = true
+description = "Safe Rust wrapper around PDFium for liteparse"
[dependencies]
-pdfium-sys = { path = "../pdfium-sys" }
+pdfium-sys = { package = "liteparse-pdfium-sys", version = "1.0.0", path = "../pdfium-sys" }