kreuzberg 4.0.0.pre.rc.6 → 4.0.0.pre.rc.8

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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -5
  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 +511 -325
  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 +32 -11
  14. data/vendor/kreuzberg/README.md +54 -8
  15. data/vendor/kreuzberg/build.rs +549 -132
  16. data/vendor/kreuzberg/src/chunking/mod.rs +1279 -79
  17. data/vendor/kreuzberg/src/chunking/processor.rs +220 -0
  18. data/vendor/kreuzberg/src/core/config.rs +49 -1
  19. data/vendor/kreuzberg/src/core/extractor.rs +134 -2
  20. data/vendor/kreuzberg/src/core/mod.rs +4 -2
  21. data/vendor/kreuzberg/src/core/pipeline.rs +188 -1
  22. data/vendor/kreuzberg/src/extraction/docx.rs +358 -0
  23. data/vendor/kreuzberg/src/extraction/html.rs +24 -8
  24. data/vendor/kreuzberg/src/extraction/image.rs +124 -1
  25. data/vendor/kreuzberg/src/extraction/libreoffice.rs +1 -2
  26. data/vendor/kreuzberg/src/extraction/office_metadata/odt_properties.rs +0 -3
  27. data/vendor/kreuzberg/src/extraction/pptx.rs +187 -87
  28. data/vendor/kreuzberg/src/extractors/archive.rs +1 -0
  29. data/vendor/kreuzberg/src/extractors/bibtex.rs +1 -0
  30. data/vendor/kreuzberg/src/extractors/docbook.rs +2 -0
  31. data/vendor/kreuzberg/src/extractors/docx.rs +50 -17
  32. data/vendor/kreuzberg/src/extractors/email.rs +29 -15
  33. data/vendor/kreuzberg/src/extractors/epub.rs +1 -0
  34. data/vendor/kreuzberg/src/extractors/excel.rs +2 -0
  35. data/vendor/kreuzberg/src/extractors/fictionbook.rs +1 -0
  36. data/vendor/kreuzberg/src/extractors/html.rs +29 -15
  37. data/vendor/kreuzberg/src/extractors/image.rs +25 -4
  38. data/vendor/kreuzberg/src/extractors/jats.rs +3 -0
  39. data/vendor/kreuzberg/src/extractors/jupyter.rs +1 -0
  40. data/vendor/kreuzberg/src/extractors/latex.rs +1 -0
  41. data/vendor/kreuzberg/src/extractors/markdown.rs +1 -0
  42. data/vendor/kreuzberg/src/extractors/mod.rs +78 -14
  43. data/vendor/kreuzberg/src/extractors/odt.rs +3 -3
  44. data/vendor/kreuzberg/src/extractors/opml.rs +1 -0
  45. data/vendor/kreuzberg/src/extractors/orgmode.rs +1 -0
  46. data/vendor/kreuzberg/src/extractors/pdf.rs +197 -17
  47. data/vendor/kreuzberg/src/extractors/pptx.rs +32 -13
  48. data/vendor/kreuzberg/src/extractors/rst.rs +1 -0
  49. data/vendor/kreuzberg/src/extractors/rtf.rs +3 -4
  50. data/vendor/kreuzberg/src/extractors/structured.rs +2 -0
  51. data/vendor/kreuzberg/src/extractors/text.rs +7 -2
  52. data/vendor/kreuzberg/src/extractors/typst.rs +1 -0
  53. data/vendor/kreuzberg/src/extractors/xml.rs +27 -15
  54. data/vendor/kreuzberg/src/keywords/processor.rs +9 -1
  55. data/vendor/kreuzberg/src/language_detection/mod.rs +43 -0
  56. data/vendor/kreuzberg/src/language_detection/processor.rs +219 -0
  57. data/vendor/kreuzberg/src/lib.rs +10 -2
  58. data/vendor/kreuzberg/src/mcp/mod.rs +3 -0
  59. data/vendor/kreuzberg/src/mcp/server.rs +120 -12
  60. data/vendor/kreuzberg/src/ocr/tesseract_backend.rs +2 -0
  61. data/vendor/kreuzberg/src/pdf/bundled.rs +328 -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 +18 -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/pdfium_linking.rs +374 -0
  94. data/vendor/kreuzberg/tests/pipeline_integration.rs +25 -0
  95. data/vendor/kreuzberg/tests/plugin_ocr_backend_test.rs +5 -0
  96. data/vendor/kreuzberg/tests/plugin_system.rs +6 -0
  97. data/vendor/kreuzberg/tests/registry_integration_tests.rs +1 -0
  98. data/vendor/kreuzberg/tests/rst_extractor_tests.rs +2 -0
  99. data/vendor/kreuzberg/tests/rtf_extractor_tests.rs +0 -1
  100. data/vendor/kreuzberg/tests/security_validation.rs +1 -0
  101. data/vendor/kreuzberg/tests/test_fastembed.rs +45 -23
  102. data/vendor/kreuzberg/tests/typst_behavioral_tests.rs +1 -0
  103. data/vendor/kreuzberg/tests/typst_extractor_tests.rs +3 -2
  104. data/vendor/rb-sys/.cargo_vcs_info.json +2 -2
  105. data/vendor/rb-sys/Cargo.lock +15 -15
  106. data/vendor/rb-sys/Cargo.toml +4 -4
  107. data/vendor/rb-sys/Cargo.toml.orig +4 -4
  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/lib.rs +1 -0
  113. data/vendor/rb-sys/src/macros.rs +2 -2
  114. data/vendor/rb-sys/src/special_consts.rs +1 -1
  115. data/vendor/rb-sys/src/stable_api/compiled.rs +1 -1
  116. data/vendor/rb-sys/src/stable_api/ruby_2_7.rs +12 -4
  117. data/vendor/rb-sys/src/stable_api/ruby_3_0.rs +12 -4
  118. data/vendor/rb-sys/src/stable_api/ruby_3_1.rs +12 -4
  119. data/vendor/rb-sys/src/stable_api/ruby_3_2.rs +12 -4
  120. data/vendor/rb-sys/src/stable_api/ruby_3_3.rs +19 -6
  121. data/vendor/rb-sys/src/stable_api/ruby_3_4.rs +17 -5
  122. data/vendor/rb-sys/src/stable_api.rs +0 -1
  123. data/vendor/rb-sys/src/tracking_allocator.rs +1 -3
  124. metadata +13 -10
  125. data/vendor/kreuzberg/src/extractors/fictionbook.rs.backup2 +0 -738
  126. data/vendor/rb-sys/.cargo-ok +0 -1
  127. data/vendor/rb-sys/src/stable_api/ruby_2_6.rs +0 -316
