Back to Copilotkit

markdownToMrkdwn

showcase/shell-docs/src/content/reference/bot/slack/markdownToMrkdwn.mdx

1.60.11.3 KB
Original Source

Overview

markdownToMrkdwn converts GitHub-flavored Markdown — what agents emit — into Slack's mrkdwn dialect. The adapter applies it automatically to every streamed chunk and every Section/Markdown block, so agent output renders correctly without the model knowing about mrkdwn.

Signature

ts
import { markdownToMrkdwn } from "@copilotkit/bot-slack";

function markdownToMrkdwn(input: string): string;

Behavior

  • Inline styles — GFM emphasis is rewritten to mrkdwn (e.g. **bold***bold*); links become mrkdwn <url|label> form; lists are normalized.
  • Code passes through — fenced ``` blocks and inline `code` are left untouched; they render identically in both flavors.
  • Tables become monospace — mrkdwn has no table primitive, so GFM tables are column-aligned and wrapped in a code fence to stay readable.
  • Applied per chunk — during streaming, the translation runs on each flushed chunk, paired with the mid-stream auto-closer so partially streamed markdown still renders.