kreuzberg 4.0.0.pre.rc.6 → 4.0.0.pre.rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -3
  3. data/README.md +15 -9
  4. data/ext/kreuzberg_rb/native/.cargo/config.toml +2 -0
  5. data/ext/kreuzberg_rb/native/Cargo.lock +516 -324
  6. data/ext/kreuzberg_rb/native/Cargo.toml +13 -3
  7. data/ext/kreuzberg_rb/native/src/lib.rs +139 -2
  8. data/kreuzberg.gemspec +38 -4
  9. data/lib/kreuzberg/config.rb +34 -1
  10. data/lib/kreuzberg/result.rb +77 -14
  11. data/lib/kreuzberg/version.rb +1 -1
  12. data/sig/kreuzberg.rbs +23 -6
  13. data/vendor/kreuzberg/Cargo.toml +25 -11
  14. data/vendor/kreuzberg/README.md +13 -8
  15. data/vendor/kreuzberg/build.rs +17 -6
  16. data/vendor/kreuzberg/src/api/mod.rs +2 -0
  17. data/vendor/kreuzberg/src/chunking/mod.rs +1279 -79
  18. data/vendor/kreuzberg/src/chunking/processor.rs +220 -0
  19. data/vendor/kreuzberg/src/core/config.rs +49 -1
  20. data/vendor/kreuzberg/src/core/extractor.rs +134 -2
  21. data/vendor/kreuzberg/src/core/mod.rs +4 -2
  22. data/vendor/kreuzberg/src/core/pipeline.rs +188 -1
  23. data/vendor/kreuzberg/src/extraction/docx.rs +358 -0
  24. data/vendor/kreuzberg/src/extraction/html.rs +24 -8
  25. data/vendor/kreuzberg/src/extraction/image.rs +124 -1
  26. data/vendor/kreuzberg/src/extraction/libreoffice.rs +1 -2
  27. data/vendor/kreuzberg/src/extraction/office_metadata/odt_properties.rs +0 -3
  28. data/vendor/kreuzberg/src/extraction/pptx.rs +187 -87
  29. data/vendor/kreuzberg/src/extractors/archive.rs +1 -0
  30. data/vendor/kreuzberg/src/extractors/bibtex.rs +1 -0
  31. data/vendor/kreuzberg/src/extractors/docbook.rs +2 -0
  32. data/vendor/kreuzberg/src/extractors/docx.rs +50 -17
  33. data/vendor/kreuzberg/src/extractors/email.rs +29 -15
  34. data/vendor/kreuzberg/src/extractors/epub.rs +1 -0
  35. data/vendor/kreuzberg/src/extractors/excel.rs +2 -0
  36. data/vendor/kreuzberg/src/extractors/fictionbook.rs +1 -0
  37. data/vendor/kreuzberg/src/extractors/html.rs +29 -15
  38. data/vendor/kreuzberg/src/extractors/image.rs +25 -4
  39. data/vendor/kreuzberg/src/extractors/jats.rs +3 -0
  40. data/vendor/kreuzberg/src/extractors/jupyter.rs +1 -0
  41. data/vendor/kreuzberg/src/extractors/latex.rs +1 -0
  42. data/vendor/kreuzberg/src/extractors/markdown.rs +1 -0
  43. data/vendor/kreuzberg/src/extractors/mod.rs +78 -14
  44. data/vendor/kreuzberg/src/extractors/odt.rs +3 -3
  45. data/vendor/kreuzberg/src/extractors/opml.rs +1 -0
  46. data/vendor/kreuzberg/src/extractors/orgmode.rs +1 -0
  47. data/vendor/kreuzberg/src/extractors/pdf.rs +194 -17
  48. data/vendor/kreuzberg/src/extractors/pptx.rs +32 -13
  49. data/vendor/kreuzberg/src/extractors/rst.rs +1 -0
  50. data/vendor/kreuzberg/src/extractors/rtf.rs +3 -4
  51. data/vendor/kreuzberg/src/extractors/structured.rs +2 -0
  52. data/vendor/kreuzberg/src/extractors/text.rs +7 -2
  53. data/vendor/kreuzberg/src/extractors/typst.rs +1 -0
  54. data/vendor/kreuzberg/src/extractors/xml.rs +27 -15
  55. data/vendor/kreuzberg/src/keywords/processor.rs +9 -1
  56. data/vendor/kreuzberg/src/language_detection/mod.rs +43 -0
  57. data/vendor/kreuzberg/src/language_detection/processor.rs +219 -0
  58. data/vendor/kreuzberg/src/lib.rs +10 -2
  59. data/vendor/kreuzberg/src/mcp/mod.rs +2 -0
  60. data/vendor/kreuzberg/src/mcp/server.rs +14 -12
  61. data/vendor/kreuzberg/src/ocr/tesseract_backend.rs +2 -0
  62. data/vendor/kreuzberg/src/pdf/error.rs +8 -0
  63. data/vendor/kreuzberg/src/pdf/metadata.rs +238 -95
  64. data/vendor/kreuzberg/src/pdf/mod.rs +14 -2
  65. data/vendor/kreuzberg/src/pdf/rendering.rs +1 -2
  66. data/vendor/kreuzberg/src/pdf/table.rs +26 -2
  67. data/vendor/kreuzberg/src/pdf/text.rs +89 -7
  68. data/vendor/kreuzberg/src/plugins/extractor.rs +34 -3
  69. data/vendor/kreuzberg/src/plugins/mod.rs +3 -0
  70. data/vendor/kreuzberg/src/plugins/ocr.rs +22 -3
  71. data/vendor/kreuzberg/src/plugins/processor.rs +8 -0
  72. data/vendor/kreuzberg/src/plugins/registry.rs +2 -0
  73. data/vendor/kreuzberg/src/plugins/validator.rs +11 -0
  74. data/vendor/kreuzberg/src/text/mod.rs +6 -0
  75. data/vendor/kreuzberg/src/text/quality_processor.rs +219 -0
  76. data/vendor/kreuzberg/src/types.rs +173 -21
  77. data/vendor/kreuzberg/tests/archive_integration.rs +2 -0
  78. data/vendor/kreuzberg/tests/batch_processing.rs +5 -3
  79. data/vendor/kreuzberg/tests/concurrency_stress.rs +14 -6
  80. data/vendor/kreuzberg/tests/config_features.rs +15 -1
  81. data/vendor/kreuzberg/tests/config_loading_tests.rs +1 -0
  82. data/vendor/kreuzberg/tests/docbook_extractor_tests.rs +2 -0
  83. data/vendor/kreuzberg/tests/email_integration.rs +2 -0
  84. data/vendor/kreuzberg/tests/error_handling.rs +43 -34
  85. data/vendor/kreuzberg/tests/format_integration.rs +2 -0
  86. data/vendor/kreuzberg/tests/image_integration.rs +2 -0
  87. data/vendor/kreuzberg/tests/mime_detection.rs +17 -16
  88. data/vendor/kreuzberg/tests/ocr_configuration.rs +4 -0
  89. data/vendor/kreuzberg/tests/ocr_errors.rs +22 -0
  90. data/vendor/kreuzberg/tests/ocr_quality.rs +2 -0
  91. data/vendor/kreuzberg/tests/odt_extractor_tests.rs +0 -21
  92. data/vendor/kreuzberg/tests/pdf_integration.rs +2 -0
  93. data/vendor/kreuzberg/tests/pipeline_integration.rs +25 -0
  94. data/vendor/kreuzberg/tests/plugin_ocr_backend_test.rs +5 -0
  95. data/vendor/kreuzberg/tests/plugin_system.rs +6 -0
  96. data/vendor/kreuzberg/tests/registry_integration_tests.rs +1 -0
  97. data/vendor/kreuzberg/tests/rst_extractor_tests.rs +2 -0
  98. data/vendor/kreuzberg/tests/rtf_extractor_tests.rs +0 -1
  99. data/vendor/kreuzberg/tests/security_validation.rs +1 -0
  100. data/vendor/kreuzberg/tests/test_fastembed.rs +45 -23
  101. data/vendor/kreuzberg/tests/typst_behavioral_tests.rs +1 -0
  102. data/vendor/kreuzberg/tests/typst_extractor_tests.rs +3 -2
  103. data/vendor/rb-sys/.cargo_vcs_info.json +2 -2
  104. data/vendor/rb-sys/Cargo.lock +15 -15
  105. data/vendor/rb-sys/Cargo.toml +4 -4
  106. data/vendor/rb-sys/Cargo.toml.orig +4 -4
  107. data/vendor/rb-sys/bin/release.sh +9 -8
  108. data/vendor/rb-sys/build/features.rs +5 -2
  109. data/vendor/rb-sys/build/main.rs +55 -15
  110. data/vendor/rb-sys/build/stable_api_config.rs +4 -2
  111. data/vendor/rb-sys/build/version.rs +3 -1
  112. data/vendor/rb-sys/src/macros.rs +2 -2
  113. data/vendor/rb-sys/src/special_consts.rs +1 -1
  114. data/vendor/rb-sys/src/stable_api/compiled.rs +1 -1
  115. data/vendor/rb-sys/src/stable_api/ruby_2_7.rs +12 -4
  116. data/vendor/rb-sys/src/stable_api/ruby_3_0.rs +12 -4
  117. data/vendor/rb-sys/src/stable_api/ruby_3_1.rs +12 -4
  118. data/vendor/rb-sys/src/stable_api/ruby_3_2.rs +12 -4
  119. data/vendor/rb-sys/src/stable_api/ruby_3_3.rs +19 -6
  120. data/vendor/rb-sys/src/stable_api/ruby_3_4.rs +17 -5
  121. data/vendor/rb-sys/src/stable_api.rs +0 -1
  122. data/vendor/rb-sys/src/tracking_allocator.rs +1 -3
  123. metadata +11 -10
  124. data/vendor/kreuzberg/src/extractors/fictionbook.rs.backup2 +0 -738
  125. data/vendor/rb-sys/.cargo-ok +0 -1
  126. data/vendor/rb-sys/src/stable_api/ruby_2_6.rs +0 -316