@@ -0,0 +1,374 @@
1
+ //! PDFium linking integration tests.
2
+ //!
3
+ //! This module tests PDF extraction functionality across all PDFium linking strategies
4
+ //! (default, static, bundled, system). Tests verify that:
5
+ //!
6
+ //! 1. PDF extraction works regardless of linking strategy
7
+ //! 2. Extracted content is valid and non-empty
8
+ //! 3. Bundled PDFium extraction works when feature is enabled
9
+ //! 4. Metadata extraction functions correctly
10
+ //! 5. Error handling works for invalid PDFs
11
+ //!
12
+ //! These tests are strategy-agnostic - they verify functionality works with ANY
13
+ //! linking strategy, not implementation details of specific strategies.
14
+ //!
15
+ //! Test philosophy:
16
+ //! - Use small test PDFs from test_documents/
17
+ //! - Assert on extracted content and behavior, not linking internals
18
+ //! - Test both successful extraction and error cases
19
+ //! - Skip tests gracefully if test files are missing
20
+
21
+ #![cfg(feature = "pdf")]
22
+
23
+ mod helpers;
24
+
25
+ use helpers::*;
26
+ use kreuzberg::core::config::ExtractionConfig;
27
+ use kreuzberg::extract_file_sync;
28
+
29
+ /// Test basic PDF extraction works regardless of linking strategy.
30
+ ///
31
+ /// This is the primary integration test - it verifies that PDF extraction
32
+ /// functions correctly with any linking strategy. We use a small test PDF
33
+ /// and verify that:
34
+ /// - Extraction completes successfully
35
+ /// - Content is non-empty and contains expected text
36
+ /// - MIME type is correctly detected
37
+ #[test]
38
+ fn test_pdf_extraction_basic() {
39
+ if skip_if_missing("pdfs_with_tables/tiny.pdf") {
40
+ return;
41
+ }
42
+
43
+ let file_path = get_test_file_path("pdfs_with_tables/tiny.pdf");
44
+ let config = ExtractionConfig::default();
45
+
46
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract PDF successfully");
47
+
48
+ // Verify MIME type detection
49
+ assert_mime_type(&result, "application/pdf");
50
+
51
+ // Verify content was extracted
52
+ assert_non_empty_content(&result);
53
+
54
+ // Verify reasonable content length for a small PDF
55
+ assert_min_content_length(&result, 10);
56
+ }
57
+
58
+ /// Test PDF extraction with a medium-sized test PDF.
59
+ ///
60
+ /// Verifies that extraction works with slightly larger PDFs and produces
61
+ /// substantive content. This test helps ensure linking strategy works
62
+ /// with real-world document sizes.
63
+ #[test]
64
+ fn test_pdf_extraction_medium() {
65
+ if skip_if_missing("pdfs_with_tables/medium.pdf") {
66
+ return;
67
+ }
68
+
69
+ let file_path = get_test_file_path("pdfs_with_tables/medium.pdf");
70
+ let config = ExtractionConfig::default();
71
+
72
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract medium PDF successfully");
73
+
74
+ assert_mime_type(&result, "application/pdf");
75
+ assert_non_empty_content(&result);
76
+
77
+ // Medium PDF should have more content than tiny
78
+ assert!(result.content.len() >= 50, "Medium PDF should have substantial content");
79
+ }
80
+
81
+ /// Test PDF extraction with rotated pages.
82
+ ///
83
+ /// Some PDFs have rotated pages. This test verifies that the linking
84
+ /// strategy handles page rotation correctly (PDFium should handle this
85
+ /// transparently). Note: This specific PDF may have OCR-only content,
86
+ /// so we just verify extraction completes without error.
87
+ #[test]
88
+ fn test_pdf_extraction_rotated_pages() {
89
+ if skip_if_missing("pdfs/ocr_test_rotated_90.pdf") {
90
+ return;
91
+ }
92
+
93
+ let file_path = get_test_file_path("pdfs/ocr_test_rotated_90.pdf");
94
+ let config = ExtractionConfig::default();
95
+
96
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract rotated PDF successfully");
97
+
98
+ assert_mime_type(&result, "application/pdf");
99
+ // Rotated PDFs may have OCR-only content, just verify extraction completes
100
+ }
101
+
102
+ /// Test PDF text extraction with code and formula content.
103
+ ///
104
+ /// Verifies extraction works with technical PDFs containing code blocks,
105
+ /// mathematical formulas, and special formatting.
106
+ #[test]
107
+ fn test_pdf_extraction_code_and_formulas() {
108
+ if skip_if_missing("pdfs/code_and_formula.pdf") {
109
+ return;
110
+ }
111
+
112
+ let file_path = get_test_file_path("pdfs/code_and_formula.pdf");
113
+ let config = ExtractionConfig::default();
114
+
115
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract PDF with code and formulas");
116
+
117
+ assert_mime_type(&result, "application/pdf");
118
+ assert_non_empty_content(&result);
119
+ }
120
+
121
+ /// Test PDF extraction preserves right-to-left text direction.
122
+ ///
123
+ /// PDFs with RTL text (Arabic, Hebrew, etc.) require special handling.
124
+ /// This verifies extraction works with RTL content.
125
+ #[test]
126
+ fn test_pdf_extraction_right_to_left() {
127
+ if skip_if_missing("pdfs/right_to_left_01.pdf") {
128
+ return;
129
+ }
130
+
131
+ let file_path = get_test_file_path("pdfs/right_to_left_01.pdf");
132
+ let config = ExtractionConfig::default();
133
+
134
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract RTL PDF successfully");
135
+
136
+ assert_mime_type(&result, "application/pdf");
137
+ // RTL PDFs might have minimal or no extracted text depending on PDF structure
138
+ // Just verify extraction completes without error
139
+ }
140
+
141
+ /// Test PDF metadata extraction.
142
+ ///
143
+ /// Verifies that PDF metadata (title, author, creation date, etc.) can be
144
+ /// extracted correctly, which is independent of linking strategy.
145
+ #[test]
146
+ fn test_pdf_metadata_extraction() {
147
+ if skip_if_missing("pdfs_with_tables/tiny.pdf") {
148
+ return;
149
+ }
150
+
151
+ let file_path = get_test_file_path("pdfs_with_tables/tiny.pdf");
152
+ let config = ExtractionConfig::default();
153
+
154
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract PDF metadata");
155
+
156
+ // Metadata field is always present (may have empty fields for some PDFs)
157
+ // Just verify the structure exists
158
+ let _metadata = &result.metadata;
159
+ assert!(!result.mime_type.is_empty(), "MIME type should be set");
160
+ }
161
+
162
+ /// Test extraction of byte array from PDF.
163
+ ///
164
+ /// Verifies that extract_bytes_sync works for PDF content, which is
165
+ /// important for in-memory processing.
166
+ #[test]
167
+ fn test_pdf_extraction_from_bytes() {
168
+ if skip_if_missing("pdfs_with_tables/tiny.pdf") {
169
+ return;
170
+ }
171
+
172
+ let file_path = get_test_file_path("pdfs_with_tables/tiny.pdf");
173
+ let pdf_bytes = std::fs::read(&file_path).expect("Should read PDF file");
174
+
175
+ let config = ExtractionConfig::default();
176
+ let result = kreuzberg::extract_bytes_sync(&pdf_bytes, "application/pdf", &config)
177
+ .expect("Should extract PDF from bytes successfully");
178
+
179
+ assert_mime_type(&result, "application/pdf");
180
+ assert_non_empty_content(&result);
181
+ }
182
+
183
+ /// Test bundled PDFium extraction when pdf-bundled feature is enabled.
184
+ ///
185
+ /// When `pdf-bundled` feature is enabled, PDFium is embedded in the binary.
186
+ /// This test verifies the bundled extraction mechanism works correctly.
187
+ #[test]
188
+ #[cfg(feature = "pdf-bundled")]
189
+ fn test_bundled_pdfium_extraction() {
190
+ use kreuzberg::pdf::extract_bundled_pdfium;
191
+
192
+ // Extract bundled PDFium library to temporary directory
193
+ let lib_path = extract_bundled_pdfium().expect("Should extract bundled PDFium library");
194
+
195
+ // Verify extracted library exists and is a file
196
+ assert!(
197
+ lib_path.exists(),
198
+ "Extracted PDFium library should exist at {}",
199
+ lib_path.display()
200
+ );
201
+ assert!(
202
+ lib_path.is_file(),
203
+ "Extracted PDFium library should be a file, not directory"
204
+ );
205
+
206
+ // Verify library has a reasonable file size (at least a few MB)
207
+ let metadata = std::fs::metadata(&lib_path).expect("Should read library metadata");
208
+ assert!(
209
+ metadata.len() > 1_000_000,
210
+ "Bundled PDFium library should be at least 1MB (got {} bytes)",
211
+ metadata.len()
212
+ );
213
+ }
214
+
215
+ /// Test bundled PDFium extracts consistently.
216
+ ///
217
+ /// Verify that repeated calls to extract_bundled_pdfium return the same path
218
+ /// and don't create duplicate extracted libraries.
219
+ #[test]
220
+ #[cfg(feature = "pdf-bundled")]
221
+ fn test_bundled_pdfium_caching() {
222
+ use kreuzberg::pdf::extract_bundled_pdfium;
223
+
224
+ let path1 = extract_bundled_pdfium().expect("First extraction should succeed");
225
+ let path2 = extract_bundled_pdfium().expect("Second extraction should succeed");
226
+
227
+ // Both calls should return the same path (caching in place)
228
+ assert_eq!(path1, path2, "Multiple extractions should return consistent path");
229
+
230
+ // Path should still exist
231
+ assert!(path1.exists(), "Extracted library should still exist");
232
+ }
233
+
234
+ /// Test bundled PDFium works with PDF extraction.
235
+ ///
236
+ /// This integration test verifies that PDFium extracted via bundled mechanism
237
+ /// actually works for PDF content extraction.
238
+ #[test]
239
+ #[cfg(feature = "pdf-bundled")]
240
+ fn test_bundled_pdfium_with_pdf_extraction() {
241
+ if skip_if_missing("pdfs_with_tables/tiny.pdf") {
242
+ return;
243
+ }
244
+
245
+ // Ensure bundled PDFium is extracted and available
246
+ let _lib_path = kreuzberg::pdf::extract_bundled_pdfium().expect("Should extract bundled PDFium library");
247
+
248
+ // Now test that PDF extraction works with the bundled library
249
+ let file_path = get_test_file_path("pdfs_with_tables/tiny.pdf");
250
+ let config = ExtractionConfig::default();
251
+
252
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract PDF with bundled PDFium");
253
+
254
+ assert_mime_type(&result, "application/pdf");
255
+ assert_non_empty_content(&result);
256
+ }
257
+
258
+ /// Test extraction with custom PDF configuration.
259
+ ///
260
+ /// Verifies that custom PDF extraction settings work correctly.
261
+ #[test]
262
+ fn test_pdf_extraction_with_config() {
263
+ if skip_if_missing("pdfs_with_tables/tiny.pdf") {
264
+ return;
265
+ }
266
+
267
+ let file_path = get_test_file_path("pdfs_with_tables/tiny.pdf");
268
+
269
+ // Create custom extraction config
270
+ let config = ExtractionConfig::default();
271
+
272
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract PDF with custom config");
273
+
274
+ assert_mime_type(&result, "application/pdf");
275
+ assert_non_empty_content(&result);
276
+
277
+ // Verify metadata is present
278
+ assert!(!result.mime_type.is_empty(), "MIME type should be set in result");
279
+ }
280
+
281
+ /// Test handling of empty or minimal PDFs.
282
+ ///
283
+ /// Some edge case PDFs might be empty or contain no text. Verify extraction
284
+ /// handles these gracefully.
285
+ #[test]
286
+ fn test_pdf_extraction_edge_cases() {
287
+ // Test extraction of a minimal PDF
288
+ if skip_if_missing("pdfs_with_tables/tiny.pdf") {
289
+ return;
290
+ }
291
+
292
+ let file_path = get_test_file_path("pdfs_with_tables/tiny.pdf");
293
+ let config = ExtractionConfig::default();
294
+
295
+ // Should complete without panic, regardless of content
296
+ let result = extract_file_sync(&file_path, None, &config);
297
+ assert!(result.is_ok(), "PDF extraction should succeed");
298
+ }
299
+
300
+ /// Test batch extraction of multiple PDFs.
301
+ ///
302
+ /// Verifies that linking strategy handles batch processing of multiple
303
+ /// PDF files correctly.
304
+ #[test]
305
+ #[cfg(feature = "tokio-runtime")]
306
+ fn test_pdf_batch_extraction() {
307
+ if skip_if_missing("pdfs_with_tables/tiny.pdf") || skip_if_missing("pdfs_with_tables/medium.pdf") {
308
+ return;
309
+ }
310
+
311
+ let paths = vec![
312
+ get_test_file_path("pdfs_with_tables/tiny.pdf"),
313
+ get_test_file_path("pdfs_with_tables/medium.pdf"),
314
+ ];
315
+
316
+ let config = ExtractionConfig::default();
317
+
318
+ // Use synchronous batch extraction
319
+ let results = kreuzberg::batch_extract_file_sync(paths, &config).expect("Should extract PDFs in batch");
320
+
321
+ // Verify all PDFs were extracted
322
+ assert_eq!(results.len(), 2, "Should extract both PDFs");
323
+
324
+ // Verify all results are valid
325
+ for result in &results {
326
+ assert_mime_type(result, "application/pdf");
327
+ assert_non_empty_content(result);
328
+ }
329
+ }
330
+
331
+ /// Test PDF with Unicode content extraction.
332
+ ///
333
+ /// Verifies that PDFium linking strategy handles PDFs with international
334
+ /// characters correctly.
335
+ #[test]
336
+ fn test_pdf_unicode_content() {
337
+ // Right-to-left PDFs often contain Unicode content
338
+ if skip_if_missing("pdfs/right_to_left_01.pdf") {
339
+ return;
340
+ }
341
+
342
+ let file_path = get_test_file_path("pdfs/right_to_left_01.pdf");
343
+ let config = ExtractionConfig::default();
344
+
345
+ let result = extract_file_sync(&file_path, None, &config).expect("Should extract PDF with Unicode content");
346
+
347
+ // Just verify extraction completes - Unicode content handling
348
+ // varies by PDF structure
349
+ assert_mime_type(&result, "application/pdf");
350
+ }
351
+
352
+ /// Verify PDF module compiles with all feature combinations.
353
+ ///
354
+ /// This is a compile-time test that ensures the pdf module and bundled
355
+ /// submodule (when enabled) compile correctly. It's implicitly tested
356
+ /// by the fact that these test functions compile.
357
+ #[test]
358
+ #[cfg(feature = "pdf")]
359
+ fn test_pdf_module_availability() {
360
+ // This test verifies that:
361
+ // 1. The pdf module is available (feature = "pdf")
362
+ // 2. Key functions are accessible
363
+ // 3. pdf-bundled module is available when feature enabled
364
+
365
+ // Verify we can access the text extraction function
366
+ let _ = kreuzberg::pdf::extract_text_from_pdf;
367
+
368
+ // Verify we can access the metadata function
369
+ let _ = kreuzberg::pdf::extract_metadata;
370
+
371
+ // Verify bundled module is available when feature enabled
372
+ #[cfg(feature = "pdf-bundled")]
373
+ let _ = kreuzberg::pdf::extract_bundled_pdfium;
374
+ }
@@ -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
 
@@ -8,6 +8,8 @@
8
8
  //! - Section structure and heading levels
9
9
  //! - Table extraction (simple and grid tables)
10
10
  //! - Reference links and images
11
+
12
+ #![cfg(feature = "office")]
11
13
  //! - Comments and special blocks
12
14
  //! - Content quality validation
13
15
 
@@ -731,7 +731,6 @@ async fn test_rtf_comprehensive_extraction_alignment() {
731
731
  "Should include third section heading"
732
732
  );
733
733
 
734
- // Table/text alignment with DOCX/ODT variants
735
734
  for expected in ["Header 1", "Cell 1A", "Product", "Apple"] {
736
735
  assert!(
737
736
  rtf_result.content.contains(expected),
@@ -140,6 +140,7 @@ fn test_archive_deeply_nested_directories() {
140
140
  }
141
141
 
142
142
  #[test]
143
+ #[cfg(feature = "archives")]
143
144
  fn test_archive_many_small_files() {
144
145
  let mut cursor = std::io::Cursor::new(Vec::new());
145
146
  {