Brings ~55 mod-exclusive files to the upstream-based mod/master-resync branch: Activities (migrated to new ActivityManager pattern): - Clock/Time: SetTimeActivity, SetTimezoneOffsetActivity, NtpSyncActivity - Dictionary: DictionaryDefinitionActivity, DictionarySuggestionsActivity, DictionaryWordSelectActivity, LookedUpWordsActivity - Bookmark: EpubReaderBookmarkSelectionActivity - Book management: BookManageMenuActivity, EndOfBookMenuActivity - OPDS: OpdsServerListActivity, OpdsSettingsActivity - Utility: DirectoryPickerActivity, NumericStepperActivity Utilities (unchanged): - BookManager, BookSettings, BookmarkStore, BootNtpSync - Dictionary, LookupHistory, TimeSync, OpdsServerStore Libraries: PlaceholderCover, TableData, ChapterXPathIndexer Scripts: inject_mod_version, generate_book_icon, preview_placeholder_cover Docs: KOReader sync XPath mapping Migration changes: - ActivityWithSubactivity -> Activity base class - Callback constructors -> finish()/setResult() pattern - enterNewActivity() -> startActivityForResult() - Activity::RenderLock&& -> RenderLock&& These files won't compile yet - they reference mod settings and I18n strings that will be added in subsequent phases. Made-with: Cursor
2.2 KiB
2.2 KiB
Table Rendering Fixes: Entities and Colspan Support
Task Description
Fix two issues with the newly implemented EPUB table rendering:
- Stray
entities appearing as literal text in table cells instead of whitespace - Cells with
colspanattributes (e.g., section headers like "Anders Celsius", "Scientific career") rendering as narrow single-column cells instead of spanning the full table width
Changes Made
1. lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp — flushPartWordBuffer()
- Added detection and replacement of literal
strings in the word buffer before flushing toParsedText - This handles double-encoded
 entities common in Wikipedia and other generated EPUBs, where XML parsing converts&to&leaving literal in the character data
2. lib/Epub/Epub/TableData.h — TableCell struct
- Added
int colspan = 1field to store the HTMLcolspanattribute value
3. lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp — startElement()
- Added parsing of the
colspanattribute from<td>and<th>tags - Stores the parsed value (minimum 1) in the
TableCell::colspanfield
4. lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp — processTable()
- Column count: Changed from
max(row.cells.size())to sum ofcell.colspanper row, correctly determining logical column count - Natural width measurement: Only non-spanning cells (colspan=1) contribute to per-column width calculations; spanning cells use combined width
- Layout: Added
spanContentWidth()andspanFullCellWidth()lambdas to compute the combined content width and full cell width for cells spanning multiple columns - Cell mapping: Each
PageTableCellDatanow maps to an actual cell (not a logical column), with correct x-offset and combined column width for spanning cells - Fill logic: Empty cells are appended only for unused logical columns after all actual cells are placed
Follow-up Items
- Rowspan support is not yet implemented (uncommon in typical EPUB content)
- The
fix only handles the most common double-encoded entity; other double-encoded entities (e.g.,&mdash;) could be handled similarly if needed