docx_review_core/model/block.rs
1use serde::{Deserialize, Serialize};
2
3use super::{BlockId, Story, TextSpan};
4
5/// A normalized textual unit extracted from a DOCX story.
6#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
7#[non_exhaustive]
8pub struct Block {
9 /// Stable identifier for this block.
10 pub id: BlockId,
11 /// The story this block belongs to.
12 pub story: Story,
13 /// Semantic kind of block.
14 pub kind: BlockKind,
15 /// Current-view text content for this block.
16 pub text: String,
17 /// Optional style name when mapped by the extractor.
18 pub style: Option<String>,
19 /// Optional tracked-change markers aligned to visible text.
20 pub text_spans: Option<Vec<TextSpan>>,
21 /// Referenced footnote ids that appear inline in this block.
22 pub footnote_refs: Vec<u32>,
23 /// Referenced endnote ids that appear inline in this block.
24 pub endnote_refs: Vec<u32>,
25}
26
27/// Semantic classification of a block.
28#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
29#[non_exhaustive]
30pub enum BlockKind {
31 /// A regular paragraph block.
32 Paragraph,
33 /// A heading with extracted level information.
34 Heading { level: u8 },
35 /// A list item with extracted nesting level.
36 ListItem { level: usize },
37 /// A flat table-cell block in the extracted output.
38 TableCell {
39 /// Identifier shared by cells that belong to the same table.
40 table_id: String,
41 /// Zero-based row index.
42 row: usize,
43 /// Zero-based column index.
44 col: usize,
45 },
46}