1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Input format adapters for the conversion pipeline.
//!
//! This module defines the [`AstExtractor`] trait and provides the built-in
//! [`DocxExtractor`]. Implement `AstExtractor` to customize how DOCX body
//! content is transformed into a [`DocumentAst`](crate::core::ast::DocumentAst),
//! then pass it to
//! [`DocxToMarkdown::with_components`](crate::DocxToMarkdown::with_components).
use crateConversionContext;
use crateDocumentAst;
use crateResult;
use BodyContent;
/// Extracts a [`DocumentAst`](crate::core::ast::DocumentAst) from parsed DOCX
/// body content.
///
/// The default implementation is [`DocxExtractor`], which delegates to
/// specialized converters for paragraphs, tables, and runs. To use a custom
/// extractor, pass it to
/// [`DocxToMarkdown::with_components`](crate::DocxToMarkdown::with_components).
///
/// # Implementing
///
/// ```no_run
/// use undocx::adapters::docx::AstExtractor;
/// use undocx::converter::ConversionContext;
/// use undocx::core::ast::{BlockNode, DocumentAst};
/// use undocx::Result;
/// use rs_docx::document::BodyContent;
///
/// struct MyExtractor;
///
/// impl AstExtractor for MyExtractor {
/// fn extract<'a>(
/// &self,
/// body: &[BodyContent<'a>],
/// context: &mut ConversionContext<'a>,
/// ) -> Result<DocumentAst> {
/// Ok(DocumentAst::default())
/// }
/// }
/// ```
///
/// # Errors
///
/// Returns [`Error`](crate::Error) if extraction fails (e.g., an I/O error
/// while reading an embedded image).
pub use DocxExtractor;