Skip to content

A fast, helpful, and open-source document parser

more nits

Logan Markewich21211590ec18
diff --git a/README.md b/README.md
index c7fc119..e32bc8b 100644
--- a/README.md
+++ b/README.md
@@ -259,7 +259,7 @@ Parse results (Rust/Node/Python APIs) carry the document's `/Info` `creator`
and `producer` entries when present; these are API-only and never appear in
CLI JSON output. Enable `--extract-content-bounds` (Rust/Python
`extract_content_bounds`, JavaScript/WASM `extractContentBounds`) to add a
-per-page `content_bounds` — the union bbox of the page's top-level content
+per-page `content_bounds`: the union bbox of the page's top-level content
objects in viewport coords (absent for empty pages). Enable
`--extract-xfa-packets` (Rust/Python `extract_xfa_packets`, JavaScript/WASM
`extractXfaPackets`) to add `xfa_packets` with each raw XFA packet's index,
@@ -271,7 +271,7 @@ All of these are off by default, so default JSON output is unchanged.
Screenshots draw AcroForm field appearances (filled values, checkbox states)
on top of the page raster, so form data is visible in the render and to OCR.
Each screenshot result reports `is_solid_fill` (blank page after render), and
-with `detect_screenshot_rects` (Node `detectScreenshotRects`) also `rects` —
+with `detect_screenshot_rects` (Node `detectScreenshotRects`) also `rects`:
solid same-color rectangles and lines found in the raster in viewport coords,
which covers scanned/flattened pages that carry no vector paths.
diff --git a/crates/liteparse-napi/src/types.rs b/crates/liteparse-napi/src/types.rs
index 670986d..99b9002 100644
--- a/crates/liteparse-napi/src/types.rs
+++ b/crates/liteparse-napi/src/types.rs
@@ -45,7 +45,7 @@ pub struct JsLiteParseConfig {
/// Number of concurrent OCR workers (default: CPU cores - 1).
pub num_workers: Option<u32>,
/// How to surface raster images in markdown output: "off", "placeholder"
- /// (default — emits `![](img_pN_K.png)` references with no bytes), or
+ /// (default; emits `![](img_pN_K.png)` references with no bytes), or
/// "embed" (same presentation as placeholder; extraction is independent).
pub image_mode: Option<String>,
/// Extract embedded image bytes and metadata (default false).
diff --git a/crates/liteparse-wasm/src/lib.rs b/crates/liteparse-wasm/src/lib.rs
index 94b6759..482690a 100644
--- a/crates/liteparse-wasm/src/lib.rs
+++ b/crates/liteparse-wasm/src/lib.rs
@@ -302,7 +302,7 @@ pub struct TextItem {
pub confidence: Option<f32>,
/// Rotation in degrees (viewport space).
pub rotation: f32,
- // Rich text metadata — present only when `extractTextMetadata` is set.
+ // Rich text metadata; present only when `extractTextMetadata` is set.
#[serde(skip_serializing_if = "Option::is_none")]
pub font_height: Option<f32>,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -854,8 +854,8 @@ impl LiteParse {
.text_items
.iter()
.map(|i| {
- // Core-gated metadata view — the single source of
- // truth for which fields `extractTextMetadata` covers.
+ // Core-gated metadata view; `TextMetadata` defines
+ // which fields `extractTextMetadata` covers.
let meta = i.text_metadata(extract_text_metadata);
TextItem {
text: i.text.clone(),
diff --git a/crates/liteparse/src/config.rs b/crates/liteparse/src/config.rs
index 3c11f98..74e2699 100644
--- a/crates/liteparse/src/config.rs
+++ b/crates/liteparse/src/config.rs
@@ -55,7 +55,7 @@ pub struct LiteParseConfig {
/// Extract the tagged-PDF logical structure tree. Default `false`.
#[serde(default)]
pub extract_structure_tree: bool,
- /// Emit each page's `content_bounds` — the union bbox of its top-level
+ /// Emit each page's `content_bounds`: the union bbox of its top-level
/// content objects in viewport coords (visible content extent). Default
/// `false` to keep the default output shape unchanged. Content bounds are
/// still computed internally for the white-fill heuristic whenever
@@ -74,7 +74,7 @@ pub struct LiteParseConfig {
#[serde(default)]
pub detect_screenshot_rects: bool,
/// Draw AcroForm field appearances (filled values, checkbox states) into
- /// rendered rasters — screenshots and OCR inputs. This initializes a
+ /// rendered rasters (screenshots and OCR inputs). This initializes a
/// PDFium form-fill environment and runs the document's open/JS actions,
/// so it is off by default: plain parses should neither execute document
/// scripts nor change raster bytes for form-bearing PDFs.
@@ -152,7 +152,7 @@ pub struct CropBox {
/// where figures live in the document.
/// * `Embed` — emit the same references as `Placeholder`, and extract the
/// embedded pixel bytes into `ParseResult.images` (equivalent to setting
-/// `LiteParseConfig::extract_images`, which `Embed` predates).
+/// `LiteParseConfig::extract_images`).
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum ImageMode {
@@ -173,8 +173,8 @@ pub enum OutputFormat {
impl LiteParseConfig {
/// Whether embedded-image extraction should run. True when
/// `extract_images` is set, or when the legacy `ImageMode::Embed` is
- /// configured — `Embed` implied byte extraction before the two switches
- /// were decoupled, and existing callers rely on that.
+ /// configured (`Embed` implies byte extraction for backwards
+ /// compatibility).
pub fn effective_extract_images(&self) -> bool {
self.extract_images || self.image_mode == ImageMode::Embed
}
diff --git a/crates/liteparse/src/extract.rs b/crates/liteparse/src/extract.rs
index e099282..e67d39c 100644
--- a/crates/liteparse/src/extract.rs
+++ b/crates/liteparse/src/extract.rs
@@ -526,8 +526,8 @@ struct CachedImage {
}
/// Dedup key: hash of the source stream plus the metadata that affects
-/// decoding. The full raw bytes are still compared on lookup (hash prefilter,
-/// not trust-the-hash), but only within the matching bucket.
+/// decoding. The hash only prefilters; the full raw bytes are still compared
+/// on lookup within the matching bucket.
#[derive(PartialEq, Eq, Hash)]
struct CacheKey {
raw_hash: u64,
@@ -836,8 +836,8 @@ fn build_vector_graphics(paths: &[PathObject], content_bounds: Option<&Rect>) ->
.collect();
// LlamaParse collapses consecutively drawn, same-color solid fills when
- // one contains the other. Preserve order because intervening paint
- // operations intentionally stop merging.
+ // one contains the other. Preserve order: an intervening paint operation
+ // stops merging.
let mut keep = vec![true; raw_shapes.len()];
for i in 0..raw_shapes.len().saturating_sub(1) {
if !keep[i] || !mergeable_shape(&raw_shapes[i]) {
@@ -914,8 +914,8 @@ fn build_vector_graphics(paths: &[PathObject], content_bounds: Option<&Rect>) ->
/// Port of the LlamaParse extract binary's `PATH_FLAGS_WHITE_FILL` heuristic.
/// An unstroked solid-white fill is background paint when it is aligned to
-/// the page's content margin, or when it is drawn immediately after — and
-/// overlaps — another white-filled area (pdf writers often paint the
+/// the page's content margin, or when it is drawn immediately after and
+/// overlapping another white-filled area (pdf writers often paint the
/// background left-to-right, top-to-bottom as a run of adjacent fills).
/// Flagged shapes keep their bbox in `shapes` (still useful for chart /
/// spreadsheet layout detection) but contribute no line segments, which
diff --git a/crates/liteparse/src/output/json.rs b/crates/liteparse/src/output/json.rs
index 34fe2bb..01bd782 100644
--- a/crates/liteparse/src/output/json.rs
+++ b/crates/liteparse/src/output/json.rs
@@ -73,9 +73,9 @@ pub(crate) struct ParseResultJson {
pub image_error_count: u32,
#[serde(skip_serializing_if = "Option::is_none")]
pub form_type: Option<i32>,
- /// Raw XFA packets — present only when `extract_xfa_packets` was
+ /// Raw XFA packets, present only when `extract_xfa_packets` was
/// requested, so the default CLI JSON stays stable. The document's
- /// `/Info` creator/producer are deliberately API-only
+ /// `/Info` creator/producer are API-only
/// (`ParseResult.creator`/`.producer`) for the same reason.
#[serde(skip_serializing_if = "Option::is_none")]
pub xfa_packets: Option<Vec<XfaPacket>>,
@@ -128,8 +128,8 @@ pub(crate) fn build_json(pages: &[ParsedPage], extract_text_metadata: bool) -> P
width: item.width,
height: item.height,
// Not part of TextMetadata: the API surfaces always
- // expose rotation (it predates the metadata flag);
- // only the CLI JSON gates it to stay byte-stable.
+ // expose rotation; only the CLI JSON gates it to
+ // keep the default output byte-stable.
rotation: extract_text_metadata.then_some(item.rotation),
font_name: item.font_name.clone(),
font_size: item.font_size,
diff --git a/crates/liteparse/src/parser.rs b/crates/liteparse/src/parser.rs
index c221f38..a25a8a6 100644
--- a/crates/liteparse/src/parser.rs
+++ b/crates/liteparse/src/parser.rs
@@ -105,7 +105,7 @@ fn write_extracted_images(
/// canonical entry's file name. The markdown emitter references each figure
/// by its own placement id (`![](img_p2_1.jpg)`), but only the canonical
/// file is written to disk (see `write_extracted_images`), so duplicate
-/// placements must reference the canonical name — the same resolution the
+/// placements must reference the canonical name, matching the resolution the
/// LlamaParse worker applies via `resolveOutputImageName`.
fn rewrite_duplicate_image_refs(
pages: &mut [ParsedPage],
diff --git a/crates/liteparse/src/render.rs b/crates/liteparse/src/render.rs
index 3f46860..d8c961f 100644
--- a/crates/liteparse/src/render.rs
+++ b/crates/liteparse/src/render.rs
@@ -14,7 +14,7 @@ pub struct RenderedPage {
/// True when every pixel has the same color (blank page after render).
pub is_solid_fill: bool,
/// Solid rectangles/lines detected in the raster (viewport coords).
- /// Empty unless rect detection was requested — and always empty for
+ /// Empty unless rect detection was requested; also empty for
/// solid-fill pages, where detection is skipped.
pub rects: Vec<ScreenshotRect>,
}
@@ -123,7 +123,7 @@ fn rgb_at(rgba: &[u8], pixel_index: usize) -> u32 {
((rgba[base] as u32) << 16) | ((rgba[base + 1] as u32) << 8) | (rgba[base + 2] as u32)
}
-/// True when every pixel matches the first pixel's RGB (alpha ignored — the
+/// True when every pixel matches the first pixel's RGB (alpha ignored; the
/// render always starts from an opaque white fill).
pub(crate) fn is_solid_fill_rgba(rgba: &[u8], width: usize, height: usize) -> bool {
if width == 0 || height == 0 || rgba.len() < width * height * 4 {
diff --git a/crates/liteparse/src/types.rs b/crates/liteparse/src/types.rs
index a0c8a3c..aacaee4 100644
--- a/crates/liteparse/src/types.rs
+++ b/crates/liteparse/src/types.rs
@@ -88,11 +88,10 @@ pub struct TextItem {
}
/// The `TextItem` fields governed by `extract_text_metadata`, pre-gated by
-/// [`TextItem::text_metadata`]. This is the single source of truth for which
-/// fields count as rich text metadata: every output surface (CLI JSON, napi,
-/// python, wasm) builds its public items from this struct, so a new metadata
-/// field added here is a compile error in each surface until it is wired
-/// through — instead of a silent schema drift between bindings.
+/// [`TextItem::text_metadata`]. This struct defines which fields count as
+/// rich text metadata: every output surface (CLI JSON, napi, python, wasm)
+/// builds its public items from it, so a new metadata field added here is a
+/// compile error in each surface until it is wired through.
///
/// All fields are `Option`/slice so "extraction disabled" is representable
/// even for the plain-`bool` fields on `TextItem`: `None`/empty means the
@@ -235,7 +234,7 @@ pub struct StructureTree {
pub roots: Vec<StructureTreeElement>,
}
-/// One tagged-PDF structure element. Field names intentionally use the
+/// One tagged-PDF structure element. Field names follow the
/// repository's snake_case JSON convention rather than PDFium's C spellings.
#[derive(Debug, Clone, Serialize)]
pub struct StructureTreeElement {
@@ -319,8 +318,8 @@ pub struct ScreenshotRect {
pub height: f32,
/// Fill color as ARGB hex string (e.g. "ff1a2b3c").
pub color: String,
- /// True when only one dimension reaches the minimum rectangle size —
- /// a solid line rather than a filled area.
+ /// True when only one dimension reaches the minimum rectangle size
+ /// (a solid line rather than a filled area).
pub is_line: bool,
}
@@ -438,11 +437,11 @@ pub struct ImageRef {
}
/// A raster image extracted from a page along with its pixel bytes. Surfaced
-/// on `ParseResult.images` only when `extract_images` is enabled — otherwise
+/// on `ParseResult.images` only when `extract_images` is enabled; otherwise
/// the extraction step skips the render and only `ImageRef`s are
-/// produced. Other images are encoded as PNG from PDFium's rendered bitmap.
-/// JPEG streams are preserved without re-encoding when PDFium
-/// exposes a valid directly decoded DCT stream.
+/// produced. JPEG streams are preserved without re-encoding when PDFium
+/// exposes a valid directly decoded DCT stream; other images are encoded as
+/// PNG from PDFium's rendered bitmap.
#[derive(Debug, Clone, Serialize)]
pub struct ExtractedImage {
pub id: String,
diff --git a/packages/node/README.md b/packages/node/README.md
index 0052176..207c703 100644
--- a/packages/node/README.md
+++ b/packages/node/README.md
@@ -80,7 +80,7 @@ When `extractImages` is true, image extraction is enabled. `imageOutputDir` requ
that explicit opt-in and writes the extracted bytes to disk. Each
`result.images` entry includes its page bbox, intrinsic pixel dimensions, rotation,
format, `name`, and `path`. Valid source JPEGs are preserved, exact duplicates reuse
-one file, and JSON CLI output contains metadata only—never base64 image data.
+one file, and JSON CLI output contains metadata only (no base64 image data).
`imageMode` controls Markdown presentation only and does not imply extraction. With
`extractImages: false`, lightweight Markdown placement refs are still collected and
`result.images` stays empty.
@@ -100,7 +100,7 @@ title, typed attributes, MCIDs, children, and referenced link annotations. Untag
pages have an empty `roots` array; the field is omitted when disabled.
Every result also carries the document's `/Info` `creator`/`producer` when
-present (API-level only — not in CLI JSON), and with `extractContentBounds`
+present (API-level only, not in CLI JSON), and with `extractContentBounds`
each page carries a `contentBounds` union bbox of its top-level content
objects. With `extractXfaPackets`, `result.xfaPackets` lists each raw XFA
packet (index, name, content length, XML content); non-XFA documents yield an
diff --git a/packages/node/native.d.ts b/packages/node/native.d.ts
index 8e2a1c2..ad9ad0e 100644
--- a/packages/node/native.d.ts
+++ b/packages/node/native.d.ts
@@ -35,7 +35,7 @@ export interface JsLiteParseConfig {
numWorkers?: number
/**
* How to surface raster images in markdown output: "off", "placeholder"
- * (default — emits `![](img_pN_K.png)` references with no bytes), or
+ * (default; emits `![](img_pN_K.png)` references with no bytes), or
* "embed" (same presentation as placeholder; extraction is independent).
*/
imageMode?: string
diff --git a/packages/node/src/lib.ts b/packages/node/src/lib.ts
index 8fd2c9a..f28e902 100644
--- a/packages/node/src/lib.ts
+++ b/packages/node/src/lib.ts
@@ -50,7 +50,7 @@ export interface LiteParseConfig {
extractContentBounds: boolean;
/** Detect solid rectangles/lines in rendered page screenshots (default: false). */
detectScreenshotRects: boolean;
- /** Draw AcroForm field appearances into rendered rasters — screenshots and OCR inputs (runs document open/JS actions; default: false). */
+ /** Draw AcroForm field appearances into rendered rasters (screenshots and OCR inputs; runs document open/JS actions; default: false). */
renderFormFields: boolean;
preserveVerySmallText: boolean;
password?: string;
diff --git a/packages/python/README.md b/packages/python/README.md
index 12ba698..f34c240 100644
--- a/packages/python/README.md
+++ b/packages/python/README.md
@@ -76,7 +76,7 @@ When ``extract_images=True``, image extraction is enabled. ``image_output_dir``
requires that explicit opt-in and writes the extracted bytes to disk. Each
``result.images`` entry includes its page bbox, intrinsic pixel dimensions, rotation,
format, ``name``, and ``path``. Valid source JPEGs are preserved, exact duplicates
-reuse one file, and JSON CLI output contains metadata only—never base64 image data.
+reuse one file, and JSON CLI output contains metadata only (no base64 image data).
``image_mode`` controls Markdown presentation only and does not imply extraction.
With ``extract_images=False``, lightweight Markdown placement refs are still collected
and ``result.images`` stays empty.