format-specific-extraction
Format-specific document extraction workflows
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- format-specific-extraction
- priority
- high
- description
- Format-specific document extraction workflows
03 SKILL.md 正文
Format-Specific Extraction Workflows
Office XML (DOCX/PPTX/ODT)
ZIP archive → Security validation → XML parsing → Text + tables + metadata
ZipBombValidator::new(limits).validate(&mut archive)?- Extract XML files from archive (
word/document.xml,ppt/slides/*.xml,content.xml) - Parse with
quick-xml::Reader(streaming) +DepthValidator+StringGrowthValidator - Extract metadata via
crate::extraction::office_metadata::extract_metadata() - See:
extractors/docx.rs,extractors/pptx.rs,extractors/odt.rs
Bytes → pdf_oxide → Per-page text + OCR fallback → Tables → Metadata
pdf_oxide::PdfDocument::from_bytes(content)?- Check if needs OCR:
config.force_ocr || !has_searchable_text() - Extract text per page, tables if
config.pagesenabled - Feature-gated:
#[cfg(feature = "pdf")] - See:
extractors/pdf/mod.rs
Archives (ZIP/TAR/7z/GZIP)
Validate → Extract metadata → Extract plaintext files only
ZipBombValidatorBEFORE any extraction- Extract metadata (file list, sizes)
- Extract text content from plaintext files
- Use
build_archive_result()helper - See:
extractors/archive.rs,extraction/archive/*.rs
Structured Text (JSON/YAML/TOML/XML)
Detect format from MIME → Parse → Pretty-print → Metadata
Single StructuredExtractor handles multiple MIME types. Parse with format-specific library, pretty-print to text.
See: extractors/structured.rs
Email (EML/MSG)
Parse headers → Extract body (text/html) → Process attachments
See: extraction/email.rs, extractors/email.rs
Common Helpers
| Helper | Location | Purpose |
|---|---|---|
office_metadata::extract_metadata() |
extraction/office.rs |
Office XML metadata |
cells_to_markdown() |
extraction/mod.rs |
Convert cell grid to GFM table |
build_archive_result() |
extraction/archive/mod.rs |
Standard archive result |
Adding a New Format
- Add MIME type to
EXT_TO_MIMEincore/mime.rs - Create extractor implementing
DocumentExtractortrait - Set
supported_mime_types()andpriority()(default: 50) - Register in
extractors/mod.rs→register_default_extractors() - Feature-gate if optional:
#[cfg(feature = "my-format")] - Apply security validators for user content
- Add tests with fixture files
04 同仓库更多 Skills
impeccable
Use when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding, and empty states. Handles UX review, visual hierarchy, information architecture, cognitive load, accessibility, performance, responsive behavior, theming, anti-patterns, typography, fonts, spacing, layout, alignment, color, motion, micro-interactions, UX copy, error states, edge cases, i18n, and reusable design systems or tokens. Also use for bland designs that need to become bolder or more delightful, loud designs that should become quieter, live browser iteration on UI elements, or ambitious visual effects that should feel technically extraordinary. Not for backend-only or non-UI tasks.
wasm-constraints
WASM build constraints for the crates/xberg-wasm crate — the wasm-target feature set, no-tokio sync-only internal APIs, the mandatory SyncExtractor trait for WASM-compatible extractors, the 2 MB HTML size limit, size-optimized build config (opt-level="z"), and the async-wrapper/sync-internal API pattern. Load when building for wasm32, adding or modifying a WASM-compatible extractor, or debugging WASM build/runtime failures.
release-versioning
How xberg versions are synced and released — Cargo.toml is the single source of truth, `task version:sync` propagates it to alef-managed binding manifests AND the integrations under integrations/, which are versioned and published in lockstep with core (including -rc.N). Load before bumping a version, editing the version-sync task, or touching an integration's version/xberg dependency.
plugin-architecture-patterns
Plugin architecture, registration, and trait patterns
mime-detection-routing
MIME type detection and extractor routing in core/mime.rs and core/extractor/bytes.rs — the extension→EXT_TO_MIME→validate→registry→extractor flow, key detection functions, the 118+ case-insensitive extension map, priority-based registry selection, wildcard MIME families, and how to add a new MIME type. Load when adding a format, wiring an extractor to a MIME type, or debugging why a file routes to the wrong (or no) extractor.
feature-flag-policy
Cargo feature flags for crates/xberg — ORT-incompatible targets (WASM, Android x86_64 emulator), type-only and tract inference companion features, WASM/Android-safe variants, PDF backend, mutually-exclusive ORT variants, platform-conditional deps, aggregate feature sets, and build profiles. Load when adding, wiring, or debugging a Cargo feature, or when reasoning about what compiles on WASM/Android/Windows/macOS-intel targets.