Files
craft-libs/crates/wordmodel
aiongg ac3dfd1f53 Merge storytold main into next (17 Nov sync)
storytold main 83cb1133dd (291 commits) into the integration head bab1a99b85; 47 conflicted files.

- Domain test files (metafile, prepress, pdf plates, settings store, heif, media-testkit, atomic): tests next cut stay cut; tests new on main are kept, as trials where the crate's test target runs trials.
- atomic: main's group-bits test and Faulty::set_group go to src/tests.rs. audio: main's GSM and SBC oracles join tests/main.rs. cms constructors, pdf knockout_backdrop and testing_pdf join their crates' one test binary; timeline's preflight tests become src/preflight_tests.rs trials.
- update: main's changes to detect, install (linux, macos) and the tests land in next's split modules. The app's own offer is inspected on a thread of its own, picked up by tick's polling; settle_for_tests settles offers too. Later on a ready update drops the close it asked for. updater_pin_tests.rs stays deleted; its new pin test is in tests/it/update.rs.
- craft-color: main added a different crate at crates/color (the colour tags of compositor and display frames); it is next's craft-color module `tags`, re-exported at the root.
- Old crates/ui (combo, docking, testing, README) and keymap's ui/view.rs stay deleted; main's new crates/ui/src/testing files are dropped with them.
- New crates in the craft facade: ai, control, dds, frame, ipc, media-source, palette, press-print, score, ssip. testkit and xtask are listed outside it.
- Cargo.lock: the union of both locks, resolved by cargo metadata. Workflow: main's nextest Windows leg, with next's --keep-going clippy.
2026-11-17 12:44:52 +00:00
..

craft-wordmodel

A word-processing document model: stories, paragraphs, runs, tables, sections, styles, numbering, fields, content controls, notes, comments, revisions, floating objects, drawings and math. It is what the DOCX, RTF, ODT and other text-format crates read into and write from.

It is WordCraft's document model (crates/doc), moved without its editing code. Module paths, type names and serde attributes are as they were, so an app that re-exports the crate keeps its native file format.

use craft_wordmodel::{Block, Document};

let doc = Document::from_text("One\nTwo");
assert_eq!(doc.body.len(), 2);
assert!(matches!(&*doc.body[0], Block::Para(p) if p.text == "One"));

What is here

  • Document: the body story, secondary stories (parts: headers, footers, notes, comments, text boxes), the style sheet, list definitions, comments, revisions, settings, document properties, media and parts kept from the source file.
  • Block, Paragraph, Run, InlineObject, Table: the content. Paragraph text is UTF-8; an inline object stands in the text as U+FFFC (para::OBJ).
  • props, styles, resolve, numbering, section: formatting and its resolution.
  • math, math_latex, math_linear, math_symbols: the equation tree (MNode) and its linear and LaTeX forms.
  • chart, smart_art, graphic, fill, connector, freeform, wordart, effects, picfx, line_dash: drawing objects as the model holds them. Reading and writing their DrawingML is craft-drawingml's job, in the format crates.
  • kept: markup kept from the file a document was read from, so what is not edited is written back as it was.
  • walk, work, geom, bidi, cluster, collate, locale_number, symbol_fonts.

Not here

Range editing, copy and paste, IME text and equation editing stay with the app that edits. Code pages are craft-rtf's codepage, the ZIP entry-count check is craft-opc's.

Limits

The model carries the limits its readers rely on: nesting of tables (table::MAX_TABLE_DEPTH), text boxes (MAX_TEXT_BOX_DEPTH, BoxBudget), math (math::MAX_DEPTH, matrix sizes), group children, alt text length, linked boxes and the walk depth (PARA_WALK_DEPTH). Their tests moved with them.