kreuzberg 4.0.0.pre.rc.6 → 4.0.0.rc1
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.
- checksums.yaml +4 -4
- data/.gitignore +0 -6
- data/.rubocop.yaml +534 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +11 -11
- data/README.md +5 -10
- data/examples/async_patterns.rb +0 -1
- data/ext/kreuzberg_rb/extconf.rb +0 -10
- data/ext/kreuzberg_rb/native/Cargo.toml +15 -23
- data/ext/kreuzberg_rb/native/build.rs +2 -0
- data/ext/kreuzberg_rb/native/include/ieeefp.h +1 -1
- data/ext/kreuzberg_rb/native/include/msvc_compat/strings.h +1 -1
- data/ext/kreuzberg_rb/native/include/strings.h +2 -2
- data/ext/kreuzberg_rb/native/include/unistd.h +1 -1
- data/ext/kreuzberg_rb/native/src/lib.rs +16 -75
- data/kreuzberg.gemspec +14 -57
- data/lib/kreuzberg/cache_api.rb +0 -1
- data/lib/kreuzberg/cli.rb +2 -2
- data/lib/kreuzberg/config.rb +2 -9
- data/lib/kreuzberg/errors.rb +7 -75
- data/lib/kreuzberg/extraction_api.rb +0 -1
- data/lib/kreuzberg/setup_lib_path.rb +0 -1
- data/lib/kreuzberg/version.rb +1 -1
- data/lib/kreuzberg.rb +0 -21
- data/pkg/kreuzberg-4.0.0.rc1.gem +0 -0
- data/sig/kreuzberg.rbs +3 -55
- data/spec/binding/cli_proxy_spec.rb +4 -2
- data/spec/binding/cli_spec.rb +11 -12
- data/spec/examples.txt +104 -0
- data/spec/fixtures/config.yaml +1 -0
- data/spec/spec_helper.rb +1 -1
- data/vendor/kreuzberg/Cargo.toml +42 -112
- data/vendor/kreuzberg/README.md +2 -2
- data/vendor/kreuzberg/build.rs +4 -18
- data/vendor/kreuzberg/src/bin/profile_extract.rs +455 -0
- data/vendor/kreuzberg/src/cache/mod.rs +3 -27
- data/vendor/kreuzberg/src/core/batch_mode.rs +0 -60
- data/vendor/kreuzberg/src/core/extractor.rs +81 -202
- data/vendor/kreuzberg/src/core/io.rs +2 -4
- data/vendor/kreuzberg/src/core/mime.rs +12 -2
- data/vendor/kreuzberg/src/core/mod.rs +1 -4
- data/vendor/kreuzberg/src/core/pipeline.rs +33 -111
- data/vendor/kreuzberg/src/embeddings.rs +16 -125
- data/vendor/kreuzberg/src/error.rs +1 -1
- data/vendor/kreuzberg/src/extraction/docx.rs +1 -1
- data/vendor/kreuzberg/src/extraction/image.rs +13 -13
- data/vendor/kreuzberg/src/extraction/libreoffice.rs +1 -0
- data/vendor/kreuzberg/src/extraction/mod.rs +5 -9
- data/vendor/kreuzberg/src/extraction/office_metadata/mod.rs +0 -2
- data/vendor/kreuzberg/src/extraction/pandoc/batch.rs +275 -0
- data/vendor/kreuzberg/src/extraction/pandoc/mime_types.rs +178 -0
- data/vendor/kreuzberg/src/extraction/pandoc/mod.rs +491 -0
- data/vendor/kreuzberg/src/extraction/pandoc/server.rs +496 -0
- data/vendor/kreuzberg/src/extraction/pandoc/subprocess.rs +1188 -0
- data/vendor/kreuzberg/src/extraction/pandoc/version.rs +162 -0
- data/vendor/kreuzberg/src/extractors/archive.rs +0 -21
- data/vendor/kreuzberg/src/extractors/docx.rs +128 -16
- data/vendor/kreuzberg/src/extractors/email.rs +0 -14
- data/vendor/kreuzberg/src/extractors/excel.rs +20 -19
- data/vendor/kreuzberg/src/extractors/html.rs +154 -137
- data/vendor/kreuzberg/src/extractors/image.rs +4 -7
- data/vendor/kreuzberg/src/extractors/mod.rs +9 -106
- data/vendor/kreuzberg/src/extractors/pandoc.rs +201 -0
- data/vendor/kreuzberg/src/extractors/pdf.rs +15 -12
- data/vendor/kreuzberg/src/extractors/pptx.rs +3 -17
- data/vendor/kreuzberg/src/extractors/structured.rs +0 -14
- data/vendor/kreuzberg/src/extractors/text.rs +5 -23
- data/vendor/kreuzberg/src/extractors/xml.rs +0 -7
- data/vendor/kreuzberg/src/keywords/rake.rs +1 -0
- data/vendor/kreuzberg/src/lib.rs +1 -4
- data/vendor/kreuzberg/src/mcp/mod.rs +1 -1
- data/vendor/kreuzberg/src/mcp/server.rs +3 -5
- data/vendor/kreuzberg/src/ocr/processor.rs +2 -18
- data/vendor/kreuzberg/src/pdf/error.rs +1 -1
- data/vendor/kreuzberg/src/pdf/table.rs +44 -17
- data/vendor/kreuzberg/src/pdf/text.rs +3 -0
- data/vendor/kreuzberg/src/plugins/extractor.rs +5 -8
- data/vendor/kreuzberg/src/plugins/ocr.rs +11 -2
- data/vendor/kreuzberg/src/plugins/processor.rs +1 -2
- data/vendor/kreuzberg/src/plugins/registry.rs +0 -13
- data/vendor/kreuzberg/src/plugins/validator.rs +8 -9
- data/vendor/kreuzberg/src/stopwords/mod.rs +2 -2
- data/vendor/kreuzberg/src/types.rs +12 -42
- data/vendor/kreuzberg/tests/batch_orchestration.rs +5 -19
- data/vendor/kreuzberg/tests/batch_processing.rs +3 -15
- data/vendor/kreuzberg/tests/chunking_offset_demo.rs +92 -0
- data/vendor/kreuzberg/tests/concurrency_stress.rs +1 -17
- data/vendor/kreuzberg/tests/config_features.rs +0 -18
- data/vendor/kreuzberg/tests/config_loading_tests.rs +39 -15
- data/vendor/kreuzberg/tests/core_integration.rs +7 -24
- data/vendor/kreuzberg/tests/csv_integration.rs +81 -71
- data/vendor/kreuzberg/tests/docx_metadata_extraction_test.rs +25 -23
- data/vendor/kreuzberg/tests/pandoc_integration.rs +503 -0
- data/vendor/kreuzberg/tests/pipeline_integration.rs +1 -0
- data/vendor/kreuzberg/tests/plugin_postprocessor_test.rs +1 -0
- data/vendor/kreuzberg/tests/registry_integration_tests.rs +22 -1
- data/vendor/kreuzberg/tests/security_validation.rs +1 -12
- metadata +25 -90
- data/.rubocop.yml +0 -538
- data/ext/kreuzberg_rb/native/Cargo.lock +0 -6535
- data/lib/kreuzberg/error_context.rb +0 -32
- data/vendor/kreuzberg/benches/otel_overhead.rs +0 -48
- data/vendor/kreuzberg/src/extraction/markdown.rs +0 -213
- data/vendor/kreuzberg/src/extraction/office_metadata/odt_properties.rs +0 -287
- data/vendor/kreuzberg/src/extractors/bibtex.rs +0 -469
- data/vendor/kreuzberg/src/extractors/docbook.rs +0 -502
- data/vendor/kreuzberg/src/extractors/epub.rs +0 -707
- data/vendor/kreuzberg/src/extractors/fictionbook.rs +0 -491
- data/vendor/kreuzberg/src/extractors/fictionbook.rs.backup2 +0 -738
- data/vendor/kreuzberg/src/extractors/jats.rs +0 -1051
- data/vendor/kreuzberg/src/extractors/jupyter.rs +0 -367
- data/vendor/kreuzberg/src/extractors/latex.rs +0 -652
- data/vendor/kreuzberg/src/extractors/markdown.rs +0 -700
- data/vendor/kreuzberg/src/extractors/odt.rs +0 -628
- data/vendor/kreuzberg/src/extractors/opml.rs +0 -634
- data/vendor/kreuzberg/src/extractors/orgmode.rs +0 -528
- data/vendor/kreuzberg/src/extractors/rst.rs +0 -576
- data/vendor/kreuzberg/src/extractors/rtf.rs +0 -810
- data/vendor/kreuzberg/src/extractors/security.rs +0 -484
- data/vendor/kreuzberg/src/extractors/security_tests.rs +0 -367
- data/vendor/kreuzberg/src/extractors/typst.rs +0 -650
- data/vendor/kreuzberg/src/panic_context.rs +0 -154
- data/vendor/kreuzberg/tests/api_extract_multipart.rs +0 -52
- data/vendor/kreuzberg/tests/bibtex_parity_test.rs +0 -421
- data/vendor/kreuzberg/tests/docbook_extractor_tests.rs +0 -498
- data/vendor/kreuzberg/tests/docx_vs_pandoc_comparison.rs +0 -370
- data/vendor/kreuzberg/tests/epub_native_extractor_tests.rs +0 -275
- data/vendor/kreuzberg/tests/fictionbook_extractor_tests.rs +0 -228
- data/vendor/kreuzberg/tests/html_table_test.rs +0 -551
- data/vendor/kreuzberg/tests/instrumentation_test.rs +0 -139
- data/vendor/kreuzberg/tests/jats_extractor_tests.rs +0 -639
- data/vendor/kreuzberg/tests/jupyter_extractor_tests.rs +0 -704
- data/vendor/kreuzberg/tests/latex_extractor_tests.rs +0 -496
- data/vendor/kreuzberg/tests/markdown_extractor_tests.rs +0 -490
- data/vendor/kreuzberg/tests/odt_extractor_tests.rs +0 -695
- data/vendor/kreuzberg/tests/opml_extractor_tests.rs +0 -616
- data/vendor/kreuzberg/tests/orgmode_extractor_tests.rs +0 -822
- data/vendor/kreuzberg/tests/rst_extractor_tests.rs +0 -692
- data/vendor/kreuzberg/tests/rtf_extractor_tests.rs +0 -776
- data/vendor/kreuzberg/tests/typst_behavioral_tests.rs +0 -1259
- data/vendor/kreuzberg/tests/typst_extractor_tests.rs +0 -647
- data/vendor/rb-sys/.cargo-ok +0 -1
- data/vendor/rb-sys/.cargo_vcs_info.json +0 -6
- data/vendor/rb-sys/Cargo.lock +0 -393
- data/vendor/rb-sys/Cargo.toml +0 -70
- data/vendor/rb-sys/Cargo.toml.orig +0 -57
- data/vendor/rb-sys/LICENSE-APACHE +0 -190
- data/vendor/rb-sys/LICENSE-MIT +0 -21
- data/vendor/rb-sys/bin/release.sh +0 -21
- data/vendor/rb-sys/build/features.rs +0 -108
- data/vendor/rb-sys/build/main.rs +0 -246
- data/vendor/rb-sys/build/stable_api_config.rs +0 -153
- data/vendor/rb-sys/build/version.rs +0 -48
- data/vendor/rb-sys/readme.md +0 -36
- data/vendor/rb-sys/src/bindings.rs +0 -21
- data/vendor/rb-sys/src/hidden.rs +0 -11
- data/vendor/rb-sys/src/lib.rs +0 -34
- data/vendor/rb-sys/src/macros.rs +0 -371
- data/vendor/rb-sys/src/memory.rs +0 -53
- data/vendor/rb-sys/src/ruby_abi_version.rs +0 -38
- data/vendor/rb-sys/src/special_consts.rs +0 -31
- data/vendor/rb-sys/src/stable_api/compiled.c +0 -179
- data/vendor/rb-sys/src/stable_api/compiled.rs +0 -257
- data/vendor/rb-sys/src/stable_api/ruby_2_6.rs +0 -316
- data/vendor/rb-sys/src/stable_api/ruby_2_7.rs +0 -316
- data/vendor/rb-sys/src/stable_api/ruby_3_0.rs +0 -324
- data/vendor/rb-sys/src/stable_api/ruby_3_1.rs +0 -317
- data/vendor/rb-sys/src/stable_api/ruby_3_2.rs +0 -315
- data/vendor/rb-sys/src/stable_api/ruby_3_3.rs +0 -326
- data/vendor/rb-sys/src/stable_api/ruby_3_4.rs +0 -327
- data/vendor/rb-sys/src/stable_api.rs +0 -261
- data/vendor/rb-sys/src/symbol.rs +0 -31
- data/vendor/rb-sys/src/tracking_allocator.rs +0 -332
- data/vendor/rb-sys/src/utils.rs +0 -89
- data/vendor/rb-sys/src/value_type.rs +0 -7
|
@@ -1,496 +0,0 @@
|
|
|
1
|
-
//! Comprehensive LaTeX Extractor Tests
|
|
2
|
-
//!
|
|
3
|
-
//! This test suite defines the expected behavior for LaTeX extraction.
|
|
4
|
-
//!
|
|
5
|
-
//! Test Coverage:
|
|
6
|
-
//! - Basic content extraction (minimal.tex)
|
|
7
|
-
//! - Section hierarchy (basic_sections.tex)
|
|
8
|
-
//! - Text formatting (formatting.tex)
|
|
9
|
-
//! - Mathematical expressions (math.tex)
|
|
10
|
-
//! - Tables (tables.tex)
|
|
11
|
-
//! - Lists (lists.tex)
|
|
12
|
-
//! - Unicode handling (unicode.tex)
|
|
13
|
-
//!
|
|
14
|
-
//! Success Criteria:
|
|
15
|
-
//! - All tests passing (100%)
|
|
16
|
-
//! - No content loss (extract meaningful content)
|
|
17
|
-
|
|
18
|
-
#![cfg(feature = "office")]
|
|
19
|
-
|
|
20
|
-
use kreuzberg::core::config::ExtractionConfig;
|
|
21
|
-
use kreuzberg::extractors::latex::LatexExtractor;
|
|
22
|
-
use kreuzberg::plugins::DocumentExtractor;
|
|
23
|
-
use std::fs;
|
|
24
|
-
use std::path::PathBuf;
|
|
25
|
-
|
|
26
|
-
/// Helper to get absolute path to test documents
|
|
27
|
-
fn test_file_path(filename: &str) -> PathBuf {
|
|
28
|
-
let manifest_dir = env!("CARGO_MANIFEST_DIR");
|
|
29
|
-
PathBuf::from(manifest_dir)
|
|
30
|
-
.parent()
|
|
31
|
-
.unwrap()
|
|
32
|
-
.parent()
|
|
33
|
-
.unwrap()
|
|
34
|
-
.join("test_documents")
|
|
35
|
-
.join("latex")
|
|
36
|
-
.join(filename)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
#[tokio::test]
|
|
40
|
-
async fn test_latex_minimal_extraction() {
|
|
41
|
-
let content = fs::read(test_file_path("minimal.tex")).expect("Failed to read minimal.tex");
|
|
42
|
-
|
|
43
|
-
let extractor = LatexExtractor::new();
|
|
44
|
-
let result = extractor
|
|
45
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
46
|
-
.await
|
|
47
|
-
.expect("Should extract minimal LaTeX");
|
|
48
|
-
|
|
49
|
-
assert!(
|
|
50
|
-
!result.content.is_empty(),
|
|
51
|
-
"FAIL: Extracted 0 bytes (current bug). Should extract content from minimal.tex"
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
assert!(
|
|
55
|
-
result.content.contains("Hello World from LaTeX!"),
|
|
56
|
-
"FAIL: Should extract 'Hello World from LaTeX!' but got: '{}'",
|
|
57
|
-
result.content
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
#[tokio::test]
|
|
62
|
-
async fn test_latex_metadata_extraction() {
|
|
63
|
-
let content = fs::read(test_file_path("basic_sections.tex")).expect("Failed to read basic_sections.tex");
|
|
64
|
-
|
|
65
|
-
let extractor = LatexExtractor::new();
|
|
66
|
-
let result = extractor
|
|
67
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
68
|
-
.await
|
|
69
|
-
.expect("Should extract LaTeX with metadata");
|
|
70
|
-
|
|
71
|
-
assert_eq!(
|
|
72
|
-
result.metadata.additional.get("title").and_then(|v| v.as_str()),
|
|
73
|
-
Some("Test Document"),
|
|
74
|
-
"FAIL: Should extract title 'Test Document' from \\title{{}} command"
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
assert_eq!(
|
|
78
|
-
result.metadata.additional.get("author").and_then(|v| v.as_str()),
|
|
79
|
-
Some("John Doe"),
|
|
80
|
-
"FAIL: Should extract author 'John Doe' from \\author{{}} command"
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
assert_eq!(
|
|
84
|
-
result.metadata.additional.get("date").and_then(|v| v.as_str()),
|
|
85
|
-
Some("2025-12-07"),
|
|
86
|
-
"FAIL: Should extract date '2025-12-07' from \\date{{}} command"
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#[tokio::test]
|
|
91
|
-
async fn test_latex_section_hierarchy() {
|
|
92
|
-
let content = fs::read(test_file_path("basic_sections.tex")).expect("Failed to read basic_sections.tex");
|
|
93
|
-
|
|
94
|
-
let extractor = LatexExtractor::new();
|
|
95
|
-
let result = extractor
|
|
96
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
97
|
-
.await
|
|
98
|
-
.expect("Should extract LaTeX sections");
|
|
99
|
-
|
|
100
|
-
assert!(
|
|
101
|
-
result.content.contains("Introduction"),
|
|
102
|
-
"FAIL: Should extract \\section{{Introduction}} as text"
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
assert!(
|
|
106
|
-
result.content.contains("Methods"),
|
|
107
|
-
"FAIL: Should extract \\section{{Methods}} as text"
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
assert!(
|
|
111
|
-
result.content.contains("Results"),
|
|
112
|
-
"FAIL: Should extract \\section{{Results}} as text"
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
assert!(
|
|
116
|
-
result.content.contains("Background"),
|
|
117
|
-
"FAIL: Should extract \\subsection{{Background}} as text"
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
assert!(
|
|
121
|
-
result.content.contains("Historical Context"),
|
|
122
|
-
"FAIL: Should extract \\subsubsection{{Historical Context}} as text"
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
assert!(
|
|
126
|
-
result.content.contains("This is the introduction paragraph"),
|
|
127
|
-
"FAIL: Should extract paragraph text from document body"
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
#[tokio::test]
|
|
132
|
-
async fn test_latex_text_formatting() {
|
|
133
|
-
let content = fs::read(test_file_path("formatting.tex")).expect("Failed to read formatting.tex");
|
|
134
|
-
|
|
135
|
-
let extractor = LatexExtractor::new();
|
|
136
|
-
let result = extractor
|
|
137
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
138
|
-
.await
|
|
139
|
-
.expect("Should extract LaTeX formatting");
|
|
140
|
-
|
|
141
|
-
assert!(
|
|
142
|
-
result.content.contains("Text Formatting"),
|
|
143
|
-
"FAIL: Should extract \\section{{Text Formatting}}"
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
assert!(
|
|
147
|
-
result.content.contains("This is normal text"),
|
|
148
|
-
"FAIL: Should extract plain paragraph text"
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
assert!(
|
|
152
|
-
result.content.contains("bold text"),
|
|
153
|
-
"FAIL: Should extract text from \\textbf{{bold text}}"
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
assert!(
|
|
157
|
-
result.content.contains("italic text"),
|
|
158
|
-
"FAIL: Should extract text from \\textit{{italic text}}"
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
assert!(
|
|
162
|
-
result.content.contains("underlined text"),
|
|
163
|
-
"FAIL: Should extract text from \\underline{{underlined text}}"
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
assert!(
|
|
167
|
-
result.content.contains("emphasized text"),
|
|
168
|
-
"FAIL: Should extract text from \\emph{{emphasized text}}"
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
assert!(
|
|
172
|
-
result.content.contains("monospace text"),
|
|
173
|
-
"FAIL: Should extract text from \\texttt{{monospace text}}"
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
assert!(
|
|
177
|
-
result.content.contains("bold and italic"),
|
|
178
|
-
"FAIL: Should extract text from nested formatting commands"
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
#[tokio::test]
|
|
183
|
-
async fn test_latex_math_extraction() {
|
|
184
|
-
let content = fs::read(test_file_path("math.tex")).expect("Failed to read math.tex");
|
|
185
|
-
|
|
186
|
-
let extractor = LatexExtractor::new();
|
|
187
|
-
let result = extractor
|
|
188
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
189
|
-
.await
|
|
190
|
-
.expect("Should extract LaTeX math");
|
|
191
|
-
|
|
192
|
-
assert!(
|
|
193
|
-
result.content.contains("Math Formulas"),
|
|
194
|
-
"FAIL: Should extract \\section{{Math Formulas}}"
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
assert!(
|
|
198
|
-
result.content.contains("Inline Math"),
|
|
199
|
-
"FAIL: Should extract \\subsection{{Inline Math}}"
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
assert!(
|
|
203
|
-
result.content.contains("Display Math"),
|
|
204
|
-
"FAIL: Should extract \\subsection{{Display Math}}"
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
assert!(
|
|
208
|
-
result.content.contains("mc") || result.content.contains("mc²"),
|
|
209
|
-
"FAIL: Should extract inline math content from $E = mc^2$"
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
assert!(
|
|
213
|
-
result.content.contains("The equation"),
|
|
214
|
-
"FAIL: Should extract text before inline math"
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
assert!(
|
|
218
|
-
result.content.contains("is famous"),
|
|
219
|
-
"FAIL: Should extract text after inline math"
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
assert!(
|
|
223
|
-
result.content.contains("int") || result.content.contains("∫"),
|
|
224
|
-
"FAIL: Should extract display math environment content"
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
#[tokio::test]
|
|
229
|
-
async fn test_latex_table_extraction() {
|
|
230
|
-
let content = fs::read(test_file_path("tables.tex")).expect("Failed to read tables.tex");
|
|
231
|
-
|
|
232
|
-
let extractor = LatexExtractor::new();
|
|
233
|
-
let result = extractor
|
|
234
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
235
|
-
.await
|
|
236
|
-
.expect("Should extract LaTeX tables");
|
|
237
|
-
|
|
238
|
-
assert!(
|
|
239
|
-
result.content.contains("Tables"),
|
|
240
|
-
"FAIL: Should extract \\section{{Tables}}"
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
assert!(
|
|
244
|
-
result.content.contains("Name"),
|
|
245
|
-
"FAIL: Should extract table header 'Name' from tabular"
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
assert!(
|
|
249
|
-
result.content.contains("Age"),
|
|
250
|
-
"FAIL: Should extract table header 'Age' from tabular"
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
assert!(
|
|
254
|
-
result.content.contains("Score"),
|
|
255
|
-
"FAIL: Should extract table header 'Score' from tabular"
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
assert!(
|
|
259
|
-
result.content.contains("Alice"),
|
|
260
|
-
"FAIL: Should extract table cell 'Alice'"
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
assert!(result.content.contains("30"), "FAIL: Should extract table cell '30'");
|
|
264
|
-
|
|
265
|
-
assert!(result.content.contains("95"), "FAIL: Should extract table cell '95'");
|
|
266
|
-
|
|
267
|
-
assert!(result.content.contains("Bob"), "FAIL: Should extract table cell 'Bob'");
|
|
268
|
-
|
|
269
|
-
assert!(
|
|
270
|
-
result.content.contains("Charlie"),
|
|
271
|
-
"FAIL: Should extract table cell 'Charlie'"
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
assert!(
|
|
275
|
-
result.content.contains("Column 1"),
|
|
276
|
-
"FAIL: Should extract 'Column 1' from second table"
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
assert!(
|
|
280
|
-
result.content.contains("Column 2"),
|
|
281
|
-
"FAIL: Should extract 'Column 2' from second table"
|
|
282
|
-
);
|
|
283
|
-
|
|
284
|
-
assert!(
|
|
285
|
-
result.content.contains("Sample table with caption"),
|
|
286
|
-
"FAIL: Should extract table caption from \\caption{{}}"
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
#[tokio::test]
|
|
291
|
-
async fn test_latex_list_itemize() {
|
|
292
|
-
let content = fs::read(test_file_path("lists.tex")).expect("Failed to read lists.tex");
|
|
293
|
-
|
|
294
|
-
let extractor = LatexExtractor::new();
|
|
295
|
-
let result = extractor
|
|
296
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
297
|
-
.await
|
|
298
|
-
.expect("Should extract LaTeX lists");
|
|
299
|
-
|
|
300
|
-
assert!(
|
|
301
|
-
result.content.contains("First item"),
|
|
302
|
-
"FAIL: Should extract \\item First item from itemize"
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
assert!(
|
|
306
|
-
result.content.contains("Second item"),
|
|
307
|
-
"FAIL: Should extract \\item Second item from itemize"
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
assert!(
|
|
311
|
-
result.content.contains("Third item with nested list"),
|
|
312
|
-
"FAIL: Should extract \\item Third item with nested list"
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
assert!(
|
|
316
|
-
result.content.contains("Fourth item"),
|
|
317
|
-
"FAIL: Should extract \\item Fourth item from itemize"
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
#[tokio::test]
|
|
322
|
-
async fn test_latex_list_nested() {
|
|
323
|
-
let content = fs::read(test_file_path("lists.tex")).expect("Failed to read lists.tex");
|
|
324
|
-
|
|
325
|
-
let extractor = LatexExtractor::new();
|
|
326
|
-
let result = extractor
|
|
327
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
328
|
-
.await
|
|
329
|
-
.expect("Should extract LaTeX nested lists");
|
|
330
|
-
|
|
331
|
-
assert!(
|
|
332
|
-
result.content.contains("Nested item 1"),
|
|
333
|
-
"FAIL: Should extract nested \\item Nested item 1"
|
|
334
|
-
);
|
|
335
|
-
|
|
336
|
-
assert!(
|
|
337
|
-
result.content.contains("Nested item 2"),
|
|
338
|
-
"FAIL: Should extract nested \\item Nested item 2"
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
#[tokio::test]
|
|
343
|
-
async fn test_latex_list_enumerate() {
|
|
344
|
-
let content = fs::read(test_file_path("lists.tex")).expect("Failed to read lists.tex");
|
|
345
|
-
|
|
346
|
-
let extractor = LatexExtractor::new();
|
|
347
|
-
let result = extractor
|
|
348
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
349
|
-
.await
|
|
350
|
-
.expect("Should extract LaTeX enumerate");
|
|
351
|
-
|
|
352
|
-
assert!(
|
|
353
|
-
result.content.contains("First numbered item"),
|
|
354
|
-
"FAIL: Should extract \\item First numbered item from enumerate"
|
|
355
|
-
);
|
|
356
|
-
|
|
357
|
-
assert!(
|
|
358
|
-
result.content.contains("Second numbered item"),
|
|
359
|
-
"FAIL: Should extract \\item Second numbered item from enumerate"
|
|
360
|
-
);
|
|
361
|
-
|
|
362
|
-
assert!(
|
|
363
|
-
result.content.contains("Third numbered item"),
|
|
364
|
-
"FAIL: Should extract \\item Third numbered item from enumerate"
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
#[tokio::test]
|
|
369
|
-
async fn test_latex_list_description() {
|
|
370
|
-
let content = fs::read(test_file_path("lists.tex")).expect("Failed to read lists.tex");
|
|
371
|
-
|
|
372
|
-
let extractor = LatexExtractor::new();
|
|
373
|
-
let result = extractor
|
|
374
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
375
|
-
.await
|
|
376
|
-
.expect("Should extract LaTeX description lists");
|
|
377
|
-
|
|
378
|
-
assert!(
|
|
379
|
-
result.content.contains("Term 1"),
|
|
380
|
-
"FAIL: Should extract \\item[Term 1] from description list"
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
assert!(
|
|
384
|
-
result.content.contains("Definition of term 1"),
|
|
385
|
-
"FAIL: Should extract definition text from description list"
|
|
386
|
-
);
|
|
387
|
-
|
|
388
|
-
assert!(
|
|
389
|
-
result.content.contains("Term 2"),
|
|
390
|
-
"FAIL: Should extract \\item[Term 2] from description list"
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
assert!(
|
|
394
|
-
result.content.contains("Definition of term 2"),
|
|
395
|
-
"FAIL: Should extract definition text from description list"
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
#[tokio::test]
|
|
400
|
-
async fn test_latex_lists_pandoc_parity() {
|
|
401
|
-
let content = fs::read(test_file_path("lists.tex")).expect("Failed to read lists.tex");
|
|
402
|
-
|
|
403
|
-
let extractor = LatexExtractor::new();
|
|
404
|
-
let _result = extractor
|
|
405
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
406
|
-
.await
|
|
407
|
-
.expect("Should extract LaTeX lists");
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
#[tokio::test]
|
|
411
|
-
async fn test_latex_unicode_handling() {
|
|
412
|
-
let content = fs::read(test_file_path("unicode.tex")).expect("Failed to read unicode.tex");
|
|
413
|
-
|
|
414
|
-
let extractor = LatexExtractor::new();
|
|
415
|
-
let result = extractor
|
|
416
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
417
|
-
.await
|
|
418
|
-
.expect("Should extract LaTeX with Unicode");
|
|
419
|
-
|
|
420
|
-
assert!(
|
|
421
|
-
result.content.contains("אֳרָנִים") || result.content.contains("Hebrew"),
|
|
422
|
-
"FAIL: Should extract Hebrew characters or 'Hebrew' text"
|
|
423
|
-
);
|
|
424
|
-
|
|
425
|
-
assert!(
|
|
426
|
-
!result.content.is_empty(),
|
|
427
|
-
"FAIL: Should extract non-zero content from unicode.tex"
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
#[tokio::test]
|
|
432
|
-
async fn test_latex_no_content_loss_bug() {
|
|
433
|
-
let content = fs::read(test_file_path("minimal.tex")).expect("Failed to read minimal.tex");
|
|
434
|
-
|
|
435
|
-
let extractor = LatexExtractor::new();
|
|
436
|
-
let result = extractor
|
|
437
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
438
|
-
.await
|
|
439
|
-
.expect("Should extract minimal LaTeX");
|
|
440
|
-
|
|
441
|
-
assert!(
|
|
442
|
-
!result.content.is_empty(),
|
|
443
|
-
"FAIL: CRITICAL BUG - Extracted 0 bytes from minimal.tex. Current LaTeX extractor is completely broken."
|
|
444
|
-
);
|
|
445
|
-
|
|
446
|
-
assert!(
|
|
447
|
-
result.content.len() >= 10,
|
|
448
|
-
"FAIL: Extracted only {} bytes, expected at least 10. Content: '{}'",
|
|
449
|
-
result.content.len(),
|
|
450
|
-
result.content
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
#[tokio::test]
|
|
455
|
-
async fn test_latex_extraction_deterministic() {
|
|
456
|
-
let content = fs::read(test_file_path("minimal.tex")).expect("Failed to read minimal.tex");
|
|
457
|
-
|
|
458
|
-
let extractor = LatexExtractor::new();
|
|
459
|
-
|
|
460
|
-
let result1 = extractor
|
|
461
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
462
|
-
.await
|
|
463
|
-
.expect("Should extract LaTeX (first run)");
|
|
464
|
-
|
|
465
|
-
let result2 = extractor
|
|
466
|
-
.extract_bytes(&content, "text/x-tex", &ExtractionConfig::default())
|
|
467
|
-
.await
|
|
468
|
-
.expect("Should extract LaTeX (second run)");
|
|
469
|
-
|
|
470
|
-
assert_eq!(
|
|
471
|
-
result1.content, result2.content,
|
|
472
|
-
"FAIL: Extraction is not deterministic. Same input produced different outputs."
|
|
473
|
-
);
|
|
474
|
-
|
|
475
|
-
assert_eq!(
|
|
476
|
-
result1.metadata.additional, result2.metadata.additional,
|
|
477
|
-
"FAIL: Metadata extraction is not deterministic."
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
#[tokio::test]
|
|
482
|
-
async fn test_latex_empty_document_handling() {
|
|
483
|
-
let empty_latex = b"\\documentclass{article}\n\\begin{document}\n\\end{document}";
|
|
484
|
-
|
|
485
|
-
let extractor = LatexExtractor::new();
|
|
486
|
-
let result = extractor
|
|
487
|
-
.extract_bytes(empty_latex, "text/x-tex", &ExtractionConfig::default())
|
|
488
|
-
.await
|
|
489
|
-
.expect("Should handle empty LaTeX without panicking");
|
|
490
|
-
|
|
491
|
-
assert!(
|
|
492
|
-
result.content.trim().is_empty(),
|
|
493
|
-
"Empty document should produce empty content (got: '{}')",
|
|
494
|
-
result.content
|
|
495
|
-
);
|
|
496
|
-
}
|