Improve Markdown rendering

Resolved 💬 3 comments Opened Jun 6, 2025 by bolinfest Closed Aug 7, 2025

Today, the Rust TUI uses https://github.com/joshka/tui-markdown for Markdown rendering while the TypeScript CLI uses https://www.npmjs.com/package/marked-terminal.

I would say that marked-terminal has more detailed styling that results in more attractive output, though it also has its share of issues, which is why we included a patched version of it in Codex CLI:

https://github.com/openai/codex/blob/029f39b9da894d27dcde81b8636ef89d8b652a9f/package.json#L32-L36

(See https://github.com/openai/codex/pull/916, which introduced the patches for details.)

Curiously, tui-markdown has some of the same issues that required patches to marked-terminal.

Nevertheless, things that I have noticed in the tui-markdown output:

  • If an item in a bulleted/numbered list includes styling, the item content starts on the next line (but it should not).
  • Hyperlinks are not formatted correctly (I discovered this when working on https://github.com/openai/codex/pull/957).
  • Output would benefit from style tweaks: I noticed marked-terminal uses yellow for inline code, which stands out quite a bit more than the white used by tui-markdown.
  • More generally, it would be good to support theming, as I expect there will be debates over the "best" Markdown styling, so we should let users play with it.
  • In some cases, I think it would be nice to strip some of the markdown characters around styled content. For example, for a fenced code block that is syntax highlighted, I'm not sure it makes sense to show the triple backticks. I also go back and forth on whether the heading text should be prefixed with #.

Admittedly, this is a lot of stuff to experiment with. Given that the implementation of tui-markdown is mostly a single file (https://github.com/joshka/tui-markdown/blob/main/tui-markdown/src/lib.rs) built on top of a handful of Markdown-related dependencies (ansi-to-tui, pulldown-cmark), I think we might want to have our own fork of tui-markdown in the Codex repo and contribute back upstream as experiments stabilize.

/cc @joshka

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