Repository navigation
Native tables have named columns - #94
Merged
Merged
Conversation
A native table took Prawn's array of arrays: the header was the first row, and a column was styled by its position, counted by hand and recounted when a column was added. Columns now have names. Rows are hashes, or objects answering those names; each column takes a title, a width, an alignment and text attributes, and the header row is made of the titles. header takes the header's style or false, stripes alternates row backgrounds, cell styles every cell, and each option is checked. Without columns, a table of hashes has those of its first row. The block still receives the Prawn::Table before it is laid out, for what the options do not cover, and Prawn's table of arrays stays at document.prawn.table. The table box moves to its own file. Assisted-by: Claude [Claude Code]
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.
A native table took Prawn's array of arrays: the header was the first row, and a column was styled by its position, counted by hand and recounted whenever a column was added. Its options were Prawn's (
column_widths,cell_style,row_colors), passed through unchecked.Columns now have names, and rows are hashes or objects answering those names. This is the fourth slice of #71, part of #69. It replaces the table options added in #91, which have not been released.
title,width,align,weight,italic,sizeandcolor; a missing title is the name spelled out (first_namereads "First name"), and withoutcolumns:a table of hashes has those of its first row.document.prawn.table.header:takes its style (includingbackground) orfalse.stripesalternates row backgrounds,cellstyles every cell, and an unknown option at any level raisesArgumentErrorlisting the accepted ones.Prawn::Tablebefore it is laid out, for what the options do not cover, such as a span or one cell's style.Proof
test/native_boxes_test.rb: a 61-row table with named columns gives the same glyphs at the same positions, on the same pages, as the equivalent Prawn table, and leaves the same cursor; a right-aligned bold column is drawn where Prawn's own table draws it; titles are inferred from the first row, and rows can be objects; header styles, stripes, the header background and cell borders are read from the content stream through qpdf; an empty table without a header draws nothing and takes no room; every malformed input raises with its message checked.test/native_bands_test.rb: a footer holding a native table still stays on its page.docs:highlight:checkpass.Generated by Claude Code