Improve markdown rendering in terminal
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16
- Forks
- 3
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 121
Description
We're currently using a combination of comrak and termimad for our markdown rendering needs.
They have some drawbacks:
-
line wrapping isn't great (it works, but I remember it not being pretty to get working)
-
styling isn't exactly to my liking (can be configured, but not just so)
-
cannot disable 4-space indented code blocks
This is a must, because LLMs like nested lists, so this:
- foo - bar -bazTurns into rendered output that considers
-bar\n -bazto be a fenced code block.I want to completely disable that feature, and only allow fenced code blocks (triple+ backticks) to be parsed as code blocks.
-
markdown syntax is removed from the final output in the terminal. This is a big one, because I want to be able to quickly copy markdown from my terminal, but e.g. if a string contains
foocode elements, the __ character is removed aroundfoo`, meaning you cannot copy/paste it over. I haven't found any way to disable this. -
Trying to work around some of the above issues makes the implementation fairly brittle, and has lead to bugs in the past (and is possibly the source of the bug in #17).
Given the importance of a solid presentation of the assistant replies in the terminal, it might be worth considering a fresh implementation that takes all of the above points into account. Likely the best direction is to take a Markdown AST (e.g. using comrak::parse_document), and add our own ANSI escapes as required (using existing crates such as crossterm).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing comrak and termimad rendering path, with comrak::parse_document as the proposed Markdown AST entry point. Consider how crossterm could provide ANSI styling while preserving Markdown text, disabling indented code blocks, and improving wrapping. Done means terminal output meets those rendering and copy/paste requirements without the brittle behavior described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100