Files
Kevin JosephandNghiathan13 6242f65262 craft-docx: a table border without w:sz is width 0, and ODT and RTF keep it (#2203)
* craft-docx: a DOCX border without w:sz is an eighth of a point

* craft-docx: a table border without w:sz is width 0, and ODT and RTF keep it

A table, cell or table-style border without w:sz gives the same output in
Word as w:sz="0" and takes no room; read as half a point, rows below a
pandoc table's header rule moved down half a point. PropCtx::table_borders
now reads it as 0, as PropCtx::borders does since #1488.

ODT and RTF have no border that is drawn and takes no room, so a drawn
width-0 cell side is written at Border::THINNEST instead of being dropped.
Where two ODT cells share an edge, a line with a width wins over a width-0
one, whichever cell states it.

Table half of storytold/wordcraft#5764.

---------

Co-authored-by: Nghiathan13 <201675788+Nghiathan13@users.noreply.github.com>
2026-11-18 15:35:29 -05:00
..

craft-flow

The model every text format maps to and from: a Flow is blocks, a block a paragraph (Para: a Kind — normal, heading, title, quote, code line, rule — list membership, alignment, spacing and formatted Inline spans: text, pictures, links, bookmarks, fields, notes, equations, ruby, charts, shapes) or a table (FTable of Cells holding blocks), with the document's Meta.

to_doc and from_doc convert a flow to and from a craft_wordmodel::Document. A format reader builds a flow and calls to_doc; a writer calls from_doc (or from_doc_with and FlowOpts for what that format keeps: fields, boxes, paragraph formatting, tracked changes) and walks the flow. Formats that keep more than the flow holds (ODT) carry it in the optional fields (extra, kept, …), which the plain formats leave empty.

use craft_flow::{FBlock, Flow, Fmt, Inline, Kind, Para, from_doc, to_doc};

let p = Para { kind: Kind::Heading(1), inlines: vec![Inline::Text("Title".into(), Fmt::default())], ..Default::default() };
let doc = to_doc(&Flow { blocks: vec![FBlock::Para(p)], ..Default::default() });
let back = from_doc(&doc);
assert!(matches!(&back.blocks[..], [FBlock::Para(p)] if p.kind == Kind::Heading(1) && p.text() == "Title"));

Also here: picture sniffing and sizing (sniff_image, image_px, make_img), CSS colours (parse_color), base64 and data: URIs, list labels (ListCounter), and the one-warning-per-kind report of what an importer leaves out to stay within a limit (Dropped, begin_import, dropped).

Provenance

WordCraft's crates/formats/src/model (at 07f97737), moved as it is onto craft-wordmodel. Image decoding for re-encoding (decode_bounded) stays with the RTF writer that needs it.