Normalize book pages before spreadsheet export (BL-16518)#8074
Draft
StephenMcConnel wants to merge 2 commits into
Draft
Normalize book pages before spreadsheet export (BL-16518)#8074StephenMcConnel wants to merge 2 commits into
StephenMcConnel wants to merge 2 commits into
Conversation
Spreadsheet export previously read the raw saved .htm directly, so it could miss normalizations that only happen when a page is visited in edit mode -- notably the browser-side per-page fix-ups (e.g. wrapping bare text in <p>, trimming trailing <br>, canvas-element migration) that plain C# does not do. ExportToSpreadsheet now runs BookProcessor.ProcessBook (BringBookUpToDate plus the off-screen per-page browser pass, then Save) on a fresh Book instance before reading the DOM, so the exported content matches what the user would see and save after visiting each page in the editor. This is gated on book.IsSaveable, matching edit-mode semantics: a read-only or not-checked-out Team Collection book is left as-is (raw-disk read, no mutation). The normalization runs inside the export progress dialog's background worker (via a getDom delegate) so the several-seconds-per-book browser pass does not freeze the UI. Because ProcessBook rewrites the .htm on disk, the in-memory selected book is reloaded from disk when the dialog closes, mirroring the spreadsheet import path, so a later editor save cannot clobber the result. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
| Filename | Overview |
|---|---|
| src/BloomExe/Spreadsheet/SpreadsheetApi.cs | Refactors export to normalize book pages before reading the DOM: adds BookServer dependency, builds getDomAndFolder and reconcileSelectedBook closures that run ProcessBook on the background thread and reload the in-memory book on dialog close; threading model, IsSaveable guard, and rename handling all look correct. |
| src/BloomExe/Spreadsheet/SpreadsheetExporter.cs | ExportToFolderWithProgressAsync signature changed to accept a getDomAndFolder delegate (instead of pre-resolved DOM+path) and an optional doWhenDialogCloses callback; the delegate is invoked on the background worker so slow processing doesn't freeze the UI. Minimal, clean change. |
Reviews (2): Last reviewed commit: "BL-16518: handle folder rename when norm..." | Re-trigger Greptile
BookProcessor.ProcessBook saves the book, which can rename its folder and .htm to match the title. The export code read the DOM and images from paths captured before processing, so a rename would make it read a stale path (export throws / images missing), and the post-export reload of the selected book would target the old folder. The getDom delegate now returns the book folder alongside the DOM, both taken from the fresh Book's post-processing location (GetPathHtmlFile / FolderPath), and the reconcile step reloads the selected book pointing at the possibly-new folder (Book.ReloadFromDisk(renamedTo)). Found in self-review. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
[Claude Opus 4.8] Consulted Devin up to |
Member
|
This is going to be REALLY slow... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Spreadsheet export previously read the raw saved
.htmdirectly, so it could miss normalizations that only happen when a page is visited in edit mode — notably the browser-side per-page fix-ups (wrapping bare text in<p>, trimming trailing<br>, canvas-element migration) that plain C# does not do.ExportToSpreadsheetnow runsBookProcessor.ProcessBook(BringBookUpToDateplus the off-screen per-page browser pass, thenSave) on a freshBookinstance before reading the DOM, so the exported content matches what the user would see and save after visiting each page in the editor.Details
book.IsSaveable, matching edit-mode semantics: a read-only or not-checked-out Team Collection book is left as-is (raw-disk read, no mutation).getDomdelegate) so the several-seconds-per-book browser pass does not freeze the UI.ProcessBookrewrites the.htmon disk, the in-memory selected book is reloaded from disk when the dialog closes, mirroring the spreadsheet import path, so a later editor save cannot clobber the result.Testing
<br/>) into a content page's.htm, exported, and confirmed the.htmwas re-normalized to<p>…</p>(br removed) and the exported.xlsxreflected the normalized text.Scope: GUI export path only. The CLI
spreadsheetExportcommand still reads the raw.htm(would need the full ApplicationContainer/BookServer/WebView2 stack).Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-16518
Devin review
This change is