Skip to content

feat(markdown): render tables and follow links in the editor - #424

Merged
fcoury merged 7 commits into
mainfrom
fcoury/markdown-pretty-tables
Oct 28, 2026
Merged

fcoury merged 7 commits into
mainfrom
fcoury/markdown-pretty-tables

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Markdown reports are difficult to read as raw pipe tables, and inspecting their source references repeatedly replaces the document. This adds readable tables, inline and list styling, and link navigation directly in the main editor while preserving the Markdown source and editing coordinates.

  • Render pipe tables as aligned, wrapped grids in Normal mode. Insert, Visual, and pending editing operations reveal source; returning to Normal restores the grid. Presentation changes leave file contents and undo history untouched. :markdown-tables toggles the current pane; markdown_tables = false changes the default.
  • Highlight emphasis, inline code, links, list markers, and task states. Source delimiters remain visible outside rendered tables. gT and Toggle task change the current task's state as one undoable edit, preserving the cursor. Dot repeat remains intact across keyboard undo/redo.
  • Follow links with gx: relative files, line/column references, headings, reference links, and autolinks, including links in rendered tables. Reuse unsaved buffers and support Ctrl-o/Ctrl-i. Web and email links use the external opener; invalid local targets leave the editor in place.
  • Use Ctrl-w x / Open link in split to create a destination that subsequent links from that source pane reuse. Each source pane owns its association and the destination has independent jump history. Focus stays in the source by default; markdown_link_split_focus = "target" changes it after restart. Clear link destination, closing either pane, or changing the source document releases the association. Associations last for the session.

Table rendering, link indexing, and task toggling are bounded to Markdown documents up to 2 MiB. Unsupported table shapes retain their source representation. List styling retains existing characters and indentation. The accepted split design and focus comparison are retained under docs/markdown-link-split/ and docs/MARKDOWN_LINK_SPLIT_PLAN.md.

How to Test

  1. Create target.md with at least three lines. Beside it, create report.md with:

    # Report
    
    **Bold**, *emphasis*, and `inline code`.
    
    | Reference | Description |
    | --- | --- |
    | [first](target.md:2) | Open the second line |
    | [second](target.md:3) | Open the third line |
    
    - [ ] First task
    - [x] Second task
      - [X] Nested task
    
    `[ ] This is code`
    
    [missing](does-not-exist.md)
    [notes](#notes)
    
    ## Notes
  2. Run cargo run -- report.md. Check the grid and inline/list styles. Navigate the table with the mouse and h/j/k/l, including its leading pipe. Enter Insert or Visual mode, then Escape: source should appear and the grid should return without dirtying the file. Resize to exercise wrapped cells.

  3. Press gx on each table link. It should open the specified target line; Ctrl-o should return to the exact source cursor. Repeat the open/return sequence. The notes link should jump to its heading.

  4. From the report, press Ctrl-w x on first, then gx on second. One right-hand destination should be reused while focus stays in the report. Switch to the destination and use Ctrl-o/Ctrl-i to walk the two references. Repeat with markdown_link_split_focus = "target" after restarting to check destination focus.

  5. On the first task, press gT, u, Ctrl-r, move to the second task, and press .. The second task should toggle, with each toggle undoable independently. Try Toggle task from the command palette and a nested task. The inline code example must not toggle.

  6. Follow missing with both gx and Ctrl-w x: expect an error without a new buffer, pane, or jump. Use Clear link destination and confirm the pane stays open and ordinary gx opens in the source pane again.

Validation

  • macOS ARM64: 4,011 tests passed, 0 failed, 3 ignored with RUST_MIN_STACK=8388608 cargo test -p red for the existing default-thread-stack limitation. All 18 focused dot-repeat tests passed, including the unchanged explicit 2 MiB stack regression.
  • Strict Clippy across all targets/features, formatting, rustdoc, and the debug build passed.
  • At 6a7d5fe0, eight retained tmux scenarios passed: dark/light terminal styling, mouse/keyboard source navigation, task undo/redo/repeat, palette execution, nested/quoted/wrapped tasks, non-task rejection, mode changes, and a table-link round trip with exact source-byte restoration.
  • The earlier split-specific tmux run at 25cefdd4 covered both focus settings, destination reuse/history/lifecycle, unsaved buffers, and the report workflow. Current-head automated tests cover those cases; the final task-focused smoke did not repeat every split scenario or launch external browser/mail applications.

Keep tables rendered in Normal mode and reveal their original Markdown for editing and selection. Preserve buffer bytes, source positions, and undo history, with a per-window source toggle and a configuration opt-out.

Share projected geometry across rendering, cursor movement, and mouse hit testing. Cover incremental redraws, wrapped cells, borders and padding, and wide-character restoration after overlays.
@fcoury

fcoury commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T19:53:25.428173Z 6a7d5fe Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a7d5fe06f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

start_col,
end_col,
start_grapheme: 0,
end_grapheme: text.graphemes(true).count(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count source graphemes once per table row

For a table containing a long cell, project_row calls this function once per wrapped display row, and each call recounts the graphemes in the entire source line. This makes layout quadratic in the cell length at a fixed viewport width: a valid table with a roughly 1 MiB cell, still below the document-size limit, entails billions of grapheme visits during synchronous layout and can freeze the editor on opening or resizing the file. Compute the source grapheme count once before constructing the projected segments and reuse it.

Useful? React with 👍 / 👎.

@fcoury
fcoury merged commit 6847f7f into main Oct 28, 2026
26 checks passed
@fcoury
fcoury deleted the fcoury/markdown-pretty-tables branch October 28, 2026 20:22
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