Skip to content

MarkdownRenderer

Category: Terminal & Rendering

Source: markdown_renderer.dart

Classes

MarkdownRenderer

Renders a subset of Markdown to ANSI-styled terminal text.

Supported:

  • Headings: #, ##, ###
  • Bold: text
  • Italic: text
  • Inline code: code
  • Fenced code blocks: lang ...
  • Unordered lists: - item, * item
  • Ordered lists: 1. item
  • Blockquotes: > text
  • Links: [text](url)
  • Tables: | col | col |

Constructor

dart
MarkdownRenderer(this.width)

Properties

PropertyTypeDescription
widthint

Methods

String render(String markdown)

Render markdown text to ANSI-styled terminal output.

[markdown] is treated as untrusted (it is typically model output). Its terminal control bytes are stripped up front — see [stripControlChars] — so injected escape sequences (OSC 52 clipboard writes, OSC 8 hyperlinks, CSI screen/cursor control, stdin-injecting device queries) can never reach the terminal. Every escape below this line is one the renderer itself adds.

Released under the MIT License.