@@ -1,5 +1,7 @@
1
1
  //! Comprehensive tests for DocBook extractor supporting both 4.x and 5.x versions.
2
2
 
3
+ #![cfg(feature = "xml")]
4
+
3
5
  use kreuzberg::core::config::ExtractionConfig;
4
6
  use kreuzberg::plugins::{DocumentExtractor, Plugin};
5
7
  use std::path::PathBuf;
@@ -3,6 +3,8 @@
3
3
  //! Tests for .eml (RFC822) email extraction.
4
4
  //! Validates metadata extraction, content extraction, HTML/plain text handling, and attachments.
5
5
 
6
+ #![cfg(feature = "email")]
7
+
6
8
  use kreuzberg::core::config::ExtractionConfig;
7
9
  use kreuzberg::core::extractor::extract_bytes;
8
10
 
@@ -12,6 +12,7 @@ mod helpers;
12
12
 
13
13
  /// Test truncated PDF - incomplete PDF file.
14
14
  #[tokio::test]
15
+ #[cfg(feature = "pdf")]
15
16
  async fn test_truncated_pdf() {
16
17
  let config = ExtractionConfig::default();
17
18
 
@@ -31,6 +32,7 @@ async fn test_truncated_pdf() {
31
32
 
32
33
  /// Test corrupted ZIP - malformed archive.
33
34
  #[tokio::test]
35
+ #[cfg(feature = "archives")]
34
36
  async fn test_corrupted_zip() {
35
37
  let config = ExtractionConfig::default();
36
38
 
@@ -50,6 +52,7 @@ async fn test_corrupted_zip() {
50
52
 
51
53
  /// Test invalid XML - bad XML syntax.
52
54
  #[tokio::test]
55
+ #[cfg(feature = "xml")]
53
56
  async fn test_invalid_xml() {
54
57
  let config = ExtractionConfig::default();
55
58
 
@@ -80,6 +83,7 @@ async fn test_invalid_xml() {
80
83
 
81
84
  /// Test corrupted image - invalid image data.
82
85
  #[tokio::test]
86
+ #[cfg(feature = "ocr")]
83
87
  async fn test_corrupted_image() {
84
88
  let config = ExtractionConfig::default();
85
89
 
@@ -112,27 +116,28 @@ async fn test_empty_file() {
112
116
 
113
117
  let empty_data = b"";
114
118
 
115
- let result_pdf = extract_bytes(empty_data, "application/pdf", &config).await;
116
119
  let result_text = extract_bytes(empty_data, "text/plain", &config).await;
117
- let result_xml = extract_bytes(empty_data, "application/xml", &config).await;
118
-
119
- match result_pdf {
120
- Ok(extraction) => {
121
- assert!(
122
- extraction.content.is_empty(),
123
- "Empty PDF should have empty content if it succeeds"
124
- );
125
- assert!(extraction.chunks.is_none(), "Chunks should be None");
126
- }
127
- Err(error) => {
128
- assert!(
129
- matches!(
130
- error,
131
- kreuzberg::KreuzbergError::Parsing { .. } | kreuzberg::KreuzbergError::Validation { .. }
132
- ),
133
- "Empty PDF should produce Parsing or Validation error, got: {:?}",
134
- error
135
- );
120
+ #[cfg(feature = "pdf")]
121
+ {
122
+ let result_pdf = extract_bytes(empty_data, "application/pdf", &config).await;
123
+ match result_pdf {
124
+ Ok(extraction) => {
125
+ assert!(
126
+ extraction.content.is_empty(),
127
+ "Empty PDF should have empty content if it succeeds"
128
+ );
129
+ assert!(extraction.chunks.is_none(), "Chunks should be None");
130
+ }
131
+ Err(error) => {
132
+ assert!(
133
+ matches!(
134
+ error,
135
+ kreuzberg::KreuzbergError::Parsing { .. } | kreuzberg::KreuzbergError::Validation { .. }
136
+ ),
137
+ "Empty PDF should produce Parsing or Validation error, got: {:?}",
138
+ error
139
+ );
140
+ }
136
141
  }
137
142
  }
138
143
 
@@ -149,20 +154,24 @@ async fn test_empty_file() {
149
154
  }
150
155
  }
151
156
 
152
- match result_xml {
153
- Ok(extraction) => {
154
- assert!(
155
- extraction.content.is_empty(),
156
- "Empty XML should have empty content if it succeeds"
157
- );
158
- assert!(extraction.chunks.is_none(), "Chunks should be None");
159
- }
160
- Err(error) => {
161
- assert!(
162
- matches!(error, kreuzberg::KreuzbergError::Parsing { .. }),
163
- "Empty XML error should be Parsing type, got: {:?}",
164
- error
165
- );
157
+ #[cfg(feature = "xml")]
158
+ {
159
+ let result_xml = extract_bytes(empty_data, "application/xml", &config).await;
160
+ match result_xml {
161
+ Ok(extraction) => {
162
+ assert!(
163
+ extraction.content.is_empty(),
164
+ "Empty XML should have empty content if it succeeds"
165
+ );
166
+ assert!(extraction.chunks.is_none(), "Chunks should be None");
167
+ }
168
+ Err(error) => {
169
+ assert!(
170
+ matches!(error, kreuzberg::KreuzbergError::Parsing { .. }),
171
+ "Empty XML error should be Parsing type, got: {:?}",
172
+ error
173
+ );
174
+ }
166
175
  }
167
176
  }
168
177
  }
@@ -5,6 +5,8 @@
5
5
  //! asynchronous APIs or to graceful handling when optional system
6
6
  //! dependencies are missing.
7
7
 
8
+ #![cfg(any(feature = "pdf", feature = "office", feature = "ocr"))]
9
+
8
10
  mod helpers;
9
11
 
10
12
  use helpers::{assert_mime_type, assert_non_empty_content, get_test_file_path, test_documents_available};
@@ -11,6 +11,8 @@
11
11
  //! - Test OCR with various languages and layouts
12
12
  //! - Verify graceful handling of images without text
13
13
 
14
+ #![cfg(feature = "ocr")]
15
+
14
16
  mod helpers;
15
17
 
16
18
  use helpers::*;
@@ -276,22 +276,23 @@ async fn test_no_extension() {
276
276
 
277
277
  let detected = detect_mime_type(&temp_path, true);
278
278
 
279
- if detected.is_err() {
280
- let error = detected.unwrap_err();
281
- assert!(
282
- matches!(
283
- error,
284
- kreuzberg::KreuzbergError::Validation { .. } | kreuzberg::KreuzbergError::UnsupportedFormat(_)
285
- ),
286
- "Should return appropriate error for file without extension"
287
- );
288
- } else {
289
- let mime = detected.unwrap();
290
- assert!(
291
- mime.contains('/'),
292
- "Detected MIME type should be valid format: {}",
293
- mime
294
- );
279
+ match detected {
280
+ Err(error) => {
281
+ assert!(
282
+ matches!(
283
+ error,
284
+ kreuzberg::KreuzbergError::Validation { .. } | kreuzberg::KreuzbergError::UnsupportedFormat(_)
285
+ ),
286
+ "Should return appropriate error for file without extension"
287
+ );
288
+ }
289
+ Ok(mime) => {
290
+ assert!(
291
+ mime.contains('/'),
292
+ "Detected MIME type should be valid format: {}",
293
+ mime
294
+ );
295
+ }
295
296
  }
296
297
 
297
298
  let _ = std::fs::remove_file(&temp_path);
@@ -11,6 +11,8 @@
11
11
  //! - Verify configuration changes actually affect output
12
12
  //! - Test table detection with various settings
13
13
 
14
+ #![cfg(feature = "ocr")]
15
+
14
16
  mod helpers;
15
17
 
16
18
  use helpers::*;
@@ -204,6 +206,7 @@ fn test_ocr_psm_single_line() {
204
206
  }
205
207
 
206
208
  #[test]
209
+ #[cfg(feature = "pdf")]
207
210
  fn test_force_ocr_on_text_pdf() {
208
211
  if skip_if_missing("pdfs/fake_memo.pdf") {
209
212
  return;
@@ -233,6 +236,7 @@ fn test_force_ocr_on_text_pdf() {
233
236
  }
234
237
 
235
238
  #[test]
239
+ #[cfg(feature = "pdf")]
236
240
  fn test_force_ocr_disabled() {
237
241
  if skip_if_missing("pdfs/fake_memo.pdf") {
238
242
  return;
@@ -13,6 +13,8 @@
13
13
  //! - Test recovery from transient failures
14
14
  //! - Validate resource limits and constraints
15
15
 
16
+ #![cfg(feature = "ocr")]
17
+
16
18
  mod helpers;
17
19
 
18
20
  use helpers::*;
@@ -451,6 +453,9 @@ fn test_ocr_cache_disabled_then_enabled() {
451
453
  };
452
454
 
453
455
  let result1 = extract_file_sync(&file_path, None, &config_no_cache);
456
+ if matches!(result1, Err(KreuzbergError::MissingDependency(_))) {
457
+ return;
458
+ }
454
459
  assert!(result1.is_ok(), "First extraction should succeed");
455
460
 
456
461
  let config_with_cache = ExtractionConfig {
@@ -468,6 +473,9 @@ fn test_ocr_cache_disabled_then_enabled() {
468
473
  };
469
474
 
470
475
  let result2 = extract_file_sync(&file_path, None, &config_with_cache);
476
+ if matches!(result2, Err(KreuzbergError::MissingDependency(_))) {
477
+ return;
478
+ }
471
479
  assert!(result2.is_ok(), "Second extraction should succeed");
472
480
 
473
481
  assert_non_empty_content(&result1.unwrap());
@@ -495,6 +503,13 @@ fn test_ocr_concurrent_same_file() {
495
503
  ..Default::default()
496
504
  });
497
505
 
506
+ if matches!(
507
+ extract_file_sync(&*file_path, None, &config),
508
+ Err(KreuzbergError::MissingDependency(_))
509
+ ) {
510
+ return;
511
+ }
512
+
498
513
  let mut handles = vec![];
499
514
  for i in 0..5 {
500
515
  let file_path_clone = Arc::clone(&file_path);
@@ -554,6 +569,13 @@ fn test_ocr_concurrent_different_files() {
554
569
  ..Default::default()
555
570
  });
556
571
 
572
+ if matches!(
573
+ extract_file_sync(&files[0], None, &config),
574
+ Err(KreuzbergError::MissingDependency(_))
575
+ ) {
576
+ return;
577
+ }
578
+
557
579
  let mut handles = vec![];
558
580
  for (i, file_path) in files.iter().enumerate() {
559
581
  let file_path_clone = file_path.clone();
@@ -14,6 +14,8 @@
14
14
  //! - Verify layout preservation (line counts, structure)
15
15
  //! - Assert minimum quality thresholds
16
16
 
17
+ #![cfg(all(feature = "ocr", feature = "pdf"))]
18
+
17
19
  mod helpers;
18
20
 
19
21
  use helpers::*;
@@ -69,16 +69,13 @@ async fn test_odt_metadata_extraction() {
69
69
  "Should contain document title in content"
70
70
  );
71
71
 
72
- // Verify metadata extraction
73
72
  let metadata = &result.metadata.additional;
74
73
  println!("Extracted metadata: {:?}", metadata);
75
74
 
76
- // Check title
77
75
  if let Some(title) = metadata.get("title") {
78
76
  assert_eq!(title.as_str(), Some("Test Metadata Document"), "Title should match");
79
77
  }
80
78
 
81
- // Check subject
82
79
  if let Some(subject) = metadata.get("subject") {
83
80
  assert_eq!(
84
81
  subject.as_str(),
@@ -87,28 +84,23 @@ async fn test_odt_metadata_extraction() {
87
84
  );
88
85
  }
89
86
 
90
- // Check creator/author
91
87
  if let Some(created_by) = metadata.get("created_by") {
92
88
  assert_eq!(created_by.as_str(), Some("John Doe"), "Creator should match");
93
89
  }
94
90
 
95
- // Check authors array
96
91
  if let Some(authors) = metadata.get("authors") {
97
92
  let authors_array = authors.as_array().expect("Authors should be an array");
98
93
  assert_eq!(authors_array.len(), 1, "Should have one author");
99
94
  assert_eq!(authors_array[0].as_str(), Some("John Doe"), "Author name should match");
100
95
  }
101
96
 
102
- // Check creation date (should exist)
103
97
  assert!(metadata.get("created_at").is_some(), "Creation date should be present");
104
98
 
105
- // Check modification date (should exist)
106
99
  assert!(
107
100
  metadata.get("modified_at").is_some(),
108
101
  "Modification date should be present"
109
102
  );
110
103
 
111
- // Check generator
112
104
  if let Some(generator) = metadata.get("generator") {
113
105
  let gen_str = generator.as_str().expect("Generator should be a string");
114
106
  assert!(gen_str.contains("Pandoc"), "Generator should be Pandoc");
@@ -604,18 +596,11 @@ async fn test_odt_table_no_duplicate_content() {
604
596
 
605
597
  assert!(!result.content.is_empty(), "Content should not be empty");
606
598
 
607
- // Count how many times we see "Content" in the output
608
- // In a properly fixed version, it should appear only once in the markdown table
609
- // or possibly twice if headers appear with the same name, but not multiple times
610
- // for the same cell
611
599
  let content_count = result.content.matches("Content").count();
612
600
 
613
- // "Content" appears twice in the header "More content" in a simple table
614
- // It should not appear more than 3 times (once in header, once in data cell, once in a different word like "More content")
615
601
  println!(" 'Content' appears {} times in output", content_count);
616
602
  println!(" Content preview:\n{}", result.content);
617
603
 
618
- // This verifies that we're not getting duplicate cell content extracted
619
604
  assert!(
620
605
  content_count <= 3,
621
606
  "Content should not appear excessively, indicating no duplicate table cell extraction"
@@ -628,7 +613,6 @@ async fn test_odt_table_no_duplicate_content() {
628
613
  /// Uses the extraction_test document created with pandoc to ensure complete content
629
614
  #[tokio::test]
630
615
  async fn test_odt_comprehensive_table_extraction() {
631
- // This test uses the pandoc-generated test document
632
616
  let test_file = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
633
617
  .parent()
634
618
  .unwrap()
@@ -648,7 +632,6 @@ async fn test_odt_comprehensive_table_extraction() {
648
632
 
649
633
  assert!(!result.content.is_empty(), "Content should not be empty");
650
634
 
651
- // Verify all sections are present
652
635
  assert!(result.content.contains("Comprehensive"), "Should contain heading");
653
636
  assert!(
654
637
  result.content.contains("First Section") || result.content.contains("First"),
@@ -663,14 +646,12 @@ async fn test_odt_comprehensive_table_extraction() {
663
646
  "Should contain third section"
664
647
  );
665
648
 
666
- // Verify tables are present and formatted correctly (as markdown)
667
649
  assert!(
668
650
  result.content.contains("|"),
669
651
  "Should contain pipe characters for markdown tables"
670
652
  );
671
653
  assert!(result.content.contains("---"), "Should contain table separator");
672
654
 
673
- // Verify table content is extracted
674
655
  assert!(
675
656
  result.content.contains("Header 1") || result.content.contains("Cell 1A"),
676
657
  "Should contain table data"
@@ -680,8 +661,6 @@ async fn test_odt_comprehensive_table_extraction() {
680
661
  "Should contain second table data"
681
662
  );
682
663
 
683
- // Verify no excessive duplication of cells (a simple heuristic check)
684
- // Count "Cell 1A" - should appear once or twice at most
685
664
  let cell_count = result.content.matches("Cell 1A").count();
686
665
  assert!(
687
666
  cell_count <= 2,
@@ -4,6 +4,8 @@
4
4
  //! multi-language E2E generator. This module keeps only the cases that
5
5
  //! exercise Rust-specific failure handling or error propagation.
6
6
 
7
+ #![cfg(feature = "pdf")]
8
+
7
9
  mod helpers;
8
10
 
9
11
  use helpers::*;
@@ -138,6 +138,7 @@ async fn test_pipeline_empty_no_processors() {
138
138
  detected_languages: None,
139
139
  chunks: None,
140
140
  images: None,
141
+ pages: None,
141
142
  };
142
143
  let config = ExtractionConfig::default();
143
144
 
@@ -182,6 +183,7 @@ async fn test_pipeline_single_processor_per_stage() {
182
183
  detected_languages: None,
183
184
  chunks: None,
184
185
  images: None,
186
+ pages: None,
185
187
  };
186
188
  let config = ExtractionConfig::default();
187
189
 
@@ -226,6 +228,7 @@ async fn test_pipeline_multiple_processors_per_stage() {
226
228
  detected_languages: None,
227
229
  chunks: None,
228
230
  images: None,
231
+ pages: None,
229
232
  };
230
233
  let config = ExtractionConfig::default();
231
234
 
@@ -261,6 +264,7 @@ async fn test_pipeline_all_stages_enabled() {
261
264
  detected_languages: None,
262
265
  chunks: None,
263
266
  images: None,
267
+ pages: None,
264
268
  };
265
269
  let config = ExtractionConfig::default();
266
270
 
@@ -294,6 +298,7 @@ async fn test_pipeline_postprocessing_disabled() {
294
298
  detected_languages: None,
295
299
  chunks: None,
296
300
  images: None,
301
+ pages: None,
297
302
  };
298
303
  let config = ExtractionConfig {
299
304
  postprocessor: Some(PostProcessorConfig {
@@ -340,6 +345,7 @@ async fn test_pipeline_early_stage_runs_first() {
340
345
  detected_languages: None,
341
346
  chunks: None,
342
347
  images: None,
348
+ pages: None,
343
349
  };
344
350
  let config = ExtractionConfig::default();
345
351
 
@@ -379,6 +385,7 @@ async fn test_pipeline_middle_stage_runs_second() {
379
385
  detected_languages: None,
380
386
  chunks: None,
381
387
  images: None,
388
+ pages: None,
382
389
  };
383
390
  let config = ExtractionConfig::default();
384
391
 
@@ -414,6 +421,7 @@ async fn test_pipeline_late_stage_runs_last() {
414
421
  detected_languages: None,
415
422
  chunks: None,
416
423
  images: None,
424
+ pages: None,
417
425
  };
418
426
  let config = ExtractionConfig::default();
419
427
 
@@ -449,6 +457,7 @@ async fn test_pipeline_within_stage_priority_order() {
449
457
  detected_languages: None,
450
458
  chunks: None,
451
459
  images: None,
460
+ pages: None,
452
461
  };
453
462
  let config = ExtractionConfig::default();
454
463
 
@@ -513,6 +522,7 @@ async fn test_pipeline_cross_stage_data_flow() {
513
522
  detected_languages: None,
514
523
  chunks: None,
515
524
  images: None,
525
+ pages: None,
516
526
  };
517
527
  let config = ExtractionConfig::default();
518
528
 
@@ -569,6 +579,7 @@ async fn test_pipeline_early_stage_error_recorded() {
569
579
  detected_languages: None,
570
580
  chunks: None,
571
581
  images: None,
582
+ pages: None,
572
583
  };
573
584
  let config = ExtractionConfig::default();
574
585
 
@@ -610,6 +621,7 @@ async fn test_pipeline_middle_stage_error_propagation() {
610
621
  detected_languages: None,
611
622
  chunks: None,
612
623
  images: None,
624
+ pages: None,
613
625
  };
614
626
  let config = ExtractionConfig::default();
615
627
 
@@ -681,6 +693,7 @@ async fn test_pipeline_late_stage_error_doesnt_affect_earlier_stages() {
681
693
  detected_languages: None,
682
694
  chunks: None,
683
695
  images: None,
696
+ pages: None,
684
697
  };
685
698
  let config = ExtractionConfig::default();
686
699
 
@@ -768,6 +781,7 @@ async fn test_pipeline_processor_error_doesnt_stop_other_processors() {
768
781
  detected_languages: None,
769
782
  chunks: None,
770
783
  images: None,
784
+ pages: None,
771
785
  };
772
786
  let config = ExtractionConfig::default();
773
787
 
@@ -845,6 +859,7 @@ async fn test_pipeline_multiple_processor_errors() {
845
859
  detected_languages: None,
846
860
  chunks: None,
847
861
  images: None,
862
+ pages: None,
848
863
  };
849
864
  let config = ExtractionConfig::default();
850
865
 
@@ -886,6 +901,7 @@ async fn test_pipeline_error_context_preservation() {
886
901
  detected_languages: None,
887
902
  chunks: None,
888
903
  images: None,
904
+ pages: None,
889
905
  };
890
906
  let config = ExtractionConfig::default();
891
907
 
@@ -957,6 +973,7 @@ async fn test_pipeline_metadata_added_in_early_visible_in_middle() {
957
973
  detected_languages: None,
958
974
  chunks: None,
959
975
  images: None,
976
+ pages: None,
960
977
  };
961
978
  let config = ExtractionConfig::default();
962
979
 
@@ -1027,6 +1044,7 @@ async fn test_pipeline_content_modified_in_middle_visible_in_late() {
1027
1044
  detected_languages: None,
1028
1045
  chunks: None,
1029
1046
  images: None,
1047
+ pages: None,
1030
1048
  };
1031
1049
  let config = ExtractionConfig::default();
1032
1050
 
@@ -1095,6 +1113,7 @@ async fn test_pipeline_multiple_processors_modifying_same_metadata() {
1095
1113
  detected_languages: None,
1096
1114
  chunks: None,
1097
1115
  images: None,
1116
+ pages: None,
1098
1117
  };
1099
1118
  let config = ExtractionConfig::default();
1100
1119
 
@@ -1182,6 +1201,7 @@ async fn test_pipeline_processors_reading_previous_output() {
1182
1201
  detected_languages: None,
1183
1202
  chunks: None,
1184
1203
  images: None,
1204
+ pages: None,
1185
1205
  };
1186
1206
  let config = ExtractionConfig::default();
1187
1207
 
@@ -1236,6 +1256,7 @@ async fn test_pipeline_large_content_modification() {
1236
1256
  detected_languages: None,
1237
1257
  chunks: None,
1238
1258
  images: None,
1259
+ pages: None,
1239
1260
  };
1240
1261
  let config = ExtractionConfig::default();
1241
1262
 
@@ -1271,6 +1292,7 @@ async fn test_pipeline_enabled_processors_whitelist() {
1271
1292
  detected_languages: None,
1272
1293
  chunks: None,
1273
1294
  images: None,
1295
+ pages: None,
1274
1296
  };
1275
1297
  let config = ExtractionConfig {
1276
1298
  postprocessor: Some(PostProcessorConfig {
@@ -1315,6 +1337,7 @@ async fn test_pipeline_disabled_processors_blacklist() {
1315
1337
  detected_languages: None,
1316
1338
  chunks: None,
1317
1339
  images: None,
1340
+ pages: None,
1318
1341
  };
1319
1342
  let config = ExtractionConfig {
1320
1343
  postprocessor: Some(PostProcessorConfig {
@@ -1359,6 +1382,7 @@ async fn test_pipeline_no_filtering_runs_all() {
1359
1382
  detected_languages: None,
1360
1383
  chunks: None,
1361
1384
  images: None,
1385
+ pages: None,
1362
1386
  };
1363
1387
  let config = ExtractionConfig::default();
1364
1388
 
@@ -1396,6 +1420,7 @@ async fn test_pipeline_empty_whitelist_runs_none() {
1396
1420
  detected_languages: None,
1397
1421
  chunks: None,
1398
1422
  images: None,
1423
+ pages: None,
1399
1424
  };
1400
1425
  let config = ExtractionConfig {
1401
1426
  postprocessor: Some(PostProcessorConfig {
@@ -3,6 +3,8 @@
3
3
  //! Tests custom OCR backend registration, execution, parameter passing,
4
4
  //! error handling, and backend switching with real image extraction.
5
5
 
6
+ #![cfg(feature = "ocr")]
7
+
6
8
  use async_trait::async_trait;
7
9
  use kreuzberg::core::config::{ExtractionConfig, OcrConfig};
8
10
  use kreuzberg::plugins::registry::get_ocr_backend_registry;
@@ -60,6 +62,7 @@ impl OcrBackend for MockOcrBackend {
60
62
  detected_languages: None,
61
63
  chunks: None,
62
64
  images: None,
65
+ pages: None,
63
66
  })
64
67
  }
65
68
 
@@ -155,6 +158,7 @@ impl OcrBackend for ValidatingOcrBackend {
155
158
  detected_languages: None,
156
159
  chunks: None,
157
160
  images: None,
161
+ pages: None,
158
162
  })
159
163
  }
160
164
 
@@ -211,6 +215,7 @@ impl OcrBackend for MetadataOcrBackend {
211
215
  detected_languages: None,
212
216
  chunks: None,
213
217
  images: None,
218
+ pages: None,
214
219
  })
215
220
  }
216
221
 
@@ -58,6 +58,7 @@ impl DocumentExtractor for FailingExtractor {
58
58
  detected_languages: None,
59
59
  chunks: None,
60
60
  images: None,
61
+ pages: None,
61
62
  })
62
63
  }
63
64
  }
@@ -302,6 +303,7 @@ fn test_extractor_priority_ordering_complex() {
302
303
  detected_languages: None,
303
304
  chunks: None,
304
305
  images: None,
306
+ pages: None,
305
307
  })
306
308
  }
307
309
  fn supported_mime_types(&self) -> &[&str] {
@@ -461,6 +463,7 @@ async fn test_processor_execution_order_within_stage() {
461
463
  detected_languages: None,
462
464
  chunks: None,
463
465
  images: None,
466
+ pages: None,
464
467
  };
465
468
 
466
469
  let config = ExtractionConfig::default();
@@ -492,6 +495,7 @@ async fn test_processor_error_propagation() {
492
495
  detected_languages: None,
493
496
  chunks: None,
494
497
  images: None,
498
+ pages: None,
495
499
  };
496
500
 
497
501
  let config = ExtractionConfig::default();
@@ -663,6 +667,7 @@ async fn test_validator_content_validation() {
663
667
  detected_languages: None,
664
668
  chunks: None,
665
669
  images: None,
670
+ pages: None,
666
671
  };
667
672
 
668
673
  let validation = validators[0].validate(&short_result, &config).await;
@@ -676,6 +681,7 @@ async fn test_validator_content_validation() {
676
681
  detected_languages: None,
677
682
  chunks: None,
678
683
  images: None,
684
+ pages: None,
679
685
  };
680
686
 
681
687
  let validation = validators[0].validate(&long_result, &config).await;
@@ -125,6 +125,7 @@ impl DocumentExtractor for MockExtractor {
125
125
  detected_languages: None,
126
126
  chunks: None,
127
127
  images: None,
128
+ pages: None,
128
129
  })
129
130
  }
130
131