Repository navigation
A migration guide from Prawn code to the native API - #124
Merged
Merged
Conversation
A stack or a grid with a background or a border moved whole to the next page, and raised when it was higher than a page. It now breaks pages like a plain stack: its decoration is drawn on each page around what that page holds of it, beneath the content, with its padding kept clear at the top and bottom of every page. keep_together: true still moves it whole. Assisted-by: Claude [Claude Code]
Random stacks, rows and grids nested three levels deep, with gaps, paddings, decorations and page break rules, holding texts and tables, are placed and read back with mutool trace: nothing drawn leaves the margins, no two lines overlap, a stack kept together stays on one page whenever it fits an empty one, and rendering twice gives the same bytes. CI runs 1000 trees on a fresh seed. Assisted-by: Claude [Claude Code]
The layout fuzzer, on fresh seeds, found three ways to draw past the bottom margin. The gap below the last line of a decorated stack's part took its frame past the page; the bottom padding of a plain stack inside one did too; and a table row higher than a page ran past it, as Prawn's table draws it. A decorated stack's part now ends where its padding starts, a plain stack's bottom padding ends with the page, and a table whose row cannot fit a page raises CannotFit naming its height. Fuzz ids are zero-padded, so that a word broken across lines in a narrow column cannot pass for another box's id. Assisted-by: Claude [Claude Code]
Each native box takes a role saying what it is to a reader, for tagged PDF to read: a text is a paragraph, a heading from h1 to h6, a list item or an artifact; a container groups, or is a list, a list item or a figure; images and codes are figures with their alternative text in alt; tables are tables. Unknown roles, and alt on anything but a figure, raise. Headings already make the PDF's outline, nested by level, each pointing at the top of its first line on the page where it lands. Those of a header or a footer make none. Assisted-by: Claude [Claude Code]
…eur-jz0fj6 # Conflicts: # test/support/layout_trees.rb
…eur-jz0fj6 # Conflicts: # docs/guide.html # lib/gamba/native/layout.rb # test/native_boxes_test.rb # test/native_document_test.rb # test/native_layout_test.rb
A migration page takes the bench invoice from Prawn code to Gamba's own API: the same code on Gamba, its table as one native block (byte for byte the same PDF), then written natively and tagged. Five Prawn idioms sit beside the native code that replaces them. A test runs every sample of the page, checks the stages show the bench's code and draw the same invoice, and that each pair draws the same text. The bench measures the middle stage from bench/mixed, and the home page, README and gemspec lead with the native API, Prawn compatibility second. Assisted-by: Claude [Claude Code]
…eur-jz0fj6 # Conflicts: # bench/compare.rb # docs/benchmarks.html
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.
The site and the README presented Gamba as a faster Prawn, and nothing showed someone with fifty Prawn documents what to move, in which order, and what each step brings. Without that path, applications stay on the compatibility layer.
A new migration page takes the bench invoice through three stages, each useful alone, and sets Prawn idioms beside the native code that replaces them. The home page, README and gemspec now lead with the native API, keeping Prawn compatibility as the second argument. Part of #88.
gambablock (byte for byte the same PDF), then written natively and tagged for PDF/UA, with time and weight at each stage read frombenchmarks.json.bench/mixed/invoice.rbbecomes a "Gamba, one native block" column ofrake bench. Until the next release run, the page says that number is not measured yet.bounding_boxcolumns, fonts and colours set then reset withmove_down, tables counted by position,repeatwithnumber_pages, and room measured before a heading.test/migration_page_test.rbruns all 14 samples of the page. It also checks that each stage shows the code the bench measures, that the stages draw the same invoice, and that each Prawn idiom draws the same text as its native code.Inter.ttfthat the repository does not ship.Proof
bundle exec rake test: 1422 runs, 0 failures, 8 skips (veraPDF and Mustang are not installed here). RuboCop is clean, andrake docs:highlight:checkpasses.cmpfinds them identical, and so do their 100 dpi rasters.Generated by Claude Code