Skip to content

A fast, helpful, and open-source document parser

rename + pptx

Logan Markewichcbf15c5ead09
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c185d6f..48cd7a7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -49,7 +49,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
- # Fonts: liteparse-docx layout tests need real font faces — 25 of
+ # Fonts: liteparse-ooxml layout tests need real font faces — 25 of
# them fail in a fontless environment (measurer, list_label,
# floating, build::block). Liberation + DejaVu is the set the musl
# test run validated; macOS/Windows runners ship system fonts.
diff --git a/.github/workflows/release-crates.yml b/.github/workflows/release-crates.yml
index e833374..08ca2c5 100644
--- a/.github/workflows/release-crates.yml
+++ b/.github/workflows/release-crates.yml
@@ -70,7 +70,7 @@ jobs:
# Must precede liteparse: it is a path dependency of the `docx-native`
# feature, and cargo refuses to publish a crate whose path deps are
# unpublished — optional or not.
- publish_if_new liteparse-docx
+ publish_if_new liteparse-ooxml
publish_if_new liteparse
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
diff --git a/Cargo.lock b/Cargo.lock
index 4072aa8..117ebd8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2047,7 +2047,7 @@ dependencies = [
"file-format",
"flate2",
"image",
- "liteparse-docx",
+ "liteparse-ooxml",
"liteparse-pdfium",
"liteparse-pdfium-sys",
"lopdf",
@@ -2071,7 +2071,23 @@ dependencies = [
]
[[package]]
-name = "liteparse-docx"
+name = "liteparse-napi"
+version = "2.11.0"
+dependencies = [
+ "image",
+ "liteparse",
+ "liteparse-pdfium",
+ "liteparse-pdfium-sys",
+ "napi",
+ "napi-build",
+ "napi-derive",
+ "serde",
+ "serde_json",
+ "tokio",
+]
+
+[[package]]
+name = "liteparse-ooxml"
version = "0.1.0"
dependencies = [
"bitflags 2.13.1",
@@ -2091,22 +2107,6 @@ dependencies = [
"zip",
]
-[[package]]
-name = "liteparse-napi"
-version = "2.11.0"
-dependencies = [
- "image",
- "liteparse",
- "liteparse-pdfium",
- "liteparse-pdfium-sys",
- "napi",
- "napi-build",
- "napi-derive",
- "serde",
- "serde_json",
- "tokio",
-]
-
[[package]]
name = "liteparse-pdfium"
version = "1.5.0"
diff --git a/Cargo.toml b/Cargo.toml
index a221706..9e558b3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,7 +4,7 @@ members = [
"crates/pdfium-sys",
"crates/pdfium",
"crates/liteparse",
- "crates/liteparse-docx",
+ "crates/liteparse-ooxml",
"crates/liteparse-napi",
"crates/liteparse-python",
"crates/liteparse-wasm",
diff --git a/crates/liteparse-docx/ATTRIBUTION.md b/crates/liteparse-ooxml/ATTRIBUTION.md
similarity index 99%
rename from crates/liteparse-docx/ATTRIBUTION.md
rename to crates/liteparse-ooxml/ATTRIBUTION.md
index 631bd78..1966eef 100644
--- a/crates/liteparse-docx/ATTRIBUTION.md
+++ b/crates/liteparse-ooxml/ATTRIBUTION.md
@@ -170,8 +170,8 @@ dropped as a numbering id, but must still never be coerced to `1`).
### Verifying
```
-cargo test -p liteparse-docx
-cargo build -p liteparse-docx --example parse_probe
+cargo test -p liteparse-ooxml
+cargo build -p liteparse-ooxml --example parse_probe
python3 bench/docx_native_spike/fuzz_attribute_values.py --mode all
```
diff --git a/crates/liteparse-docx/Cargo.toml b/crates/liteparse-ooxml/Cargo.toml
similarity index 92%
rename from crates/liteparse-docx/Cargo.toml
rename to crates/liteparse-ooxml/Cargo.toml
index c9ae531..a1b33c6 100644
--- a/crates/liteparse-docx/Cargo.toml
+++ b/crates/liteparse-ooxml/Cargo.toml
@@ -1,10 +1,10 @@
[package]
-name = "liteparse-docx"
+name = "liteparse-ooxml"
version = "0.1.0"
edition.workspace = true
license = "MIT"
repository.workspace = true
-description = "Native DOCX structure reader (vendored Skia-free subset of dxpdf)"
+description = "Native OOXML structure reader (vendored Skia-free subset of dxpdf)"
publish = true
[dependencies]
diff --git a/crates/liteparse-docx/LICENSE b/crates/liteparse-ooxml/LICENSE
similarity index 100%
rename from crates/liteparse-docx/LICENSE
rename to crates/liteparse-ooxml/LICENSE
diff --git a/crates/liteparse-docx/examples/layout_probe.rs b/crates/liteparse-ooxml/examples/layout_probe.rs
similarity index 94%
rename from crates/liteparse-docx/examples/layout_probe.rs
rename to crates/liteparse-ooxml/examples/layout_probe.rs
index 3ac8505..d333f85 100644
--- a/crates/liteparse-docx/examples/layout_probe.rs
+++ b/crates/liteparse-ooxml/examples/layout_probe.rs
@@ -1,6 +1,6 @@
//! Layout probe — the vendored (fontdb + skrifa) twin of spike 2's harness.
//!
-//! Taps `liteparse_docx::render::resolve_and_layout` and emits the same JSON
+//! Taps `liteparse_ooxml::render::resolve_and_layout` and emits the same JSON
//! Lines shape as `bench/docx_layout_spike` (which runs upstream dxpdf with
//! Skia), so the two joins directly: same document in, page counts and
//! command censuses out, one row per file. Divergence between the two is the
@@ -8,13 +8,13 @@
//! ~0 where the host has the fonts.
//!
//! ```text
-//! cargo run --release -p liteparse-docx --example layout_probe -- <file.docx>...
+//! cargo run --release -p liteparse-ooxml --example layout_probe -- <file.docx>...
//! ```
use std::time::Instant;
-use liteparse_docx::render::layout::draw_command::DrawCommand;
-use liteparse_docx::render::resolve_and_layout;
+use liteparse_ooxml::render::layout::draw_command::DrawCommand;
+use liteparse_ooxml::render::resolve_and_layout;
use serde_json::json;
/// Running min/max over text positions, so we can check the coordinate
@@ -80,7 +80,7 @@ fn run_one(path: &str) -> serde_json::Value {
// The vendored parser is fail-open (unknown elements, attribute values
// and namespace collisions degrade instead of aborting), so parse
// failures here are unexpected — report them loudly.
- let doc = match liteparse_docx::docx::parse(&data) {
+ let doc = match liteparse_ooxml::docx::parse(&data) {
Ok(d) => d,
Err(e) => {
return json!({ "path": path, "ok": false, "stage": "parse", "error": e.to_string() });
diff --git a/crates/liteparse-docx/examples/parse_probe.rs b/crates/liteparse-ooxml/examples/parse_probe.rs
similarity index 80%
rename from crates/liteparse-docx/examples/parse_probe.rs
rename to crates/liteparse-ooxml/examples/parse_probe.rs
index 8b0e419..157d2c3 100644
--- a/crates/liteparse-docx/examples/parse_probe.rs
+++ b/crates/liteparse-ooxml/examples/parse_probe.rs
@@ -1,7 +1,7 @@
fn main() {
for path in std::env::args().skip(1) {
let bytes = std::fs::read(&path).unwrap();
- match liteparse_docx::docx::parse(&bytes) {
+ match liteparse_ooxml::docx::parse(&bytes) {
Ok(_) => println!("OK {path}"),
Err(e) => println!("FAIL {path}: {e}"),
}
diff --git a/crates/liteparse-docx/src/docx/error.rs b/crates/liteparse-ooxml/src/docx/error.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/error.rs
rename to crates/liteparse-ooxml/src/docx/error.rs
diff --git a/crates/liteparse-docx/src/docx/mod.rs b/crates/liteparse-ooxml/src/docx/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/mod.rs
rename to crates/liteparse-ooxml/src/docx/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/body.rs b/crates/liteparse-ooxml/src/docx/parse/body.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/body.rs
rename to crates/liteparse-ooxml/src/docx/parse/body.rs
diff --git a/crates/liteparse-docx/src/docx/parse/body_schema.rs b/crates/liteparse-ooxml/src/docx/parse/body_schema.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/body_schema.rs
rename to crates/liteparse-ooxml/src/docx/parse/body_schema.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/mod.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/mod.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/anchor.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/anchor.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/anchor.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/anchor.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/color.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/color.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/color.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/color.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/effect.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/effect.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/effect.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/effect.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/fill.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/fill.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/fill.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/fill.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/geometry.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/geometry.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/geometry.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/geometry.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/mod.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/mod.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/picture.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/picture.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/picture.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/picture.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/shape.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/shape.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/shape.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/shape.rs
diff --git a/crates/liteparse-docx/src/docx/parse/drawing/schema/stroke.rs b/crates/liteparse-ooxml/src/docx/parse/drawing/schema/stroke.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/drawing/schema/stroke.rs
rename to crates/liteparse-ooxml/src/docx/parse/drawing/schema/stroke.rs
diff --git a/crates/liteparse-docx/src/docx/parse/fonts.rs b/crates/liteparse-ooxml/src/docx/parse/fonts.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/fonts.rs
rename to crates/liteparse-ooxml/src/docx/parse/fonts.rs
diff --git a/crates/liteparse-docx/src/docx/parse/mod.rs b/crates/liteparse-ooxml/src/docx/parse/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/mod.rs
rename to crates/liteparse-ooxml/src/docx/parse/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/notes.rs b/crates/liteparse-ooxml/src/docx/parse/notes.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/notes.rs
rename to crates/liteparse-ooxml/src/docx/parse/notes.rs
diff --git a/crates/liteparse-docx/src/docx/parse/numbering.rs b/crates/liteparse-ooxml/src/docx/parse/numbering.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/numbering.rs
rename to crates/liteparse-ooxml/src/docx/parse/numbering.rs
diff --git a/crates/liteparse-docx/src/docx/parse/primitives/colors.rs b/crates/liteparse-ooxml/src/docx/parse/primitives/colors.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/primitives/colors.rs
rename to crates/liteparse-ooxml/src/docx/parse/primitives/colors.rs
diff --git a/crates/liteparse-docx/src/docx/parse/primitives/integer_measure.rs b/crates/liteparse-ooxml/src/docx/parse/primitives/integer_measure.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/primitives/integer_measure.rs
rename to crates/liteparse-ooxml/src/docx/parse/primitives/integer_measure.rs
diff --git a/crates/liteparse-docx/src/docx/parse/primitives/lenient.rs b/crates/liteparse-ooxml/src/docx/parse/primitives/lenient.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/primitives/lenient.rs
rename to crates/liteparse-ooxml/src/docx/parse/primitives/lenient.rs
diff --git a/crates/liteparse-docx/src/docx/parse/primitives/mod.rs b/crates/liteparse-ooxml/src/docx/parse/primitives/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/primitives/mod.rs
rename to crates/liteparse-ooxml/src/docx/parse/primitives/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/primitives/st_enums.rs b/crates/liteparse-ooxml/src/docx/parse/primitives/st_enums.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/primitives/st_enums.rs
rename to crates/liteparse-ooxml/src/docx/parse/primitives/st_enums.rs
diff --git a/crates/liteparse-docx/src/docx/parse/primitives/toggles.rs b/crates/liteparse-ooxml/src/docx/parse/primitives/toggles.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/primitives/toggles.rs
rename to crates/liteparse-ooxml/src/docx/parse/primitives/toggles.rs
diff --git a/crates/liteparse-docx/src/docx/parse/primitives/units.rs b/crates/liteparse-ooxml/src/docx/parse/primitives/units.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/primitives/units.rs
rename to crates/liteparse-ooxml/src/docx/parse/primitives/units.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/mod.rs b/crates/liteparse-ooxml/src/docx/parse/properties/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/mod.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/border.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/border.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/border.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/border.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/cnf_style.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/cnf_style.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/cnf_style.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/cnf_style.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/fonts.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/fonts.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/fonts.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/fonts.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/insets.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/insets.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/insets.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/insets.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/lang.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/lang.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/lang.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/lang.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/measure.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/measure.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/measure.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/measure.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/mod.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/mod.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/paragraph.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/paragraph.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/paragraph.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/paragraph.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/run.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/run.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/run.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/run.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/section.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/section.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/section.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/section.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/shading.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/shading.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/shading.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/shading.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/table.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/table.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/table.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/table.rs
diff --git a/crates/liteparse-docx/src/docx/parse/properties/schema/tabs.rs b/crates/liteparse-ooxml/src/docx/parse/properties/schema/tabs.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/properties/schema/tabs.rs
rename to crates/liteparse-ooxml/src/docx/parse/properties/schema/tabs.rs
diff --git a/crates/liteparse-docx/src/docx/parse/rel_rewrite.rs b/crates/liteparse-ooxml/src/docx/parse/rel_rewrite.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/rel_rewrite.rs
rename to crates/liteparse-ooxml/src/docx/parse/rel_rewrite.rs
diff --git a/crates/liteparse-docx/src/docx/parse/serde_xml.rs b/crates/liteparse-ooxml/src/docx/parse/serde_xml.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/serde_xml.rs
rename to crates/liteparse-ooxml/src/docx/parse/serde_xml.rs
diff --git a/crates/liteparse-docx/src/docx/parse/settings.rs b/crates/liteparse-ooxml/src/docx/parse/settings.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/settings.rs
rename to crates/liteparse-ooxml/src/docx/parse/settings.rs
diff --git a/crates/liteparse-docx/src/docx/parse/styles.rs b/crates/liteparse-ooxml/src/docx/parse/styles.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/styles.rs
rename to crates/liteparse-ooxml/src/docx/parse/styles.rs
diff --git a/crates/liteparse-docx/src/docx/parse/theme/mod.rs b/crates/liteparse-ooxml/src/docx/parse/theme/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/theme/mod.rs
rename to crates/liteparse-ooxml/src/docx/parse/theme/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/theme/script.rs b/crates/liteparse-ooxml/src/docx/parse/theme/script.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/theme/script.rs
rename to crates/liteparse-ooxml/src/docx/parse/theme/script.rs
diff --git a/crates/liteparse-docx/src/docx/parse/vml/color.rs b/crates/liteparse-ooxml/src/docx/parse/vml/color.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/vml/color.rs
rename to crates/liteparse-ooxml/src/docx/parse/vml/color.rs
diff --git a/crates/liteparse-docx/src/docx/parse/vml/formulas.rs b/crates/liteparse-ooxml/src/docx/parse/vml/formulas.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/vml/formulas.rs
rename to crates/liteparse-ooxml/src/docx/parse/vml/formulas.rs
diff --git a/crates/liteparse-docx/src/docx/parse/vml/mod.rs b/crates/liteparse-ooxml/src/docx/parse/vml/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/vml/mod.rs
rename to crates/liteparse-ooxml/src/docx/parse/vml/mod.rs
diff --git a/crates/liteparse-docx/src/docx/parse/vml/path_commands.rs b/crates/liteparse-ooxml/src/docx/parse/vml/path_commands.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/vml/path_commands.rs
rename to crates/liteparse-ooxml/src/docx/parse/vml/path_commands.rs
diff --git a/crates/liteparse-docx/src/docx/parse/vml/schema.rs b/crates/liteparse-ooxml/src/docx/parse/vml/schema.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/vml/schema.rs
rename to crates/liteparse-ooxml/src/docx/parse/vml/schema.rs
diff --git a/crates/liteparse-docx/src/docx/parse/vml/style.rs b/crates/liteparse-ooxml/src/docx/parse/vml/style.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/parse/vml/style.rs
rename to crates/liteparse-ooxml/src/docx/parse/vml/style.rs
diff --git a/crates/liteparse-docx/src/docx/relationships.rs b/crates/liteparse-ooxml/src/docx/relationships.rs
similarity index 89%
rename from crates/liteparse-docx/src/docx/relationships.rs
rename to crates/liteparse-ooxml/src/docx/relationships.rs
index 7adf310..0842e62 100644
--- a/crates/liteparse-docx/src/docx/relationships.rs
+++ b/crates/liteparse-ooxml/src/docx/relationships.rs
@@ -61,6 +61,18 @@ pub enum RelationshipType {
StylesWithEffects,
/// §11.3.8: glossary/building blocks document.
GlossaryDocument,
+ /// §13.3.8: a slide (PresentationML).
+ Slide,
+ /// §13.3.9: a slide layout (PresentationML).
+ SlideLayout,
+ /// §13.3.10: a slide master (PresentationML).
+ SlideMaster,
+ /// §13.3.5: a notes slide (PresentationML).
+ NotesSlide,
+ /// §13.3.4: the notes master (PresentationML).
+ NotesMaster,
+ /// §13.3.3: the handout master (PresentationML).
+ HandoutMaster,
/// Any relationship type not listed above.
Unknown(String),
}
@@ -110,6 +122,22 @@ impl RelationshipType {
Self::StylesWithEffects
} else if uri.ends_with("/glossaryDocument") {
Self::GlossaryDocument
+ // PresentationML (§13.3). Order is not load-bearing here — no PPTX
+ // type is a `/`-suffix of another (`/notesSlide` does not end with
+ // `/slide`, `/slideLayout` does not end with `/slide`) — but keep the
+ // longer names first anyway so a future addition cannot shadow.
+ } else if uri.ends_with("/slideLayout") {
+ Self::SlideLayout
+ } else if uri.ends_with("/slideMaster") {
+ Self::SlideMaster
+ } else if uri.ends_with("/notesSlide") {
+ Self::NotesSlide
+ } else if uri.ends_with("/notesMaster") {
+ Self::NotesMaster
+ } else if uri.ends_with("/handoutMaster") {
+ Self::HandoutMaster
+ } else if uri.ends_with("/slide") {
+ Self::Slide
} else {
warn!("unknown relationship type: {}", uri);
Self::Unknown(uri.to_string())
diff --git a/crates/liteparse-docx/src/docx/whitespace_workaround.rs b/crates/liteparse-ooxml/src/docx/whitespace_workaround.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/whitespace_workaround.rs
rename to crates/liteparse-ooxml/src/docx/whitespace_workaround.rs
diff --git a/crates/liteparse-docx/src/docx/zip.rs b/crates/liteparse-ooxml/src/docx/zip.rs
similarity index 100%
rename from crates/liteparse-docx/src/docx/zip.rs
rename to crates/liteparse-ooxml/src/docx/zip.rs
diff --git a/crates/liteparse-docx/src/error.rs b/crates/liteparse-ooxml/src/error.rs
similarity index 100%
rename from crates/liteparse-docx/src/error.rs
rename to crates/liteparse-ooxml/src/error.rs
diff --git a/crates/liteparse-docx/src/field/ast.rs b/crates/liteparse-ooxml/src/field/ast.rs
similarity index 100%
rename from crates/liteparse-docx/src/field/ast.rs
rename to crates/liteparse-ooxml/src/field/ast.rs
diff --git a/crates/liteparse-docx/src/field/context.rs b/crates/liteparse-ooxml/src/field/context.rs
similarity index 100%
rename from crates/liteparse-docx/src/field/context.rs
rename to crates/liteparse-ooxml/src/field/context.rs
diff --git a/crates/liteparse-docx/src/field/error.rs b/crates/liteparse-ooxml/src/field/error.rs
similarity index 100%
rename from crates/liteparse-docx/src/field/error.rs
rename to crates/liteparse-ooxml/src/field/error.rs
diff --git a/crates/liteparse-docx/src/field/eval.rs b/crates/liteparse-ooxml/src/field/eval.rs
similarity index 100%
rename from crates/liteparse-docx/src/field/eval.rs
rename to crates/liteparse-ooxml/src/field/eval.rs
diff --git a/crates/liteparse-docx/src/field/format.rs b/crates/liteparse-ooxml/src/field/format.rs
similarity index 100%
rename from crates/liteparse-docx/src/field/format.rs
rename to crates/liteparse-ooxml/src/field/format.rs
diff --git a/crates/liteparse-docx/src/field/mod.rs b/crates/liteparse-ooxml/src/field/mod.rs
similarity index 95%
rename from crates/liteparse-docx/src/field/mod.rs
rename to crates/liteparse-ooxml/src/field/mod.rs
index c26264d..a6565e9 100644
--- a/crates/liteparse-docx/src/field/mod.rs
+++ b/crates/liteparse-ooxml/src/field/mod.rs
@@ -6,7 +6,7 @@
//! # Examples
//!
//! ```
-//! use liteparse_docx::field::{parse, evaluate, FieldContext};
+//! use liteparse_ooxml::field::{parse, evaluate, FieldContext};
//!
//! // Parse a PAGE field
//! let instr = parse(" PAGE ").unwrap();
diff --git a/crates/liteparse-docx/src/field/parse.rs b/crates/liteparse-ooxml/src/field/parse.rs
similarity index 100%
rename from crates/liteparse-docx/src/field/parse.rs
rename to crates/liteparse-ooxml/src/field/parse.rs
diff --git a/crates/liteparse-docx/src/field/switches.rs b/crates/liteparse-ooxml/src/field/switches.rs
similarity index 100%
rename from crates/liteparse-docx/src/field/switches.rs
rename to crates/liteparse-ooxml/src/field/switches.rs
diff --git a/crates/liteparse-docx/src/lib.rs b/crates/liteparse-ooxml/src/lib.rs
similarity index 61%
rename from crates/liteparse-docx/src/lib.rs
rename to crates/liteparse-ooxml/src/lib.rs
index d88a529..52d6a36 100644
--- a/crates/liteparse-docx/src/lib.rs
+++ b/crates/liteparse-ooxml/src/lib.rs
@@ -1,10 +1,15 @@
-//! Native DOCX structure reader.
+//! Native OOXML structure reader.
//!
//! Vendored, Skia-free subset of [dxpdf](https://github.com/nerdy-pro/dxpdf)
//! 0.4.0 (MIT — see `LICENSE` and `ATTRIBUTION.md`). Upstream is a DOCX→PDF
//! engine; this crate keeps only `parse → resolve`, which is where the
//! document's *structure* lives, and drops the Skia-bound layout/paint half.
//!
+//! Named `-ooxml` rather than `-docx` because much of the vendored code is
+//! format-neutral OOXML — ZIP packaging, relationships, DrawingML, theme,
+//! line breaking, measurement — and is shared with the PPTX reader landing
+//! alongside it. `docx` is the DOCX entry point.
+//!
//! The whole point is that a DOCX already states, explicitly, everything the
//! LibreOffice→PDF→projection path has to reverse-engineer from coordinates:
//! heading levels (`outlineLvl`), list numbering (including `startOverride`),
@@ -12,15 +17,16 @@
//!
//! ```no_run
//! let bytes = std::fs::read("report.docx")?;
-//! let doc = liteparse_docx::docx::parse(&bytes)?;
-//! let resolved = liteparse_docx::render::resolve::resolve(doc);
-//! # Ok::<(), liteparse_docx::Error>(())
+//! let doc = liteparse_ooxml::docx::parse(&bytes)?;
+//! let resolved = liteparse_ooxml::render::resolve::resolve(doc);
+//! # Ok::<(), liteparse_ooxml::Error>(())
//! ```
pub mod docx;
pub mod error;
pub mod field;
pub mod model;
+pub mod pptx;
pub mod render;
pub use error::Error;
diff --git a/crates/liteparse-docx/src/model/dimension.rs b/crates/liteparse-ooxml/src/model/dimension.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/dimension.rs
rename to crates/liteparse-ooxml/src/model/dimension.rs
diff --git a/crates/liteparse-docx/src/model/geometry.rs b/crates/liteparse-ooxml/src/model/geometry.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/geometry.rs
rename to crates/liteparse-ooxml/src/model/geometry.rs
diff --git a/crates/liteparse-docx/src/model/mod.rs b/crates/liteparse-ooxml/src/model/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/mod.rs
rename to crates/liteparse-ooxml/src/model/mod.rs
diff --git a/crates/liteparse-docx/src/model/types/color.rs b/crates/liteparse-ooxml/src/model/types/color.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/color.rs
rename to crates/liteparse-ooxml/src/model/types/color.rs
diff --git a/crates/liteparse-docx/src/model/types/content.rs b/crates/liteparse-ooxml/src/model/types/content.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/content.rs
rename to crates/liteparse-ooxml/src/model/types/content.rs
diff --git a/crates/liteparse-docx/src/model/types/document.rs b/crates/liteparse-ooxml/src/model/types/document.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/document.rs
rename to crates/liteparse-ooxml/src/model/types/document.rs
diff --git a/crates/liteparse-docx/src/model/types/drawing.rs b/crates/liteparse-ooxml/src/model/types/drawing.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/drawing.rs
rename to crates/liteparse-ooxml/src/model/types/drawing.rs
diff --git a/crates/liteparse-docx/src/model/types/drawing_color.rs b/crates/liteparse-ooxml/src/model/types/drawing_color.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/drawing_color.rs
rename to crates/liteparse-ooxml/src/model/types/drawing_color.rs
diff --git a/crates/liteparse-docx/src/model/types/formatting.rs b/crates/liteparse-ooxml/src/model/types/formatting.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/formatting.rs
rename to crates/liteparse-ooxml/src/model/types/formatting.rs
diff --git a/crates/liteparse-docx/src/model/types/identifiers.rs b/crates/liteparse-ooxml/src/model/types/identifiers.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/identifiers.rs
rename to crates/liteparse-ooxml/src/model/types/identifiers.rs
diff --git a/crates/liteparse-docx/src/model/types/mod.rs b/crates/liteparse-ooxml/src/model/types/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/mod.rs
rename to crates/liteparse-ooxml/src/model/types/mod.rs
diff --git a/crates/liteparse-docx/src/model/types/numbering.rs b/crates/liteparse-ooxml/src/model/types/numbering.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/numbering.rs
rename to crates/liteparse-ooxml/src/model/types/numbering.rs
diff --git a/crates/liteparse-docx/src/model/types/paragraph.rs b/crates/liteparse-ooxml/src/model/types/paragraph.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/paragraph.rs
rename to crates/liteparse-ooxml/src/model/types/paragraph.rs
diff --git a/crates/liteparse-docx/src/model/types/run_properties.rs b/crates/liteparse-ooxml/src/model/types/run_properties.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/run_properties.rs
rename to crates/liteparse-ooxml/src/model/types/run_properties.rs
diff --git a/crates/liteparse-docx/src/model/types/section.rs b/crates/liteparse-ooxml/src/model/types/section.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/section.rs
rename to crates/liteparse-ooxml/src/model/types/section.rs
diff --git a/crates/liteparse-docx/src/model/types/settings.rs b/crates/liteparse-ooxml/src/model/types/settings.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/settings.rs
rename to crates/liteparse-ooxml/src/model/types/settings.rs
diff --git a/crates/liteparse-docx/src/model/types/styles.rs b/crates/liteparse-ooxml/src/model/types/styles.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/styles.rs
rename to crates/liteparse-ooxml/src/model/types/styles.rs
diff --git a/crates/liteparse-docx/src/model/types/table.rs b/crates/liteparse-ooxml/src/model/types/table.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/table.rs
rename to crates/liteparse-ooxml/src/model/types/table.rs
diff --git a/crates/liteparse-docx/src/model/types/theme.rs b/crates/liteparse-ooxml/src/model/types/theme.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/theme.rs
rename to crates/liteparse-ooxml/src/model/types/theme.rs
diff --git a/crates/liteparse-docx/src/model/types/vml.rs b/crates/liteparse-ooxml/src/model/types/vml.rs
similarity index 100%
rename from crates/liteparse-docx/src/model/types/vml.rs
rename to crates/liteparse-ooxml/src/model/types/vml.rs
diff --git a/crates/liteparse-ooxml/src/pptx/mod.rs b/crates/liteparse-ooxml/src/pptx/mod.rs
new file mode 100644
index 0000000..1fa2563
--- /dev/null
+++ b/crates/liteparse-ooxml/src/pptx/mod.rs
@@ -0,0 +1,15 @@
+//! Native PresentationML (`.pptx`) reader.
+//!
+//! Shares the OOXML packaging, relationships, DrawingML schema, theme,
+//! measurement and line-breaking layers with [`crate::docx`] — see
+//! `ATTRIBUTION.md` for what is vendored and what is ours.
+//!
+//! Unlike DOCX, PPTX **carries its own geometry**: every shape declares
+//! `<a:off>`/`<a:ext>` in EMU against a fixed `<p:sldSz>`. So the hard part
+//! here is not layout, it is the placeholder cascade — a shape that omits
+//! `<a:xfrm>` inherits position and size from its layout, which inherits
+//! from its master, and the match rule differs at each rung.
+
+pub mod package;
+
+pub use package::{EMU_PER_POINT, Part, PresentationInfo, PresentationPackage, SlideParts, walk};
diff --git a/crates/liteparse-ooxml/src/pptx/package.rs b/crates/liteparse-ooxml/src/pptx/package.rs
new file mode 100644
index 0000000..3364c57
--- /dev/null
+++ b/crates/liteparse-ooxml/src/pptx/package.rs
@@ -0,0 +1,427 @@
+//! PresentationML package walk: `ppt/presentation.xml` → ordered slides,
+//! each joined to its layout, master and notes part.
+//!
+//! This stage is deliberately *byte-level*. It resolves the part graph and
+//! hands back raw XML plus the relationships needed to resolve `r:embed` /
+//! `r:id` references later. Nothing here understands a shape. Keeping the
+//! graph walk separate from the schema layer is what makes it testable
+//! against a corpus without a working reader.
+//!
+//! Everything it stands on — [`PackageContents`], [`resolve_target`],
+//! [`rels_path_for`], [`Relationships`] — is the OOXML packaging layer
+//! vendored for DOCX, reused here unchanged. Only [`RelationshipType`]'s
+//! PresentationML variants were added.
+
+use crate::docx::error::{ParseError, Result};
+use crate::docx::relationships::{RelationshipType, Relationships};
+use crate::docx::zip::{PackageContents, part_directory, rels_path_for, resolve_target};
+
+/// EMU per point (§20.1.2.1: 914400 EMU per inch, 72 pt per inch).
+pub const EMU_PER_POINT: f64 = 12700.0;
+
+/// The presentation-level facts every slide is laid out against.
+#[derive(Clone, Debug)]
+pub struct PresentationInfo {
+ /// `<p:sldSz>` in EMU. Every slide in a deck shares one size.
+ pub slide_width_emu: i64,
+ pub slide_height_emu: i64,
+ /// `<p:notesSz>` in EMU, when declared.
+ pub notes_width_emu: Option<i64>,
+ pub notes_height_emu: Option<i64>,
+}
+
+impl PresentationInfo {
+ /// Slide size in points, the unit the layout engine and `TextItem` use.
+ pub fn slide_size_pt(&self) -> (f64, f64) {
+ (
+ self.slide_width_emu as f64 / EMU_PER_POINT,
+ self.slide_height_emu as f64 / EMU_PER_POINT,
+ )
+ }
+}
+
+/// One part's raw bytes plus the relationships declared *by that part*.
+///
+/// The rels travel with the bytes because `r:id` values are scoped to the
+/// part that uses them: a slide's `rId2` and its layout's `rId2` are
+/// unrelated. Resolving an image or hyperlink requires knowing which part
+/// the reference came from.
+#[derive(Clone, Debug)]
+pub struct Part {
+ /// Package-normalized path (lowercased, no leading `/`).
+ pub path: String,
+ pub xml: Vec<u8>,
+ pub rels: Relationships,
+}
+
+impl Part {
+ /// Resolve an `r:id` declared by this part to an absolute package path.
+ ///
+ /// Returns `None` for external targets (hyperlinks), which have no part.
+ pub fn resolve_rel(&self, rel_id: &str) -> Option<String> {
+ let rel = self.rels.find_by_id(rel_id)?;
+ if rel.target_mode == crate::docx::relationships::TargetMode::External {
+ return None;
+ }
+ Some(resolve_target(part_directory(&self.path), &rel.target))
+ }
+}
+
+/// A slide joined to the parts it inherits from.
+///
+/// `layout` and `master` are `Option` because the cascade must degrade
+/// rather than fail: a slide with no reachable layout still has its own
+/// directly-applied text and geometry, and refusing to parse it would be
+/// the fail-closed behaviour this vendor has already had to retire four
+/// times (see `ATTRIBUTION.md`).
+#[derive(Clone, Debug)]
+pub struct SlideParts {
+ pub slide: Part,
+ pub layout: Option<Part>,
+ pub master: Option<Part>,
+ pub notes: Option<Part>,
+}
+
+/// The whole deck, walked but not yet understood.
+///
+/// Deliberately neither `Clone` nor `Debug`: it owns every media part, so a
+/// clone copies the whole deck's images (390 MB across the corpus) and a
+/// debug-print dumps them.
+pub struct PresentationPackage {
+ pub info: PresentationInfo,
+ /// Slides in **presentation order** — `<p:sldIdLst>`, not part order.
+ pub slides: Vec<SlideParts>,
+ /// `ppt/theme/themeN.xml` for the first master, when present.
+ pub theme: Option<Vec<u8>>,
+ /// The notes master, shared by every notes slide.
+ pub notes_master: Option<Part>,
+ /// Raw media parts, keyed by normalized package path.
+ pub package: PackageContents,
+}
+
+/// Walk a `.pptx` container into its part graph.
+pub fn walk(data: &[u8]) -> Result<PresentationPackage> {
+ let package = PackageContents::from_bytes(data)?;
+
+ // The presentation part is reached through the package root rels rather
+ // than assumed to be `ppt/presentation.xml`. The path is conventional,
+ // not mandated, and the 9 docProps-less decks in the corpus are already
+ // proof that "every producer follows convention" is a bad bet.
+ let root_rels = load_rels(&package, "");
+ let pres_path = root_rels
+ .find_by_type(&RelationshipType::OfficeDocument)
+ .map(|r| resolve_target("", &r.target))
+ .unwrap_or_else(|| "ppt/presentation.xml".to_string());
+
+ let pres_xml = package
+ .get_part(&pres_path)
+ .ok_or_else(|| ParseError::MissingPart(pres_path.clone()))?
+ .to_vec();
+ let pres_rels = load_rels(&package, &pres_path);
+ let pres = Part {
+ path: pres_path,
+ xml: pres_xml,
+ rels: pres_rels,
+ };
+
+ let parsed = parse_presentation(&pres.xml)?;
+ let info = PresentationInfo {
+ // §19.2.1.39 makes sldSz optional in schema terms; default to 4:3
+ // (9144000 × 6858000 EMU) rather than error, so a malformed deck
+ // still yields text at a plausible scale.
+ slide_width_emu: parsed.slide_size.map_or(9_144_000, |s| s.0),
+ slide_height_emu: parsed.slide_size.map_or(6_858_000, |s| s.1),
+ notes_width_emu: parsed.notes_size.map(|s| s.0),
+ notes_height_emu: parsed.notes_size.map(|s| s.1),
+ };
+
+ let notes_master = pres
+ .resolve_rel_of_type(&RelationshipType::NotesMaster)
+ .and_then(|p| load_part(&package, &p));
+
+ let mut slides = Vec::new();
+ for rel_id in parsed.slide_rel_ids {
+ // Order is driven by sldIdLst. Part names are NOT a valid ordering:
+ // `slide10.xml` sorts before `slide2.xml` lexically, and hidden or
+ // deleted slides leave gaps in the numbering.
+ let Some(path) = pres.resolve_rel(&rel_id) else {
+ log::warn!("slide r:id {} does not resolve to a part", rel_id);
+ continue;
+ };
+ let Some(slide) = load_part(&package, &path) else {
+ log::warn!("slide part missing: {}", path);
+ continue;
+ };
+
+ let layout = slide
+ .resolve_rel_of_type(&RelationshipType::SlideLayout)
+ .and_then(|p| load_part(&package, &p));
+ // The master hangs off the *layout*, not the slide — a slide has no
+ // direct master relationship.
+ let master = layout
+ .as_ref()
+ .and_then(|l| l.resolve_rel_of_type(&RelationshipType::SlideMaster))
+ .and_then(|p| load_part(&package, &p));
+ let notes = slide
+ .resolve_rel_of_type(&RelationshipType::NotesSlide)
+ .and_then(|p| load_part(&package, &p));
+
+ slides.push(SlideParts {
+ slide,
+ layout,
+ master,
+ notes,
+ });
+ }
+
+ // Theme comes off the first master. Decks with multiple masters can
+ // carry multiple themes; resolving per-master is a colour-fidelity
+ // concern deferred until `phClr` substitution lands.
+ let theme = slides
+ .iter()
+ .find_map(|s| s.master.as_ref())
+ .and_then(|m| m.resolve_rel_of_type(&RelationshipType::Theme))
+ .and_then(|p| package.get_part(&p).map(|b| b.to_vec()));
+
+ Ok(PresentationPackage {
+ info,
+ slides,
+ theme,
+ notes_master,
+ package,
+ })
+}
+
+impl Part {
+ fn resolve_rel_of_type(&self, ty: &RelationshipType) -> Option<String> {
+ let rel = self.rels.find_by_type(ty)?;
+ Some(resolve_target(part_directory(&self.path), &rel.target))
+ }
+}
+
+/// Load a part plus its own `.rels`. A part with no `.rels` file is normal
+/// (most layouts have one, many slides do not), so an absent rels file
+/// yields an empty set rather than an error.
+fn load_part(package: &PackageContents, path: &str) -> Option<Part> {
+ let xml = package.get_part(path)?.to_vec();
+ let rels = load_rels(package, path);
+ Some(Part {
+ path: path.to_string(),
+ xml,
+ rels,
+ })
+}
+
+fn load_rels(package: &PackageContents, part_path: &str) -> Relationships {
+ let rels_path = if part_path.is_empty() {
+ "_rels/.rels".to_string()
+ } else {
+ rels_path_for(part_path)
+ };
+ package
+ .get_part(&rels_path)
+ .and_then(|b| match Relationships::parse(b) {
+ Ok(r) => Some(r),
+ Err(e) => {
+ // A malformed rels part costs us image/hyperlink/layout
+ // resolution for one part, not the deck.
+ log::warn!("failed to parse {}: {}", rels_path, e);
+ None
+ }
+ })
+ .unwrap_or_default()
+}
+
+// ---------------------------------------------------------------------------
+// The presentation part is parsed by hand, NOT with serde. This is the one
+// place in the vendor that departs from the serde-schema convention, and the
+// reason is a hard limitation rather than taste:
+//
+// quick-xml's serde layer matches attributes on their **local name with the
+// namespace prefix dropped** (the same property `serde_xml.rs` documents for
+// *elements*). `<p:sldId id="322" r:id="rId2"/>` therefore presents two
+// attributes both named `id`, and deserializing it fails with
+// `duplicate field @id` — which is exactly what the corpus reported, 45/45.
+//
+// There is no serde spelling that distinguishes them: `#[serde(rename =
+// "@r:id")]` never matches because the prefix is already gone, and
+// `alias = "@id"` would bind the *numeric slide id* to the relationship id —
+// silent corruption, the class `ATTRIBUTION.md` records as this vendor's
+// recurring trap. (`blip@r:embed` gets away with its alias only because no
+// competing `@embed` exists on that element.)
+//
+// So the r:id-bearing lists are read with a namespace-aware reader that
+// compares the *qualified* name. The presentation part is small and flat, so
+// the cost is ~50 lines and it stays confined to this module.
+//
+// The same collision exists on `p:sldMasterId` and `p:sldLayoutId`; anything
+// added later that reads those must come through here, not through serde.
+// ---------------------------------------------------------------------------
+
+#[derive(Default)]
+struct PresentationXml {
+ slide_rel_ids: Vec<String>,
+ slide_size: Option<(i64, i64)>,
+ notes_size: Option<(i64, i64)>,
+}
+
+fn parse_presentation(data: &[u8]) -> Result<PresentationXml> {
+ use quick_xml::Reader;
+ use quick_xml::events::Event;
+
+ let mut reader = Reader::from_reader(data);
+ let mut out = PresentationXml::default();
+ let mut buf = Vec::new();
+ // `sldId` also appears inside `<p:custShowLst>`, whose entries point at
+ // slides already listed in sldIdLst. Tracking the enclosing list keeps a
+ // custom show from duplicating or reordering the deck.
+ let mut in_slide_id_lst = false;
+
+ loop {
+ let ev = reader
+ .read_event_into(&mut buf)
+ .map_err(quick_xml::DeError::from)?;
+ match ev {
+ Event::Eof => break,
+ Event::Start(ref e) | Event::Empty(ref e) => match local_name(e.name().as_ref()) {
+ b"sldIdLst" => in_slide_id_lst = !matches!(ev, Event::Empty(_)),
+ b"sldId" if in_slide_id_lst => {
+ if let Some(id) = qualified_attr(e, b"r:id") {
+ out.slide_rel_ids.push(id);
+ } else {
+ log::warn!("p:sldId without r:id; slide skipped");
+ }
+ }
+ b"sldSz" => out.slide_size = size_attrs(e),
+ b"notesSz" => out.notes_size = size_attrs(e),
+ _ => {}
+ },
+ Event::End(ref e) => {
+ if local_name(e.name().as_ref()) == b"sldIdLst" {
+ in_slide_id_lst = false;
+ }
+ }
+ _ => {}
+ }
+ buf.clear();
+ }
+ Ok(out)
+}
+
+/// Strip a namespace prefix from a qualified name (`p:sldId` → `sldId`).
+fn local_name(qname: &[u8]) -> &[u8] {
+ match qname.iter().position(|&b| b == b':') {
+ Some(i) => &qname[i + 1..],
+ None => qname,
+ }
+}
+
+/// Read an attribute by its **qualified** name, so `r:id` and `id` stay
+/// distinct. Malformed attributes are skipped rather than fatal, matching
+/// the fail-open posture of `docx/parse/primitives/lenient.rs`.
+fn qualified_attr(e: &quick_xml::events::BytesStart<'_>, want: &[u8]) -> Option<String> {
+ e.attributes().flatten().find_map(|a| {
+ (a.key.as_ref() == want).then(|| String::from_utf8_lossy(&a.value).into_owned())
+ })
+}
+
+fn size_attrs(e: &quick_xml::events::BytesStart<'_>) -> Option<(i64, i64)> {
+ let cx = qualified_attr(e, b"cx")?.parse().ok()?;
+ let cy = qualified_attr(e, b"cy")?.parse().ok()?;
+ Some((cx, cy))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ const PRES: &str = r#"<?xml version="1.0"?>
+<p:presentation xmlns:p="p" xmlns:r="r">
+ <p:sldMasterIdLst><p:sldMasterId id="2147483660" r:id="rId1"/></p:sldMasterIdLst>
+ <p:sldIdLst>
+ <p:sldId id="322" r:id="rId2"/>
+ <p:sldId id="260" r:id="rId3"/>
+ </p:sldIdLst>
+ <p:sldSz cx="12192000" cy="6858000"/>
+ <p:notesSz cx="6858000" cy="9144000"/>
+</p:presentation>"#;
+
+ /// The regression this module exists for. `p:sldId` carries both `@id`
+ /// and `@r:id`; quick-xml's serde layer drops namespace prefixes on
+ /// attributes, so a serde schema sees `duplicate field @id` and the
+ /// whole deck fails to parse (observed: 45/45 of the corpus).
+ ///
+ /// Two things must hold, and the second is the one that matters: the
+ /// r:id must be read, AND the numeric `@id` must never stand in for it.
+ #[test]
+ fn slide_ids_read_r_id_not_the_numeric_id() {
+ let p = parse_presentation(PRES.as_bytes()).unwrap();
+ assert_eq!(p.slide_rel_ids, vec!["rId2", "rId3"]);
+ // If `@id` ever leaks into this list, resolution silently yields no
+ // part and the deck comes out empty rather than erroring.
+ assert!(!p.slide_rel_ids.iter().any(|s| s == "322" || s == "260"));
+ }
+
+ /// The master list has the same `@id`/`@r:id` shape and sits directly
+ /// above sldIdLst. Its entries must not be mistaken for slides.
+ #[test]
+ fn master_ids_do_not_leak_into_the_slide_list() {
+ let p = parse_presentation(PRES.as_bytes()).unwrap();
+ assert_eq!(p.slide_rel_ids.len(), 2);
+ assert!(!p.slide_rel_ids.iter().any(|s| s == "rId1"));
+ }
+
+ /// A custom show references slides already in sldIdLst; counting its
+ /// entries would duplicate and reorder the deck.
+ #[test]
+ fn custom_show_slide_ids_are_ignored() {
+ let xml = r#"<p:presentation xmlns:p="p" xmlns:r="r">
+ <p:sldIdLst><p:sldId id="1" r:id="rId2"/></p:sldIdLst>
+ <p:custShowLst><p:custShow name="s" id="0"><p:sldLst>
+ <p:sldId id="1" r:id="rId2"/><p:sldId id="1" r:id="rId2"/>
+ </p:sldLst></p:custShow></p:custShowLst>
+</p:presentation>"#;
+ assert_eq!(
+ parse_presentation(xml.as_bytes()).unwrap().slide_rel_ids,
+ vec!["rId2"]
+ );
+ }
+
+ #[test]
+ fn sizes_are_read_and_converted() {
+ let p = parse_presentation(PRES.as_bytes()).unwrap();
+ assert_eq!(p.slide_size, Some((12_192_000, 6_858_000)));
+ assert_eq!(p.notes_size, Some((6_858_000, 9_144_000)));
+ let info = PresentationInfo {
+ slide_width_emu: 12_192_000,
+ slide_height_emu: 6_858_000,
+ notes_width_emu: None,
+ notes_height_emu: None,
+ };
+ // 12192000 / 12700 = 960 pt, the 16:9 widescreen default.
+ assert_eq!(info.slide_size_pt(), (960.0, 540.0));
+ }
+
+ /// A deck with no `sldSz` still parses, at a plausible scale, rather
+ /// than erroring — the fail-open posture the rest of the vendor uses.
+ #[test]
+ fn missing_slide_size_falls_back_rather_than_failing() {
+ let xml = r#"<p:presentation xmlns:p="p" xmlns:r="r"><p:sldIdLst/></p:presentation>"#;
+ let p = parse_presentation(xml.as_bytes()).unwrap();
+ assert_eq!(p.slide_size, None);
+ assert!(p.slide_rel_ids.is_empty());
+ }
+
+ /// An `sldId` missing its r:id is skipped, not fatal, and does not
+ /// shift the positions of the slides around it.
+ #[test]
+ fn slide_without_rel_id_is_skipped() {
+ let xml = r#"<p:presentation xmlns:p="p" xmlns:r="r"><p:sldIdLst>
+ <p:sldId id="1" r:id="rId2"/><p:sldId id="2"/><p:sldId id="3" r:id="rId4"/>
+</p:sldIdLst></p:presentation>"#;
+ assert_eq!(
+ parse_presentation(xml.as_bytes()).unwrap().slide_rel_ids,
+ vec!["rId2", "rId4"]
+ );
+ }
+}
diff --git a/crates/liteparse-docx/src/render/dimension.rs b/crates/liteparse-ooxml/src/render/dimension.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/dimension.rs
rename to crates/liteparse-ooxml/src/render/dimension.rs
diff --git a/crates/liteparse-docx/src/render/emoji/cluster.rs b/crates/liteparse-ooxml/src/render/emoji/cluster.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/emoji/cluster.rs
rename to crates/liteparse-ooxml/src/render/emoji/cluster.rs
diff --git a/crates/liteparse-docx/src/render/emoji/mod.rs b/crates/liteparse-ooxml/src/render/emoji/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/emoji/mod.rs
rename to crates/liteparse-ooxml/src/render/emoji/mod.rs
diff --git a/crates/liteparse-docx/src/render/emoji/resolve.rs b/crates/liteparse-ooxml/src/render/emoji/resolve.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/emoji/resolve.rs
rename to crates/liteparse-ooxml/src/render/emoji/resolve.rs
diff --git a/crates/liteparse-docx/src/render/error.rs b/crates/liteparse-ooxml/src/render/error.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/error.rs
rename to crates/liteparse-ooxml/src/render/error.rs
diff --git a/crates/liteparse-docx/src/render/fonts.rs b/crates/liteparse-ooxml/src/render/fonts.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/fonts.rs
rename to crates/liteparse-ooxml/src/render/fonts.rs
diff --git a/crates/liteparse-docx/src/render/geometry.rs b/crates/liteparse-ooxml/src/render/geometry.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/geometry.rs
rename to crates/liteparse-ooxml/src/render/geometry.rs
diff --git a/crates/liteparse-docx/src/render/layout/build/block.rs b/crates/liteparse-ooxml/src/render/layout/build/block.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/build/block.rs
rename to crates/liteparse-ooxml/src/render/layout/build/block.rs
diff --git a/crates/liteparse-docx/src/render/layout/build/convert.rs b/crates/liteparse-ooxml/src/render/layout/build/convert.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/build/convert.rs
rename to crates/liteparse-ooxml/src/render/layout/build/convert.rs
diff --git a/crates/liteparse-docx/src/render/layout/build/floating.rs b/crates/liteparse-ooxml/src/render/layout/build/floating.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/build/floating.rs
rename to crates/liteparse-ooxml/src/render/layout/build/floating.rs
diff --git a/crates/liteparse-docx/src/render/layout/build/list_label.rs b/crates/liteparse-ooxml/src/render/layout/build/list_label.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/build/list_label.rs
rename to crates/liteparse-ooxml/src/render/layout/build/list_label.rs
diff --git a/crates/liteparse-docx/src/render/layout/build/mod.rs b/crates/liteparse-ooxml/src/render/layout/build/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/build/mod.rs
rename to crates/liteparse-ooxml/src/render/layout/build/mod.rs
diff --git a/crates/liteparse-docx/src/render/layout/build/table.rs b/crates/liteparse-ooxml/src/render/layout/build/table.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/build/table.rs
rename to crates/liteparse-ooxml/src/render/layout/build/table.rs
diff --git a/crates/liteparse-docx/src/render/layout/cell.rs b/crates/liteparse-ooxml/src/render/layout/cell.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/cell.rs
rename to crates/liteparse-ooxml/src/render/layout/cell.rs
diff --git a/crates/liteparse-docx/src/render/layout/draw_command.rs b/crates/liteparse-ooxml/src/render/layout/draw_command.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/draw_command.rs
rename to crates/liteparse-ooxml/src/render/layout/draw_command.rs
diff --git a/crates/liteparse-docx/src/render/layout/float.rs b/crates/liteparse-ooxml/src/render/layout/float.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/float.rs
rename to crates/liteparse-ooxml/src/render/layout/float.rs
diff --git a/crates/liteparse-docx/src/render/layout/fragment/collect.rs b/crates/liteparse-ooxml/src/render/layout/fragment/collect.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/fragment/collect.rs
rename to crates/liteparse-ooxml/src/render/layout/fragment/collect.rs
diff --git a/crates/liteparse-docx/src/render/layout/fragment/mod.rs b/crates/liteparse-ooxml/src/render/layout/fragment/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/fragment/mod.rs
rename to crates/liteparse-ooxml/src/render/layout/fragment/mod.rs
diff --git a/crates/liteparse-docx/src/render/layout/fragment/segment.rs b/crates/liteparse-ooxml/src/render/layout/fragment/segment.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/fragment/segment.rs
rename to crates/liteparse-ooxml/src/render/layout/fragment/segment.rs
diff --git a/crates/liteparse-docx/src/render/layout/fragment/split.rs b/crates/liteparse-ooxml/src/render/layout/fragment/split.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/fragment/split.rs
rename to crates/liteparse-ooxml/src/render/layout/fragment/split.rs
diff --git a/crates/liteparse-docx/src/render/layout/fragment/text.rs b/crates/liteparse-ooxml/src/render/layout/fragment/text.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/fragment/text.rs
rename to crates/liteparse-ooxml/src/render/layout/fragment/text.rs
diff --git a/crates/liteparse-docx/src/render/layout/header_footer.rs b/crates/liteparse-ooxml/src/render/layout/header_footer.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/header_footer.rs
rename to crates/liteparse-ooxml/src/render/layout/header_footer.rs
diff --git a/crates/liteparse-docx/src/render/layout/line.rs b/crates/liteparse-ooxml/src/render/layout/line.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/line.rs
rename to crates/liteparse-ooxml/src/render/layout/line.rs
diff --git a/crates/liteparse-docx/src/render/layout/measurer.rs b/crates/liteparse-ooxml/src/render/layout/measurer.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/measurer.rs
rename to crates/liteparse-ooxml/src/render/layout/measurer.rs
diff --git a/crates/liteparse-docx/src/render/layout/mod.rs b/crates/liteparse-ooxml/src/render/layout/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/mod.rs
rename to crates/liteparse-ooxml/src/render/layout/mod.rs
diff --git a/crates/liteparse-docx/src/render/layout/page.rs b/crates/liteparse-ooxml/src/render/layout/page.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/page.rs
rename to crates/liteparse-ooxml/src/render/layout/page.rs
diff --git a/crates/liteparse-docx/src/render/layout/paragraph/borders.rs b/crates/liteparse-ooxml/src/render/layout/paragraph/borders.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/paragraph/borders.rs
rename to crates/liteparse-ooxml/src/render/layout/paragraph/borders.rs
diff --git a/crates/liteparse-docx/src/render/layout/paragraph/line_emit.rs b/crates/liteparse-ooxml/src/render/layout/paragraph/line_emit.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/paragraph/line_emit.rs
rename to crates/liteparse-ooxml/src/render/layout/paragraph/line_emit.rs
diff --git a/crates/liteparse-docx/src/render/layout/paragraph/mod.rs b/crates/liteparse-ooxml/src/render/layout/paragraph/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/paragraph/mod.rs
rename to crates/liteparse-ooxml/src/render/layout/paragraph/mod.rs
diff --git a/crates/liteparse-docx/src/render/layout/paragraph/types.rs b/crates/liteparse-ooxml/src/render/layout/paragraph/types.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/paragraph/types.rs
rename to crates/liteparse-ooxml/src/render/layout/paragraph/types.rs
diff --git a/crates/liteparse-docx/src/render/layout/section/floating_table.rs b/crates/liteparse-ooxml/src/render/layout/section/floating_table.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/section/floating_table.rs
rename to crates/liteparse-ooxml/src/render/layout/section/floating_table.rs
diff --git a/crates/liteparse-docx/src/render/layout/section/helpers.rs b/crates/liteparse-ooxml/src/render/layout/section/helpers.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/section/helpers.rs
rename to crates/liteparse-ooxml/src/render/layout/section/helpers.rs
diff --git a/crates/liteparse-docx/src/render/layout/section/layout.rs b/crates/liteparse-ooxml/src/render/layout/section/layout.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/section/layout.rs
rename to crates/liteparse-ooxml/src/render/layout/section/layout.rs
diff --git a/crates/liteparse-docx/src/render/layout/section/mod.rs b/crates/liteparse-ooxml/src/render/layout/section/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/section/mod.rs
rename to crates/liteparse-ooxml/src/render/layout/section/mod.rs
diff --git a/crates/liteparse-docx/src/render/layout/section/stacker.rs b/crates/liteparse-ooxml/src/render/layout/section/stacker.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/section/stacker.rs
rename to crates/liteparse-ooxml/src/render/layout/section/stacker.rs
diff --git a/crates/liteparse-docx/src/render/layout/section/types.rs b/crates/liteparse-ooxml/src/render/layout/section/types.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/section/types.rs
rename to crates/liteparse-ooxml/src/render/layout/section/types.rs
diff --git a/crates/liteparse-docx/src/render/layout/table/borders.rs b/crates/liteparse-ooxml/src/render/layout/table/borders.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/table/borders.rs
rename to crates/liteparse-ooxml/src/render/layout/table/borders.rs
diff --git a/crates/liteparse-docx/src/render/layout/table/emit.rs b/crates/liteparse-ooxml/src/render/layout/table/emit.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/table/emit.rs
rename to crates/liteparse-ooxml/src/render/layout/table/emit.rs
diff --git a/crates/liteparse-docx/src/render/layout/table/grid.rs b/crates/liteparse-ooxml/src/render/layout/table/grid.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/table/grid.rs
rename to crates/liteparse-ooxml/src/render/layout/table/grid.rs
diff --git a/crates/liteparse-docx/src/render/layout/table/measure.rs b/crates/liteparse-ooxml/src/render/layout/table/measure.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/table/measure.rs
rename to crates/liteparse-ooxml/src/render/layout/table/measure.rs
diff --git a/crates/liteparse-docx/src/render/layout/table/mod.rs b/crates/liteparse-ooxml/src/render/layout/table/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/table/mod.rs
rename to crates/liteparse-ooxml/src/render/layout/table/mod.rs
diff --git a/crates/liteparse-docx/src/render/layout/table/split.rs b/crates/liteparse-ooxml/src/render/layout/table/split.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/table/split.rs
rename to crates/liteparse-ooxml/src/render/layout/table/split.rs
diff --git a/crates/liteparse-docx/src/render/layout/table/types.rs b/crates/liteparse-ooxml/src/render/layout/table/types.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/layout/table/types.rs
rename to crates/liteparse-ooxml/src/render/layout/table/types.rs
diff --git a/crates/liteparse-docx/src/render/mod.rs b/crates/liteparse-ooxml/src/render/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/mod.rs
rename to crates/liteparse-ooxml/src/render/mod.rs
diff --git a/crates/liteparse-docx/src/render/raster.rs b/crates/liteparse-ooxml/src/render/raster.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/raster.rs
rename to crates/liteparse-ooxml/src/render/raster.rs
diff --git a/crates/liteparse-docx/src/render/resolve/color.rs b/crates/liteparse-ooxml/src/render/resolve/color.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/color.rs
rename to crates/liteparse-ooxml/src/render/resolve/color.rs
diff --git a/crates/liteparse-docx/src/render/resolve/conditional.rs b/crates/liteparse-ooxml/src/render/resolve/conditional.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/conditional.rs
rename to crates/liteparse-ooxml/src/render/resolve/conditional.rs
diff --git a/crates/liteparse-docx/src/render/resolve/drawing_color.rs b/crates/liteparse-ooxml/src/render/resolve/drawing_color.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/drawing_color.rs
rename to crates/liteparse-ooxml/src/render/resolve/drawing_color.rs
diff --git a/crates/liteparse-docx/src/render/resolve/fonts.rs b/crates/liteparse-ooxml/src/render/resolve/fonts.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/fonts.rs
rename to crates/liteparse-ooxml/src/render/resolve/fonts.rs
diff --git a/crates/liteparse-docx/src/render/resolve/header_footer.rs b/crates/liteparse-ooxml/src/render/resolve/header_footer.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/header_footer.rs
rename to crates/liteparse-ooxml/src/render/resolve/header_footer.rs
diff --git a/crates/liteparse-docx/src/render/resolve/images.rs b/crates/liteparse-ooxml/src/render/resolve/images.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/images.rs
rename to crates/liteparse-ooxml/src/render/resolve/images.rs
diff --git a/crates/liteparse-docx/src/render/resolve/locale.rs b/crates/liteparse-ooxml/src/render/resolve/locale.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/locale.rs
rename to crates/liteparse-ooxml/src/render/resolve/locale.rs
diff --git a/crates/liteparse-docx/src/render/resolve/mod.rs b/crates/liteparse-ooxml/src/render/resolve/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/mod.rs
rename to crates/liteparse-ooxml/src/render/resolve/mod.rs
diff --git a/crates/liteparse-docx/src/render/resolve/numbering.rs b/crates/liteparse-ooxml/src/render/resolve/numbering.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/numbering.rs
rename to crates/liteparse-ooxml/src/render/resolve/numbering.rs
diff --git a/crates/liteparse-docx/src/render/resolve/properties.rs b/crates/liteparse-ooxml/src/render/resolve/properties.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/properties.rs
rename to crates/liteparse-ooxml/src/render/resolve/properties.rs
diff --git a/crates/liteparse-docx/src/render/resolve/sections.rs b/crates/liteparse-ooxml/src/render/resolve/sections.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/sections.rs
rename to crates/liteparse-ooxml/src/render/resolve/sections.rs
diff --git a/crates/liteparse-docx/src/render/resolve/shape_geometry/custom.rs b/crates/liteparse-ooxml/src/render/resolve/shape_geometry/custom.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/shape_geometry/custom.rs
rename to crates/liteparse-ooxml/src/render/resolve/shape_geometry/custom.rs
diff --git a/crates/liteparse-docx/src/render/resolve/shape_geometry/guides.rs b/crates/liteparse-ooxml/src/render/resolve/shape_geometry/guides.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/shape_geometry/guides.rs
rename to crates/liteparse-ooxml/src/render/resolve/shape_geometry/guides.rs
diff --git a/crates/liteparse-docx/src/render/resolve/shape_geometry/mod.rs b/crates/liteparse-ooxml/src/render/resolve/shape_geometry/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/shape_geometry/mod.rs
rename to crates/liteparse-ooxml/src/render/resolve/shape_geometry/mod.rs
diff --git a/crates/liteparse-docx/src/render/resolve/shape_geometry/presets/line.rs b/crates/liteparse-ooxml/src/render/resolve/shape_geometry/presets/line.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/shape_geometry/presets/line.rs
rename to crates/liteparse-ooxml/src/render/resolve/shape_geometry/presets/line.rs
diff --git a/crates/liteparse-docx/src/render/resolve/shape_geometry/presets/mod.rs b/crates/liteparse-ooxml/src/render/resolve/shape_geometry/presets/mod.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/shape_geometry/presets/mod.rs
rename to crates/liteparse-ooxml/src/render/resolve/shape_geometry/presets/mod.rs
diff --git a/crates/liteparse-docx/src/render/resolve/shape_geometry/presets/rect.rs b/crates/liteparse-ooxml/src/render/resolve/shape_geometry/presets/rect.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/shape_geometry/presets/rect.rs
rename to crates/liteparse-ooxml/src/render/resolve/shape_geometry/presets/rect.rs
diff --git a/crates/liteparse-docx/src/render/resolve/shape_visuals.rs b/crates/liteparse-ooxml/src/render/resolve/shape_visuals.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/shape_visuals.rs
rename to crates/liteparse-ooxml/src/render/resolve/shape_visuals.rs
diff --git a/crates/liteparse-docx/src/render/resolve/styles.rs b/crates/liteparse-ooxml/src/render/resolve/styles.rs
similarity index 100%
rename from crates/liteparse-docx/src/render/resolve/styles.rs
rename to crates/liteparse-ooxml/src/render/resolve/styles.rs
diff --git a/crates/liteparse/Cargo.toml b/crates/liteparse/Cargo.toml
index e575716..5b95cbb 100644
--- a/crates/liteparse/Cargo.toml
+++ b/crates/liteparse/Cargo.toml
@@ -30,13 +30,13 @@ oar-ocr-webgpu = ["oar-ocr", "oar-ocr/webgpu"]
oar-ocr-openvino = ["oar-ocr", "oar-ocr/openvino"]
tesseract = ["dep:tesseract-rs"]
# Native DOCX structure reading (no LibreOffice, no projection).
-docx-native = ["dep:liteparse-docx", "liteparse-docx/raster"]
+docx-native = ["dep:liteparse-ooxml", "liteparse-ooxml/raster"]
[dependencies]
blake3 = "1"
clap = { version = "4.5.55", features = ["derive"] }
file-format = { version = "0.29.0", features = ["reader"] }
-liteparse-docx = { version = "0.1.0", path = "../liteparse-docx", optional = true }
+liteparse-ooxml = { version = "0.1.0", path = "../liteparse-ooxml", optional = true }
image = { version = "0.25", default-features = false, features = ["default-formats"] }
memchr = "2"
ordered-float = "5.3.0"
diff --git a/crates/liteparse/src/office/docx.rs b/crates/liteparse/src/office/docx.rs
index 56647d6..a7e25bf 100644
--- a/crates/liteparse/src/office/docx.rs
+++ b/crates/liteparse/src/office/docx.rs
@@ -1,4 +1,4 @@
-//! DOCX → [`Block`] using only `liteparse-docx`'s `parse` + `resolve` stages.
+//! DOCX → [`Block`] using only `liteparse-ooxml`'s `parse` + `resolve` stages.
//!
//! Deliberately avoids the vendored crate's `render::layout` stage: structure
//! alone — headings, lists, emphasis, merged cells, notes — is recoverable
@@ -12,13 +12,13 @@
use std::collections::{HashMap, VecDeque};
-use liteparse_docx::field::FieldInstruction;
-use liteparse_docx::model::{
+use liteparse_ooxml::field::FieldInstruction;
+use liteparse_ooxml::model::{
Block as DocxBlock, HyperlinkTarget, Inline, NoteId, NumId, NumberFormat, OutlineLevel,
Paragraph, ParagraphProperties, RunElement, RunProperties, StrikeStyle, StyleId, Table,
VerticalMerge,
};
-use liteparse_docx::render::resolve::ResolvedDocument;
+use liteparse_ooxml::render::resolve::ResolvedDocument;
use crate::error::LiteParseError;
use crate::markdown_layout::{Block, Cell, apply_link, escape_inline};
@@ -51,9 +51,9 @@ pub struct EmitOptions {
/// fail-open on unknown elements, unknown attribute values and malformed
/// scalars, so a document with unmodeled markup still yields blocks.
pub fn docx_to_blocks(data: &[u8], extract_links: bool) -> Result<Vec<Block>, LiteParseError> {
- let parsed = liteparse_docx::docx::parse(data)
+ let parsed = liteparse_ooxml::docx::parse(data)
.map_err(|e| LiteParseError::Conversion(format!("docx parse failed: {e}")))?;
- let resolved = liteparse_docx::render::resolve::resolve(parsed);
+ let resolved = liteparse_ooxml::render::resolve::resolve(parsed);
Ok(emit(&resolved, extract_links))
}
@@ -347,7 +347,7 @@ impl<'a> Emitter<'a> {
// than a dangling reference.
if let Some(queues) = self.figures.as_mut()
&& let Some(rel) =
- liteparse_docx::render::resolve::images::extract_image_rel_id(img)
+ liteparse_ooxml::render::resolve::images::extract_image_rel_id(img)
&& let Some(media) = self.doc.media.get(rel)
&& let Some(fig) = queues
.get_mut(&(media.data.as_ptr() as usize))
@@ -818,8 +818,8 @@ mod tests {
"/../../docx_files/legal/courts_3rd_circuit_ch4.docx"
))
.expect("corpus fixture");
- let parsed = liteparse_docx::docx::parse(&data).expect("fixture parses");
- let doc = liteparse_docx::render::resolve::resolve(parsed);
+ let parsed = liteparse_ooxml::docx::parse(&data).expect("fixture parses");
+ let doc = liteparse_ooxml::render::resolve::resolve(parsed);
let tagged = emit_with_sources(
&doc,
diff --git a/crates/liteparse/src/office/docx_layout.rs b/crates/liteparse/src/office/docx_layout.rs
index 328422d..32a807d 100644
--- a/crates/liteparse/src/office/docx_layout.rs
+++ b/crates/liteparse/src/office/docx_layout.rs
@@ -18,10 +18,10 @@
use std::collections::{HashMap, VecDeque};
-use liteparse_docx::render::fonts::FontRegistry;
-use liteparse_docx::render::layout::draw_command::{DrawCommand, LayoutedPage, OutlineMark};
-use liteparse_docx::render::layout::fragment::FontProps;
-use liteparse_docx::render::layout::measurer::TextMeasurer;
+use liteparse_ooxml::render::fonts::FontRegistry;
+use liteparse_ooxml::render::layout::draw_command::{DrawCommand, LayoutedPage, OutlineMark};
+use liteparse_ooxml::render::layout::fragment::FontProps;
+use liteparse_ooxml::render::layout::measurer::TextMeasurer;
use crate::types::{
DocumentAnnotation, ExtractedImage, OutlineTarget, Page, Rect, TextItem, WordBox,
@@ -97,8 +97,8 @@ pub fn layout_to_pages(
underline: false,
char_spacing: *char_spacing,
text_scale: *text_scale,
- underline_position: liteparse_docx::render::dimension::Pt::ZERO,
- underline_thickness: liteparse_docx::render::dimension::Pt::ZERO,
+ underline_position: liteparse_ooxml::render::dimension::Pt::ZERO,
+ underline_thickness: liteparse_ooxml::render::dimension::Pt::ZERO,
};
let (advance, metrics) = measurer.measure(text, &props);
let ascent = metrics.ascent.raw();
@@ -406,8 +406,8 @@ pub struct NativeImages {
/// everything), so surfacing bytes most consumers cannot decode would be a
/// worse contract than omitting them. Word's SVG embeds normally carry a PNG
/// fallback blip, which is the one the layout draws.
-fn media_extension(format: liteparse_docx::model::ImageFormat) -> Option<&'static str> {
- use liteparse_docx::model::ImageFormat as F;
+fn media_extension(format: liteparse_ooxml::model::ImageFormat) -> Option<&'static str> {
+ use liteparse_ooxml::model::ImageFormat as F;
match format {
F::Png => Some("png"),
F::Jpeg => Some("jpg"),
@@ -561,7 +561,7 @@ pub fn image_rects_per_page(layouted: &[LayoutedPage]) -> Vec<Vec<Rect>> {
/// continuation pages — inherit the previous page's count, and anything
/// before the first anchored block falls back to 1.
pub fn page_column_counts(
- resolved: &liteparse_docx::render::resolve::ResolvedDocument,
+ resolved: &liteparse_ooxml::render::resolve::ResolvedDocument,
block_pages: &HashMap<usize, usize>,
n_pages: usize,
) -> Vec<usize> {
@@ -638,10 +638,10 @@ fn union_bounds(items: &[TextItem]) -> Option<Rect> {
#[cfg(test)]
mod tests {
use super::*;
- use liteparse_docx::render::dimension::Pt;
- use liteparse_docx::render::geometry::{PtOffset, PtRect, PtSize};
- use liteparse_docx::render::layout::draw_command::OutlineHeading;
- use liteparse_docx::render::resolve::color::RgbColor;
+ use liteparse_ooxml::render::dimension::Pt;
+ use liteparse_ooxml::render::geometry::{PtOffset, PtRect, PtSize};
+ use liteparse_ooxml::render::layout::draw_command::OutlineHeading;
+ use liteparse_ooxml::render::resolve::color::RgbColor;
use std::rc::Rc;
fn registry() -> FontRegistry {
@@ -776,7 +776,7 @@ mod tests {
&[page(vec![
DrawCommand::Outline(OutlineMark::Begin(OutlineHeading {
node_id: 1,
- level: liteparse_docx::model::OutlineLevel::new(2),
+ level: liteparse_ooxml::model::OutlineLevel::new(2),
title: Rc::from("Title"),
})),
text_cmd(72.0, 100.0, "Title", 12.0),
diff --git a/crates/liteparse/src/parser.rs b/crates/liteparse/src/parser.rs
index 1d764b7..a894b0d 100644
--- a/crates/liteparse/src/parser.rs
+++ b/crates/liteparse/src/parser.rs
@@ -816,18 +816,18 @@ impl LiteParse {
fn parse_docx_native_inner(&self, data: &[u8]) -> Result<Option<ParseResult>, LiteParseError> {
use crate::office::{docx, docx_layout};
- let parsed = liteparse_docx::docx::parse(data)
+ let parsed = liteparse_ooxml::docx::parse(data)
.map_err(|e| LiteParseError::Conversion(format!("docx parse failed: {e}")))?;
- let resolved = liteparse_docx::render::resolve::resolve(parsed);
+ let resolved = liteparse_ooxml::render::resolve::resolve(parsed);
// Build the registry directly rather than via `resolve_and_layout`,
// whose `.expect` panics on a font-less host; here that is a clean
// fallback to the conversion path instead.
- let registry = liteparse_docx::render::fonts::FontRegistry::build(
+ let registry = liteparse_ooxml::render::fonts::FontRegistry::build(
&resolved.embedded_fonts,
&resolved.font_families,
)
.map_err(|e| LiteParseError::Conversion(format!("font registry: {e}")))?;
- let layouted = liteparse_docx::render::layout_document(&resolved, &registry);
+ let layouted = liteparse_ooxml::render::layout_document(&resolved, &registry);
let native = docx_layout::layout_to_pages(
&layouted,
&registry,
@@ -994,15 +994,15 @@ impl LiteParse {
data: &[u8],
page_numbers: Option<&[u32]>,
) -> Result<Vec<ScreenshotResult>, LiteParseError> {
- let parsed = liteparse_docx::docx::parse(data)
+ let parsed = liteparse_ooxml::docx::parse(data)
.map_err(|e| LiteParseError::Conversion(format!("docx parse failed: {e}")))?;
- let resolved = liteparse_docx::render::resolve::resolve(parsed);
- let registry = liteparse_docx::render::fonts::FontRegistry::build(
+ let resolved = liteparse_ooxml::render::resolve::resolve(parsed);
+ let registry = liteparse_ooxml::render::fonts::FontRegistry::build(
&resolved.embedded_fonts,
&resolved.font_families,
)
.map_err(|e| LiteParseError::Conversion(format!("font registry: {e}")))?;
- let layouted = liteparse_docx::render::layout_document(&resolved, &registry);
+ let layouted = liteparse_ooxml::render::layout_document(&resolved, &registry);
let page_count = layouted.len() as u32;
let pages: Vec<u32> = match page_numbers {
@@ -1017,7 +1017,7 @@ impl LiteParse {
"page {page_num} out of range (document has {page_count} pages)"
)));
}
- let raster = liteparse_docx::render::raster::rasterize_page(
+ let raster = liteparse_ooxml::render::raster::rasterize_page(
&layouted[(page_num - 1) as usize],
&registry,
scale,