mbutterick/quad

fading background color when code block overflows

Closed this issue · 7 comments

image

#lang quadwriter/markdown

\```
| Data | Size (nodes . arcs) | Complexity | CPU time² | Ratio (¹/²) |
|------+---------------------+------------+-----------+-------------|
| NY   | (264346 . 733846)   |   12462441 |      5026 |        2480 |
| BAY  | (321270 . 800172)   |   14219926 |      2938 |        4840 |
| COL  | (435666 . 1057066)  |   19382574 |      3808 |        5089 |
| FLA  | (1070376 . 2712798) |   52523774 |     15208 |        3454 |
| NE   | (1524453 . 3897636) |   77195074 |     38422 |        2009 |
\```

So what is the right behavior? A code block shouldn't be line-wrapped, because it might upset the spacing within (as it would here). But if the surrounding box stretches to fit, the ends of the line could expand beyond the right edge of the page.

that's a good question! I forgot about adding a note about how I'm throwing garbage at quad and expecting something else back :P

but I'll say I expected the background color to overflow with the text; not sure how clear this was, but my issue is with the occasional blank lines between the blue background, not with the overflowing behaviour itself

For now, I’m going to clip the contents of the box. Unlike a web browser, quad assumes that the goal is to fit the layout into a fixed space. Thus, I’m reluctant to go down a path where the fix for an overfull box is for the box to change size. That would have knock-on effects throughout the whole layout and demolish any idea of predictability or precision.

As a compromise I could see shrinking the content of an overfull box until the lines fit in the allocated size. That will require some more thought, because it requires some new backtracking in the layout algorithm (namely, that the shrinkage factor would be set by the longest line, and then it needs to be applied to all the lines).

(Of course, if you really need longer lines throughout the document, you can change page-margin-left and page-margin-right to be smaller. I don’t consider this a huge hardship, since that would be how you’d solve the problem in an ordinary word processor.)

For now, I’m going to clip the contents of the box.

I think this is OK, but shouldn't we have a warning ? in big documents it might be difficult to spot the errors!

image

Yes — added this as new issue #23.

Warnings for overfull lines have been added.