dcdpr / dcdpr/jp

Improve markdown rendering in terminal

Open
#53 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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
          -baz
    

    Turns into rendered output that considers -bar\n -baz to 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 foo code elements, the __ character is removed around foo`, 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.