Block Element Alignment

January 17, 2026 ยท View on GitHub

Overview

Fixed visual alignment inconsistency where block-level elements (tables, code blocks, blockquotes, etc.) rendered at 0px left margin while paragraphs and headers had 4px indent.

Problem

Some block elements rendered flush against the left edge while text content had a 4px base indent, creating visual misalignment in the rendered view.

Affected elements:

  • Tables (EditableTable)
  • Code blocks (EditableCodeBlock)
  • Mermaid diagrams (MermaidBlock)
  • Blockquotes
  • Thematic breaks (horizontal rules)
  • Front matter blocks

Not affected (already correct):

  • Paragraphs (4px base indent)
  • Headers (4px base indent)

Solution

Added consistent BASE_INDENT (4.0px) to all block-level rendering functions by wrapping content in ui.horizontal() with ui.add_space(BASE_INDENT).

Key Files

  • src/markdown/editor.rs - All rendering functions

Implementation Details

Pattern Used

const BASE_INDENT: f32 = 4.0;

ui.horizontal(|ui| {
    ui.add_space(BASE_INDENT);
    // ... render widget
}).inner;

Functions Modified

FunctionChange
render_tableWrapped EditableTable::show() in horizontal with indent
render_code_blockWrapped EditableCodeBlock::show() in horizontal with indent
render_mermaid_blockWrapped MermaidBlock::show() in horizontal with indent
render_blockquoteAdded ui.add_space(BASE_INDENT) before quote border
render_blockquote_with_structural_keysSame as above
render_thematic_breakWrapped horizontal rule in horizontal with indent
render_front_matterWrapped frame in horizontal with indent

Testing

Visual verification:

  1. Open a markdown file with tables, code blocks, blockquotes
  2. All elements should align at the same left margin
  3. Headers, paragraphs, and block elements share consistent 4px indent