Class MarkdownRenderer

java.lang.Object
ai.wanaku.cli.main.support.MarkdownRenderer

public class MarkdownRenderer extends Object
Renders Markdown text with terminal styling using JLine3's AttributedString.

This class parses Markdown using the CommonMark library and converts it to styled terminal output with ANSI color codes and text formatting.

Supported Markdown features:

  • Headings (levels 1-6) - rendered in bold cyan
  • Paragraphs - standard text with proper spacing
  • Bold text (**text**) - rendered in bold
  • Italic text (*text*) - rendered in italic (if terminal supports)
  • Inline code (`code`) - rendered in yellow with background
  • Bullet lists - rendered with bullet points
  • Links - rendered in blue underlined with URL
  • Code blocks - rendered in yellow
  • Tables (GFM) - rendered with borders and proper alignment

Example usage:


 String markdown = "# Hello World\n\nThis is **bold** text.";
 AttributedString styled = MarkdownRenderer.render(markdown);
 terminal.writer().println(styled.toAnsi());
 
  • Constructor Details

    • MarkdownRenderer

      public MarkdownRenderer()
  • Method Details

    • render

      public static org.jline.utils.AttributedString render(String markdown)
      Renders Markdown text to a styled AttributedString for terminal output.
      Parameters:
      markdown - the Markdown text to render
      Returns:
      an AttributedString with terminal styling applied
      Throws:
      IllegalArgumentException - if markdown is null