Skip to content

feat(tui): proper markdown rendering with syntax highlighting#57

Merged
lostmygithubaccount merged 4 commits intomainfrom
cody/ws-toolstuimarkdownrendering
Mar 27, 2026
Merged

feat(tui): proper markdown rendering with syntax highlighting#57
lostmygithubaccount merged 4 commits intomainfrom
cody/ws-toolstuimarkdownrendering

Conversation

@lostmygithubaccount
Copy link
Copy Markdown
Contributor

@lostmygithubaccount lostmygithubaccount commented Mar 26, 2026

Summary

  • Replace hand-rolled markdown parser with pulldown-cmark for full CommonMark + GFM support
  • Add syntect-based syntax highlighting for code blocks (~50 languages, base16-eighties.dark theme)
  • Two-pass table rendering with correct column alignment and per-cell inline styling
  • Fix stale buffer ghost characters via Clear widget before paragraph render
  • Hidden Ctrl+R toggle for raw markdown source view

Markdown elements now supported

Element Rendering
Headings (H1–H6) Visual hierarchy: H1 bold+underlined+blue, H2 bold+blue, H3 bold, H4+ bold+italic
Bullet / ordered lists Proper nesting, consistent indentation across digit boundaries
Code blocks Box-drawing borders, syntax highlighting, diff red/green coloring
Inline code Orange with dim backtick delimiters
Bold / italic / strikethrough Style stack composes correctly for nesting
Tables Two-pass column widths, alignment (left/center/right), inline formatting preserved
Blockquotes Styled bars in DIM_COLOR, italic content, nesting supported
Links Blue+underlined text, URL suffix deduplicated when text matches URL
Task lists Green [✓] / dim [ ] markers
Horizontal rules ──── line in DIM_COLOR
Images [image: url] placeholder

Bug fixes

  • Ghost characters from stale bufferParagraph widget doesn't clear unused cells; added Clear widget pre-render
  • Code fence info string metadatasql title="file.sql" lines="1-15" now extracts just sql for syntax detection and header display
  • Nested list indentlist_indent now restored to parent item's continuation indent after nested list
  • Ordered list 9→10 jump — Tracks max_digits per list for consistent bullet padding
  • Table inline formatting leakCode events inside table cells no longer leak to the main span accumulator

Screenshots/demo video

Coming soon

🤖 Generated with Claude Code

lostmygithubaccount and others added 4 commits March 25, 2026 19:41
Replace hand-rolled markdown parser with pulldown-cmark for full
CommonMark + GFM support. Add syntect-based syntax highlighting for
code blocks.

New markdown features:
- Headings with visual hierarchy (H1 bold+underlined, H2 bold, etc.)
- Bullet and ordered lists with proper nesting and indentation
- Blockquotes with styled │ bars
- Tables with two-pass column alignment and per-cell styling
- Links with URL dedup, strikethrough, task lists, horizontal rules
- Inline code with dim backtick delimiters
- Diff code blocks with red/green coloring
- Syntax highlighting for 50+ languages (syntect, base16-eighties theme)

Other fixes:
- Ctrl+R hidden toggle for raw markdown source view
- Clear widget before paragraph render to prevent ghost characters
- Extract language token from code fence info strings with metadata
- Consistent ordered list indentation across digit boundaries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ownrendering

# Conflicts:
#	crates/ascend-tools-tui/src/lib.rs
Fix table column widths to use unicode display width instead of byte
length, fixing misalignment with CJK/emoji content. Fix ordered list
digit padding when lists start at high numbers. Fix nested list indent
restoration by saving/restoring parent indent instead of using a
hardcoded formula.

Add GFM blockquote admonition support ([!NOTE], [!TIP], [!IMPORTANT],
[!WARNING], [!CAUTION]) with distinct colored labels. Replace implicit
in_table() check with explicit field. Replace table span clone() with
std::mem::take(). Add 8 new tests covering unicode tables, nested
blockquotes, mixed lists, GFM admonitions, and edge cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix SoftBreak/HardBreak routing inside tables (was corrupting main span accumulator)
- Trim syntect features to minimal set (drop html, plist, yaml, dump-create deps)
- Remove trivial in_table() getter in favor of direct field access
- Add explicit parens for operator precedence clarity in blank_line_if_needed
- Add clarifying comments (Clear widget, find_syntax diff exclusion)
- Add test for code block inside blockquote

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lostmygithubaccount lostmygithubaccount marked this pull request as ready for review March 27, 2026 20:10
@lostmygithubaccount lostmygithubaccount enabled auto-merge (squash) March 27, 2026 20:11
@lostmygithubaccount lostmygithubaccount merged commit c43577a into main Mar 27, 2026
1 check passed
@lostmygithubaccount lostmygithubaccount deleted the cody/ws-toolstuimarkdownrendering branch March 27, 2026 20:16
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.

1 participant