Knuth-Plass Line Breaking With River Penalties

Baseline paragraph breaking uses classic box/glue/penalty scoring. Extension adds vertical space-alignment penalties so justified lines can avoid visible rivers while still preserving Knuth-Plass style badness and fitness evaluation.

explicit spacing per line post-hoc detected river overlay beam search keeps search tractable

Paragraph Input

Display Mode

Controls

default 2
top-N states per breakpoint
lines
filter weak chains
diagonal tolerance

Toggles

Neural Detector Overlay

Precomputed predictions from the focal-loss U-Net on hand-labeled test paragraphs. The threshold slider binarizes the saved probability heatmap client-side.

Layers
neural (heatmap / binary) heuristic mask ground truth

Detector-Guided Reranking

Generate a small set of candidate layouts with different river-penalty settings, score each on classical demerits + river severity, and pick the best. River severity is a geometry surrogate — it uses the same chain features the neural detector was trained on, but does not run the U-Net live. See docs/detector-guided-reranking.md.

ready