main split the engine's lib.rs into modules; the as-opened validation is ported: Editor::as_opened and AsOpened in history.rs, editor_signatures in doc_state.rs (used wherever an editor's signatures are validated), the as-read capture in open.rs, and mark_saved clearing it in session/save.rs. The test also pins the saved status (dynamic Invalid, static Valid).
With marks, a page the marks would widen past 14,400 pt was refused only after the
document's Will Print actions ran, so their field change stayed behind a print that
failed. Session::check_printer_marks runs the mark editor on a scratch copy first;
doc_print calls it before Will Print, and the print still adds the marks after it.
Main split organize/src/import.rs into import/{carry,combine,copy,fields}.rs and already made set_attachments UTF-16-safe and indirect-/Names-safe (this PR's other two hunks), so those take main's version. Ported the PR's core change: insert_file_pages now merges the source's catalog attachments via carry::collect_attachments + attachments::entries (made pub(crate)) + set_attachments. PR's engine regression test file kept as-is; parity evidence/notes merged onto main's entries (it/ paths); ROADMAP/docs entries added to main's text. cargo check -p pdfcraft-organize -p pdfcraft-engine --tests passes locally.
A producer may draw a sentence as one text run with a gap and paint the
bold word into it. The prose box then spans the word instead of ending
beside it, so the overlap limit rejected it and the word was suggested
as a heading. Prose whose box spans the line on its row now counts as
beside it; the row, size, style and lower-case conditions are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The beside test required the same size, so a 9 pt bold keyword in 10 pt
prose (RFC 9110 page 16, reported on #6020) was suggested again. A line
now counts as inside a sentence when the prose beside it is no smaller
than it; a heading set larger than run-in text beside it stays a heading.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocks set inside a sentence were removed before the heading rules ran.
The check is symmetric, so prose beside an italic word was removed too,
and a page of such paragraphs lost its body text: the body size became the
heading's, and the heading was dropped. Inline blocks now stay in the
evidence, counting toward the body style, but marked as having no letters,
which the rules never take as a heading.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A bold run inside a paragraph is a text line of its own, so the layout
fallback saw a short bold block where the body is regular and proposed it
as a bookmark. A line now counts as set inside a sentence when prose sits
beside it on the same row: boxes sharing at least half the shorter one's
height, side by side, at most half an em apart, at the same size, in
another style, with a lower-case letter. Such blocks are left out like
captions. The lower-case test keeps a bold title after its section number,
the half-height overlap keeps a heading over tightly set text, and the
half-em gap keeps a heading across a narrow gutter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(rename): separate filename and full-path boundary fixtures
* Preserve repository LF endings in rename test fixtures
* Preserve UTF-8 text in rename fixture repair
---------
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
buttonGetIcon is implemented now, so the script the test used no longer
throws. The test calls a method PdfCraft lacks, as the neighboring
document-script test does, and changes the document script before each edit
because the script realm runs an unchanged document script once.
A branch past the depth or visit limit set `cut`, which then refused
every later node, so a shallow heading after a deep branch was lost.
The limits now only skip the node and report it; only the heading cap
still ends the walk. Marked content past the limit is reported too.
When no tagged heading is found and the suggestion falls back to
layout, the structure walk's truncation is kept in `truncated`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bookmark_suggest's structure path always said truncated: false, though
pdfcraft_a11y::headings stops silently at 10000 headings, at a tree nested
past 256 levels and after a million visits. headings_with_truncation
returns the same list and whether one of those limits stopped the walk
where a heading could have been; headings keeps its signature and output.
The heading cap is now checked when a heading is met, so exactly 10000
headings is not reported as cut.
The tool description told callers to edit levels; a suggested bookmark has
no level and bookmark_import refuses one. It now says to move bookmarks
into or out of children.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bookmark_suggest's pages_read counted a page whose text could not be
read (its content past the page decode allowance) as read, and the
layout cap of 10,000 bookmarks dropped headings without setting
truncated. read_lines now counts the pages it read; the suggestion
carries truncated when pages were not read or more headings than the
cap were found, and the tool returns that. Caption leads (Figure, Fig.,
Table, Chart, Exhibit, Plate) now match in any case, so "FIGURE 3:" is
not suggested as a heading.
Tests: captions_match_in_any_case,
more_headings_than_the_cap_are_reported,
a_page_whose_text_cant_be_read_is_not_counted; each fails with its fix
reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#7814 brought this branch's first two commits to main inside step 2, but not the three
fixes made here since: the RTF picture budget that counts every placement, rotations baked
into the pictures, pictures fitted to the text height, and the pages that lost a picture
reported through truncated_pages. They now sit in step 2's Builder: RTF's flow_doc gives
it a pictures::Budget, and Word's word_doc doesn't, so Word keeps its own limits
(room_for) and turns positioned pictures through their float. The text-height fit is in
the shared picture(), so Word's flowing pictures fit too.
The truncated_pages doc now says what RTF reports: pictures lost to its own limits or a
rotation it couldn't bake. A picture no format can encode is left out of all of them.
* export: write RTF through craft-rtf's full writer, from the word model
The pages are mapped onto a craft_wordmodel::Document (as_word.rs, the
mapping the DOCX export will share), and craft_rtf::doc::export writes
it. Over the small writer this keeps, in RTF:
- pictures, inline (the engine no longer leaves them out for RTF);
- each page's size, as a section per page (blank pages kept);
- Heading 1 and 2 styles;
- the title;
- hard line breaks inside a paragraph or cell (storytold/pdfcraft#4723).
It also fixes two bugs: \cellx was the absolute page x, so every column
edge sat one left margin too far right, and tables that touched became
one (NIST CSF 2.0 came out with 28 tables instead of 68).
craft-rtf, craft-wordmodel, craft-docx and craft-mime are pinned together
at one craft-libs commit: doc::export takes its own revision's Document.
* export: pin craft-libs main with push_text, the header-row fix and the RTF generator name
craft-rtf, craft-wordmodel, craft-docx and craft-mime move to craft-libs
b8eaa8e2, which has storytold/craft-libs#1946, #1947 and #1950. The
mapping appends through Paragraph::push_text/push_object, tables keep
the default look, and the RTF names PdfCraft as its generator.
* export: write Word through craft-docx, from the shared word model
as_docx.rs no longer writes WordprocessingML itself: as_word::word_doc
maps the pages onto a craft_wordmodel::Document and craft_docx::write
writes it. The decisions stay the same: a page with rotated text or
overlapping text keeps its layout as positioned text boxes and pictures
(watermark-sized text behind, pictures over it, other text on top), the
other pages flow, each page is a section of its own size, a shared page
colour is the document's, the PDF's language goes in the slot Word keeps
for its script, and the media limits are unchanged.
Over the hand-written package this gains:
- a VML fallback for every text box, so Word 2007 opens positioned pages;
- rotated text as a turned text box Word draws as a line;
- the body font named (Arial), with a font table saying it is a sans;
- PdfCraft as the application in docProps/app.xml;
- a picture drawn many times stored once.
The tests that matched XML read the package back through craft-docx.
* parity: the Word export through craft-docx, checked in Word 16, Word 2007 and LibreOffice
* chore: update Cargo.lock after rebasing #7592
---------
Co-authored-by: kiwi4boy <kiwi4boy@gmail.com>