Skip to content

Set a list closer under its paragraph, and space the previews as the page - #423

Merged
Swordlash merged 7 commits into
mainfrom
list-after-paragraph
Dec 3, 2026
Merged

Swordlash merged 7 commits into
mainfrom
list-after-paragraph

Conversation

@Swordlash

@Swordlash Swordlash commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

WP5.148: a list right after a paragraph sits closer to it, and the editor's previews space a text's blocks as the page does. The owner: between a text and the list after it the render leaves a large gap, "tak jakby był tam enter", and space is wasted.

What was found

  • Nothing in the stylesheet set the margins of a paragraph or a list in rendered text, so the browser's own applied: a paragraph and the list after it stood exactly as far apart as two paragraphs (16 px on a page, 27 px on a slide). The same on pages and on slides.
  • The editor's previews showed every gap between two blocks doubled (32 px against the page's 16 px): the empty .source-line markers the previews use for following the cursor's line had overflow: hidden, which made each a formatting context of its own and stopped the margins on its two sides from collapsing through it. The rule had it since it was written (WP5.36); it hid nothing, the marker being empty.

What is built (CSS only, in web/style.css)

  • A list that directly follows a paragraph has 0.35em between them: both the paragraph's bottom margin and the list's top margin are set (margins collapse to the larger, so the paragraph's has to shrink too, with :has), and the first paragraph of a loose list's first item with them. It holds where the renderer puts something between the two: a source-line marker in a preview, the box of an incremental, non-incremental or sorted list, the box of a step after [[!pause]]. Only paragraphs without a class count, so a box's title, the contents' title and a spoiler's error line are left alone.
  • overflow: hidden is gone from .source-line. The marker is still an empty block with a box, so followLine and scrollIntoView still have something to scroll to; a block followed now lands about 16 px lower in the pane than before.
Gap Before After
Page: paragraph, list 16 px 5.59 px
Page: paragraph, paragraph 16 px 16 px
Page: heading, list 19.9 px 19.9 px
Slide: paragraph, list 27.09 px about 9.5 px
Slide: paragraph, paragraph 27.09 px 27.09 px
Preview: paragraph, paragraph 32 px 16 px, as the page
Preview: paragraph, list 11.19 px (with the first change alone) 5.59 px, as the page

An incremental list and a list after a pause keep the same gap while their items and steps appear.

Known and left

  • A paragraph and a list in two successive steps (a pause between them), a list in any other box (an id, a class of the writer's, [[!div]]), a list after display math (a box, not a paragraph), and {.day} lists keep their spacing.
  • An html fence's own <p> followed by <ul> moves too, its frame being a page body.
  • The PDF's spacing is LaTeX's (pandoc's template loads parskip): a list stands a paragraph's skip below its paragraph there, as before. Read from the template, not from a rendered PDF.

Tests (a real browser)

  • A page (Test.Browser.Spoilers, "a list right after a paragraph"): paragraph, list, paragraph, paragraph; a heading then a list at 19.9 px; a loose list; a list at the start of a box.
  • A slide (Test.Browser.Slides): a plain list, a heading, an incremental list across its steps, a list after a pause.
  • The preview (Test.Browser.Workspace, "spaces a text's blocks in the side by side preview as the page does"): six gaps between seven blocks, equal to the page's within half a pixel.
  • Seen failing: the page's and the slide's with the rule out (16.0 and 27.09); with a rule made too broad on purpose, the box's title and the slide's heading; the preview's with the marker's old rule (32, 11.19, 48, 35.9, 32, 32).

Verification

Run locally: format, lint; the browser groups touched and those that follow lines or scroll, alone (106 examples: the workspace's 10, the editor's 51, the frames' 18, the slides' 17, the spoilers' 9, the presentation preview's follow). No Haskell outside the tests changed; build-native and build-wasm beyond the test build are left to CI.

Codex

  • Round 1 (a238e9e, gpt-6.2-sol, high): four findings, all constructs the rule's list of cases does not reach, none fixed on this head; the owner is asked whether to merge as it stands. (1) Something that renders nothing between the paragraph and the list (an HTML comment, a math block of macro definitions alone) leaves two markers in a row in the preview, which then shows the full gap while the page shows the small one. (2) A paragraph and its list in two successive steps of a slide keep the full gap (said under "Known and left"). (3) A list with an anchor ({#id}) is wrapped in a box the rule does not name, and keeps the full gap (said). (4) A list whose first item starts with a heading keeps that heading's margin above it. The rule is CSS written case by case because the renderer puts wrappers between the two; a rule that cannot miss a case would have the renderer mark the pair, which is a change of every page's HTML and a package of its own.

(rounds are added here)

🤖 Generated with Claude Code

https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM

The browser gives a paragraph and the list after it a margin of 1em
each, which collapse to the gap between two paragraphs: the list looks
as if a blank line stood above it. Both margins of that pair are now
0.35em, on a page, in the previews, on a slide and in a comment. The
list may sit behind the empty marker of its source line in a preview,
or in the box of an incremental list or of a slide's step, so the rule
names those wrappers too. A list after a box's title, a heading or
another list keeps the browser's margins.

The browser tests measure the gaps on a page and on a slide, through
its steps, against the gap between two paragraphs and below a heading.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
A loose list's first item starts with a paragraph whose top margin of
1em collapses through the list into the gap above it, so the list kept
the gap of two paragraphs: that paragraph's top margin is 0.35em too
when the list follows a paragraph. A line {.sorted} or
{.nonincremental} before a list puts it in a box, as {.incremental}
does, and the rule now looks through those boxes as well. The page's
test checks a loose list after a paragraph, its items still a
paragraph's gap apart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
The rule took any paragraph but a box's title, and so also moved the
list of a [[!toc]] under its "Contents" title, whose own margin it
overrode. The text's paragraphs are the renderer's only paragraphs
without a class, so the rule now takes those alone. The page's test
checks that the list at the start of a box stays a paragraph's gap
below the box's title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
Each block of a preview follows an empty marker of its source line,
which the preview follows the cursor's line by. The marker had
overflow: hidden, which made it a block formatting context: the margins
on its two sides no longer collapsed through it, and every gap between
two blocks in the preview was twice the page's (32 pixels against 16
between two paragraphs). No commit or plan says why it was there; an
empty block of no height needs nothing to hide. Without it the margins
collapse through the marker, and the marker is still a box at the next
block's top, or a few pixels above it, for followLine's scroll and
scrollIntoView.

A browser test of the side by side preview compares the gaps between a
text's blocks with the page's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
#418 added two bindings to the browserJS list of Test.Browser.Workspace
where this branch added one; the merge keeps all three.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HnFn8HVAncUyJ6jU4yhnRM
@Swordlash
Swordlash merged commit 7a178a8 into main Dec 3, 2026
14 checks passed
@Swordlash
Swordlash deleted the list-after-paragraph branch December 3, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants