Skip to content

Conversation

@Killusions
Copy link
Member

@Killusions Killusions commented Dec 6, 2025

  • add code copy button to markdown renderer
  • add table csv download button to markdown renderer
  • complete unfinished code blocks for streaming in markdown renderer
  • add optional support for code syntax highlighting in markdown renderer

New feature showcase:

ScreenFloat Shot of Arc on 2025-12-06 at 15-57-58 ScreenFloat Shot of Arc on 2025-12-06 at 15-57-37

This PR enhances the markdown renderer used in chat messages with interactive features, rendering options, theming, examples, and supporting changes.

Highlights

  • Adds copy-to-clipboard button for code blocks and per-table CSV download button (customizable, translatable labels).
  • Completes streaming-safe code block handling using placeholders and per-instance caching; renderer now returns HTMLElement and maintains caches for code blocks, tables, and LaTeX.
  • Optional syntax highlighting (highlight.js) and optional LaTeX rendering (KaTeX) for inline and display math; examples updated to demonstrate both.
  • Exposes MarkdownRendererOptions and new SiMarkdownRendererComponent inputs: disableCopyButton, disableDownloadButton, syntaxHighlighter, latexRenderer, copyButtonLabel, downloadButtonLabel; getMarkdownRenderer now accepts an options parameter.
  • Adds helpers: sanitizeHtmlWithStyles and LRU-style caches for DOM/string reuse; extensive renderer refactor and placeholder/post-render pipeline.
  • Adds SCSS highlight theme and layout for code/table overlays and KaTeX styling; sample markdown and showcase images updated.
  • Expands tests for LaTeX and table/code edge cases; updates Playwright snapshots and example configs.
  • Adds devDependencies (highlight.js, katex, @types/katex) and includes KaTeX CSS in example build.
  • Chat container: debounced scrolling during streaming and new public scrollToBottom()/scrollToTop() methods.

Backward compatibility

  • Features are opt-in via new options/inputs; intended to be non-breaking for existing usage.

@Killusions Killusions changed the title feat/add support for syntax highlighting, copying and downloading to markdown renderer in chat messages feat(chat-messages): add support for syntax highlighting, copying and downloading to markdown renderer Dec 6, 2025
@Killusions Killusions changed the title feat(chat-messages): add support for syntax highlighting, copying and downloading to markdown renderer feat(chat-messages): add support for syntax highlighting, copying and downloading csv to markdown renderer Dec 6, 2025
@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch 3 times, most recently from 27e60f1 to 37bf9ef Compare December 6, 2025 14:54
@Killusions Killusions marked this pull request as ready for review December 6, 2025 14:54
@Killusions Killusions requested a review from a team as a code owner December 6, 2025 14:54
@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

📝 Walkthrough

Walkthrough

Adds a configurable, stateful markdown renderer and exports a new MarkdownRendererOptions interface; getMarkdownRenderer now accepts an optional options parameter and returns an HTMLElement. The renderer implements per-instance caches and placeholder-based post-processing for code blocks, tables, LaTeX, links, and inline code; it supports optional syntax highlighting and LaTeX rendering hooks, and emits per-code copy and per-table download controls. SiMarkdownRendererComponent gains inputs for labels, enablement flags, syntaxHighlighter, and latexRenderer. Translation keys, helper sanitizers/caches, styles, example integrations (highlight.js/KaTeX), tests, and chat-container scroll APIs were also added.

Sequence Diagram(s)

sequenceDiagram
    participant Component as SiMarkdownRendererComponent
    participant Renderer as getMarkdownRenderer
    participant Parser as Markdown Parser
    participant Cache as Placeholder/Cache Manager
    participant Highlighter as SyntaxHighlighter
    participant Math as LaTeX Renderer
    participant DOM as Host Container

    Component->>Renderer: request render(text, options)
    Renderer->>Parser: parse markdown -> tokens
    Parser-->>Renderer: tokens (code, table, latex, inline, links)

    alt code block
        Renderer->>Highlighter: highlight(code, language)
        Highlighter-->>Renderer: highlighted HTML or undefined
        Renderer->>Cache: store code placeholder (metadata)
    end

    alt table
        Renderer->>Cache: store table CSV and placeholder
    end

    alt LaTeX
        Renderer->>Math: render(latex, displayMode)
        Math-->>Renderer: rendered HTML or undefined
        Renderer->>Cache: store latex placeholder
    end

    Renderer->>Renderer: assemble sanitized HTML with placeholders
    Renderer->>Cache: resolve placeholders -> DOM nodes (attach buttons/handlers)
    Renderer->>DOM: return final HTMLElement
    Component->>DOM: mount element
Loading

Possibly related PRs

Suggested labels

released

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature additions: syntax highlighting, code copy button, and CSV download functionality for the markdown renderer in chat messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch from 37bf9ef to 061738b Compare December 6, 2025 17:41
coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch from 061738b to 4b6ee7c Compare December 6, 2025 23:09
coderabbitai[bot]

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Dec 6, 2025

@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch 2 times, most recently from 518beed to 796a228 Compare December 7, 2025 16:08
coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch from 796a228 to 2fe3043 Compare December 9, 2025 10:15
coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch from 2fe3043 to 58a0c9f Compare December 9, 2025 13:20
coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch from 58a0c9f to d7323d9 Compare December 9, 2025 14:39
coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch from d7323d9 to 3585366 Compare December 9, 2025 15:24
coderabbitai[bot]

This comment was marked as outdated.

@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch 3 times, most recently from d52b6a6 to f3d9198 Compare January 19, 2026 12:30
@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch 2 times, most recently from a98658d to 6090746 Compare January 29, 2026 15:05
@Killusions Killusions force-pushed the feat/add-support-for-syntax-highlighting,-copying-and-downloading-to-markdown-renderer-in-chat-messages branch from 6090746 to 22d2c16 Compare January 29, 2026 16:22
@github-actions
Copy link

Code Coverage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants