Skip to content

chore: improve markdown spacing#766

Merged
tellaho merged 7 commits into
mainfrom
tho/message-timeline-polish
May 28, 2026
Merged

chore: improve markdown spacing#766
tellaho merged 7 commits into
mainfrom
tho/message-timeline-polish

Conversation

@tellaho
Copy link
Copy Markdown
Collaborator

@tellaho tellaho commented May 28, 2026

Category: improvement
User Impact: Message content now has consistent, cohesive vertical rhythm — headings, lists, blockquotes, code blocks, and tables all breathe naturally without jarring gaps or cramped runs.

Problem: Markdown spacing used a flat margin for all elements (my-0.5 / my-1.5 / my-3), which meant headings, code blocks, and dividers all got the same gap regardless of their visual weight. This created either too-tight or too-loose spacing depending on the element pair.

Solution: Replaced the single-rule approach with an axiomatic "lobotomized owl" (* + *) strategy — a base rhythm with contextual overrides for specific element pairs. Headings get a flat push/pull regardless of level (font size does the hierarchy work), block-level elements (code, blockquotes, tables) breathe more, and lists after paragraphs tuck in tighter to feel related.

File changes

desktop/src/shared/ui/markdown.tsx
Rewrote the spacing system across all three density variants (tight, compact, default). Added data-code-block and data-table-block attributes for CSS targeting. Bumped heading font sizes one step up (h1→xl, h2→lg, h3→base) with explicit leading values. Added internal blockquote spacing reset. All spacing now uses owl-based [&>*+*] selectors with contextual pair overrides.

How to verify

  1. Open any channel with markdown messages containing a mix of headings, paragraphs, lists, blockquotes, code blocks, tables, and hr dividers.
  2. Compare spacing between elements — headings should have equal push regardless of level, block elements should breathe, lists after paragraphs should feel related.
  3. Check all three variants: tight (chat messages), compact (thread panel), default (long-form/notes).

Screenshots

Headings + paragraphs:
image

Lists:
image

Blockquote + code block:
image

hr divider + table:
image

tellaho added 6 commits May 27, 2026 21:52
- Bump header sizes: h1 text-xl, h2 text-lg, h3 text-base (was text-lg/text-base/inherit)
- Add explicit leading to headers for consistent vertical rhythm
- Replace flat my-* spacing with sibling-aware margins (element+element)
- Headers get extra top margin for visual section breaks
- Content after headers gets tighter spacing to group with heading
- All three variants (tight/compact/default) updated proportionally
Strategy 4: define spacing for pairs of adjacent element types rather
than a flat owl. Each heavy/visual element (blockquote, code block,
table) gets symmetric breathing room above and below. hr gets the
largest gap as a clear section divider.

Tight mode spacing hierarchy:
- Base (p+p, list+p): mt-2.5 (10px)
- Blockquote/code/table: mt-3.5 (14px)
- hr: mt-4 (16px)
- Headings: mt-3 to mt-4 (unchanged)

Also:
- data-code-block attr on MarkdownCodeBlock for CSS targeting
- data-table-block attr on table wrapper
- Internal blockquote owl spacing for multi-paragraph quotes
- Refactored className to array.join() for readability
Lists that follow a paragraph should feel 'related' to their intro
text. Pull them closer than the base owl gap:
- tight: mt-1.5 (6px) vs base mt-2.5 (10px)
- compact: mt-2 (8px) vs base mt-3 (12px)
- default: mt-3 (12px) vs base mt-4 (16px)

Also targets div+ul/div+ol since the p component sometimes renders
as a div (when it contains block media).
Heading size already communicates hierarchy — extra whitespace for
larger headings was redundant in a chat context.

All variants now use flat values:
- tight: push mt-2.5, pull mt-0.5
- compact: push mt-3, pull mt-0.5
- default: push mt-3.5, pull mt-0.5

Also fixes invalid mt-4.5 value in default variant (now mt-4 for hr).
@tellaho tellaho changed the title improve markdown spacing with axiomatic owl-based rhythm chore: improve markdown spacing with axiomatic owl-based rhythm May 28, 2026
@tellaho tellaho changed the title chore: improve markdown spacing with axiomatic owl-based rhythm chore: improve markdown spacing May 28, 2026
@tellaho tellaho marked this pull request as ready for review May 28, 2026 16:53
@tellaho tellaho requested a review from a team as a code owner May 28, 2026 16:53
@tellaho tellaho enabled auto-merge (squash) May 28, 2026 17:31
@tellaho tellaho merged commit 8eedec7 into main May 28, 2026
15 checks passed
@tellaho tellaho deleted the tho/message-timeline-polish branch May 28, 2026 17:35
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