Module paragraph

Module paragraph 

Source
Expand description

Paragraph: a sequence of runs with a paragraph shape reference.

Paragraph aggregates Run objects and holds a ParaShapeIndex reference to the paragraph shape (alignment, spacing, indentation) defined in Blueprint.

§Design Decisions

  • Vec<Run> not SmallVec<[Run; 5]> – YAGNI. SmallVec would bloat each Paragraph from ~40 bytes to ~220 bytes with no profiling evidence that allocation is a bottleneck. Migration to SmallVec is a non-breaking internal change if needed later.

  • No raw_xml / raw_binary – raw preservation belongs in the Smithy layer, not the format-agnostic domain model.

§Examples

use hwpforge_core::paragraph::Paragraph;
use hwpforge_core::run::Run;
use hwpforge_foundation::{CharShapeIndex, ParaShapeIndex};

let mut para = Paragraph::new(ParaShapeIndex::new(0));
para.add_run(Run::text("Hello ", CharShapeIndex::new(0)));
para.add_run(Run::text("world!", CharShapeIndex::new(1)));
assert_eq!(para.text_content(), "Hello world!");
assert_eq!(para.run_count(), 2);

Structs§

Paragraph
A paragraph: an ordered sequence of runs sharing a paragraph shape.