# Specification: Markdown Support & Syntax Highlighting

## Overview
This track introduces rich text rendering to the Manual Slop GUI by adding support for GitHub-Flavored Markdown (GFM) in message and response views. It also adds syntax highlighting for code blocks and text content when the language context can be cheaply resolved (e.g., via known metadata or file extensions).

## Functional Requirements
- **Markdown Rendering:**
    - Integrate `imgui_markdown` (as provided by `imgui-bundle`) to render Markdown content in read-only views.
    - Support standard GFM features: headers, bold/italic text, lists, and links.
    - Ensure proper font and style mapping for Markdown elements within the application's theme.
- **Syntax Highlighting:**
    - Implement syntax highlighting for the following languages:
        - **PowerShell:** For AI-generated scripts and tool execution logs.
        - **Python:** For codebase snippets and TDD tasks.
        - **JSON/TOML:** For log payloads and configuration files.
    - **Language Resolution Strategy:**
        - Use explicit language tags in Markdown code blocks (e.g., ` ```python `).
        - Use file extensions when rendering content originating from a file.
        - Apply cheap heuristic deduction for common patterns if no explicit context exists.
- **GUI Integration:**
    - Replace the basic `imgui.text_wrapped` rendering in the **Discussion History** and **Comms Log** panels with the new Markdown renderer.
    - Ensure that syntax-highlighted blocks remain selectable and copyable (compatible with the "Selectable GUI Text" track).

## Non-Functional Requirements
- **Performance:** Rendering Markdown and syntax highlighting must be efficient enough to handle large logs without significant frame rate drops. Use caching or incremental rendering if necessary.
- **Visual Consistency:** The highlighting colors and Markdown styles must align with the "Professional" UI theme overhaul.

## Acceptance Criteria
- [ ] User and AI messages in the Discussion History render with Markdown formatting (bold, lists, etc.).
- [ ] Code blocks in messages are correctly syntax-highlighted for PowerShell and Python.
- [ ] JSON and TOML payloads in the Comms Log are syntax-highlighted.
- [ ] Links within Markdown content are clickable (e.g., opening URLs or local files).
- [ ] The renderer handles malformed Markdown gracefully without crashing the GUI.

## Out of Scope
- Support for complex Markdown extensions like tables (unless natively supported by `imgui_markdown`).
- Inline image rendering within Markdown.
- Expensive AST-based language detection for every text block.
