Paginate a report with indivisible paragraphs
A report can fit in aggregate yet overflow when a paragraph must stay together. Pack the measured paragraphs into the usable page area. The first two paragraphs fill a ten-line page. Three lines move to the second page and leave seven available there.
Run the framework with your own input
Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.
git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-lapwing.git
cd blyx-lapwing
blyxc native-run project.blyx -- "4,6,3" 120 10 10 10API and return values
Returns [pages, lines used on final page, unused line slots, printable lines per page]. Blocks are positive paragraph line counts. The host measures text and renders the resulting pages. Invalid input returns an empty vector.
| Argument | Accepted input |
|---|---|
| blocks | Vector of: nonnegative exact integer |
| paper | positive finite number |
| top | nonnegative finite number |
| bottom | nonnegative finite number |
| line | positive finite number |
Use the libraries independently
The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.
Try the program
Expected output
2 3 7 10
Practice
Change blocks = [], paper = 40.0, top = 0.0, bottom = 0.0. Predict the result, then run the program.
Hint
Returns [pages, lines used on final page, unused line slots, printable lines per page]. Blocks are positive paragraph line counts. The host measures text and renders the resulting pages.
Worked solution
The result vector is [0, 0, 0, 4]. Compare its fields with the return layout in the API section.
Find
let blocks = [4, 6, 3];Replace with
let blocks = [];Find
let paper = 120.0;Replace with
let paper = 40.0;Find
let top = 10.0;Replace with
let top = 0.0;Find
let bottom = 10.0;Replace with
let bottom = 0.0;Output after the change
0 0 0 4
