# Table Width Hints: HTML Attributes + CSS Width Support ## Task Description Add support for author-specified column widths from HTML `width` attributes and CSS `width` property on ``, ``, `` tags) - Added `#include "css/CssStyle.h"` for `CssLength` ### 3. Parser (`lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp`) - Removed `"col"` from `TABLE_SKIP_TAGS` (was being skipped entirely) - Added `parseHtmlWidthAttr()` helper: parses HTML `width="200"` (pixels) and `width="50%"` (percent) into `CssLength` - Added `` handling in `startElement`: parses `width` HTML attribute and `style` CSS, pushes to `tableData->colWidthHints` - Updated `` hints > max cell hint (colspan=1 only). Percentages resolve relative to available content width. - Modified step 3b: hinted columns get their resolved pixel width (clamped to min col width). If all hinted widths exceed available space, they're scaled down proportionally. Unhinted columns use the existing two-pass fair-share algorithm on the remaining space. ## Follow-up Items - The `` tag is still skipped entirely; `` tags within `` won't be reached. Could un-skip `` (make it transparent like ``/``) if needed. - `rowspan` is not yet supported.
`, and `` elements, using them as hints for column sizing in `processTable()`. ## Changes Made ### 1. CSS Layer (`lib/Epub/Epub/css/CssStyle.h`, `lib/Epub/Epub/css/CssParser.cpp`) - Added `width` bit to `CssPropertyFlags` - Added `CssLength width` field to `CssStyle` - Added `hasWidth()` convenience method - Updated `applyOver()`, `reset()`, `clearAll()`, `anySet()` to include `width` - Added `else if (propName == "width")` case to `CssParser::parseDeclarations()` using `interpretLength()` ### 2. Table Data (`lib/Epub/Epub/TableData.h`) - Added `CssLength widthHint` and `bool hasWidthHint` to `TableCell` - Added `std::vector colWidthHints` to `TableData` (from `
`/`` handling: now parses `width` HTML attribute, `style` attribute, and stylesheet CSS width (via `resolveStyle`). CSS takes priority over HTML attribute. Stored in `TableCell::widthHint` ### 4. Layout (`processTable()`) - Added step 3a: resolves width hints per column. Priority: `