Repository navigation
fix(usfm): keep \h and \mt1 when the TOC fields change - #410
Conversation
The export filled \mt1 from the short name before the book title, and \h fell back to the short name, so saving a Short Name in the metadata dialog replaced both lines. Chad dropped that derivation from fluent-web#398 on 20 Aug, but the export still had it. Each \toc field now fills only its own line. \h is the running header and \mt1 the book title, each falling back to the display name. Nothing in the database changes: the dialog never wrote those two columns. Part of eten-tech-foundation/fluent-web#398.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
QA on eten-tech-foundation/fluent-web#398 found that editing the TOC fields changed two other lines of the exported book. After saving a Short Name,
\mt1came out with that value, and so did\hwhenever no running header was set. Whatever those lines held before was gone from the file. Chad confirmed it on the issue: the Short Name should only land in\toc2.What was going on
The export took
\mt1fromtocShortNamefirst and only then frombookTitle, and\hfell back totocShortName. Both came from the first version of the ticket, which derived\mt1from the Short Name. Chad crossed that rule out on 20 Aug. #275 still had it when it merged the next day, and #323 kept the same fallback order.Nothing was lost in the database. The dialog only writes the three TOC columns, so
running_headerandbook_titlewere never touched. The export just stopped showing them.The fix
\hisrunningHeader, else the book name.\mt1isbookTitle, else the book name. Each TOC field fills only its own line. There's no migration: the next export shows the old\hand\mt1again.I also rewrote the OpenAPI descriptions that explained the old precedence, and replaced the note about pre-filling Short Name from
bookTitle. Chad dropped that rule the same day, and eten-tech-foundation/fluent-web#581 takes it out of the dialog.Tests
Two unit tests replace the ones that pinned the old rule. With all three TOC fields set, an authored
\hand\mt1stay as authored. With only the TOC fields set, both lines keep the book name. The USFM round-trip test now expects the book title in\mt1.Validation on the PR head:
\hand\mt, without them, and a second edit on top of the first. Onmainall 6 fail on the\h/\mt1lines:\mt1comes out as the Short Name, and so does\hwhen no running header is set. The rest of the suite for both PRs passes too (18 cases, including save and reload in the dialog).Tested API
dff7bc8f371f4e61889a96ea8cee235d8e578337with web eten-tech-foundation/fluent-web#581 atb756d73667b743d15964b6c2f21d0654b9e083aa. These are local checks only.Part of eten-tech-foundation/fluent-web#398.
Summary by CodeRabbit
\mt1and the running header for\h, falling back to the book’s display name when those fields are blank.