Improve table rendering: inline markdown, wrap, alignment, autolink#77
Open
jinzex wants to merge 8 commits intohanebox:releasefrom
Open
Improve table rendering: inline markdown, wrap, alignment, autolink#77jinzex wants to merge 8 commits intohanebox:releasefrom
jinzex wants to merge 8 commits intohanebox:releasefrom
Conversation
Render inline markdown (links, bold, italic, code, wiki links) inside table cells and wire up Enter-to-open for the first [text](url) per cell, including the "Open ↗" hint on the cursor'd row. Previously table cells rendered their raw source, so `[label](url)` appeared literally and columns reserved space for hidden markup. Scoped to simple scenarios: one markdown link per cell, no bare-URL autolinking. Also fix has_unsaved_changes to compare line-by-line with the same str::lines() semantics that enter_edit_mode uses. The old raw-string compare fired a false positive whenever a note ended in "\n" (most files), making edit-then-Esc round-trips prompt the unsaved-changes dialog even when no edits were made. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Parse :--- / ---: / :---: in the separator row to derive per-column alignment. Fix calc_formatting_shrinkage counting `[x](url)` as url_len+3 instead of url_len+4, which drifted borders by N on rows with N links. Adds unit tests for cell_visible_width, extract_simple_table_links, and Alignment::from_separator_cell. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Render bare URLs as styled links everywhere and emit them to item_links_at so Enter opens them. Strips trailing sentence punctuation per GFM; skips URLs that fall inside an existing [label](url) so they don't double-emit. Table cells fall back to a bare-URL scan when no bracket link is present. Unit tests for detect_bare_url_len (scheme, delimiters, punctuation, no-match) and for extract_simple_table_links bare-URL + precedence. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Alignment is already visible in how data rows are padded, so showing `:---` / `---:` / `:---:` in the rendered separator duplicates source syntax that most markdown renderers strip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wide tables no longer push later columns off-screen. Column widths cap against the terminal area (shrink-widest-first with a floor), and cells wrap to multiple visual lines at whitespace boundaries. Row height grows to match the tallest cell. Wrapping preserves inline markdown: parse_inline_formatting runs once per cell, then spans are distributed across visual lines — atomic spans (links, bold, italic, code, wiki) stay intact, plain-text spans break at whitespace. Avoids corrupting constructs that span wrap boundaries. Drop the one-link-per-cell limit in extract_simple_table_links so every [text](url) and bare URL in a row is navigable via arrow-key cycling. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cell_visible_width measured by chars().count(), so a cell like "🟡In-Progress" was sized at 12 cols when it actually renders in 13. Column widths under-reserved, causing emoji/CJK cells to overflow and wrap unnecessarily even when the terminal had room. Switch to UnicodeWidthStr::width and subtract the markdown-marker char count (markers are all ASCII = 1 col each). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Table cells can now contain GFM-style <br>, <br/>, <br /> (case-insensitive) to split content across multiple visual lines. Each logical line parses and wraps independently; they stack vertically within the cell, and row height grows to fit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
calc_wrapped_height measured each word with raw width — including markdown markers — so a token like [#cdd-rl-post-training](https://...) counted ~80 raw cols when it actually renders as ~21. Lines with long markdown links over-reserved height, leaving blank padding rows below the visible content. Switch to cell_visible_width per word so the strip-shrinkage already used for tables applies here too. Handles the common single-word link case (multi-word constructs with internal spaces are a separate, rarer case in non-table content). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improve markdown table rendering in the terminal view so table cells render inline markdown, respect column alignment, wrap cleanly when the table is wider than the terminal, autolink bare URLs, and let keyboard navigation reach every link in a row. Also fixes a false-positive unsaved-changes dialog.
What's in
[link](url),**bold**,*italic*,`code`,~~strike~~,[[wiki]]now render like they do in any other paragraph (previously cells showed raw source).:---/---:/:---:in the separator row drive Left/Right/Center padding.https://example.compasted directly renders as a styled link and opens with Enter, inside and outside tables.[text](url)and bare URL in a row (previously only the first one per row was navigable). "Open ↗" hint on the cursored row.Example to reproduce
Save as any
.mdfile and open it withekphos:Before / after
Test plan
cargo test --release— 396 pass, 0 fail.cargo build --releaseand open the example above — all four tables render correctly.eand thenEscon an unchanged note — no unsaved-changes dialog.