| name | md2slack |
| description | Copy a Markdown table to the macOS clipboard as HTML so pasting into Slack triggers Slack's "format as table?" prompt. Use whenever the user wants to send, paste, share, or post a table to Slack, or when the assistant has produced a Markdown table and Slack is mentioned. macOS only. |
md2slack
Slack detects HTML <table> elements on the clipboard (the public.html flavor) and offers to render them as a native Slack table block. Plain text Markdown does not trigger this.
Requirements
- macOS
pandoc — install with brew install pandoc if missing
Input source
The table to convert comes from one of these two sources only:
- A Markdown table the user provided in their current message.
- A Markdown table the assistant produced earlier in the conversation.
Do NOT read from the user's clipboard (pbpaste) or any file on disk. If neither source is available, ask the user to provide the table.
What to do
Replace the md variable with the actual Markdown table, then run this script. Tell the user to switch to Slack and paste (Cmd+V).
python3 - << 'PYEOF'
import subprocess, re
md = """
| Name | Role |
|------|------|
| Alice | Eng |
| Bob | PM |
"""
result = subprocess.run(['pandoc', '-f', 'gfm', '-t', 'html'],
input=md.encode(), capture_output=True, check=True)
html = result.stdout.decode()
if '<table' not in html:
raise SystemExit('Error: input did not parse as a table')
rows = []
for line in md.strip().splitlines():
line = line.strip()
if not line or re.match(r'^[\|\s\-:]+$', line):
continue
cells = [c.strip() for c in line.strip('|').split('|')]
rows.append('\t'.join(cells))
tsv = '\n'.join(rows)
html_hex = html.encode('utf-8').hex().upper()
tsv_hex = tsv.encode('utf-8').hex().upper()
script = ('set the clipboard to {text:\xab' + 'data utf8' + tsv_hex +
'\xbb, \xabclass HTML\xbb:\xabdata HTML' + html_hex + '\xbb}')
subprocess.run(['osascript', '-e', script], check=True)
print('✓ HTML table on clipboard. Paste into Slack with Cmd+V.')
PYEOF
Failure modes
- Pandoc not found →
brew install pandoc.
- "input did not parse as a table" → Markdown is malformed (missing
|---| separator row, or inconsistent columns).
- Pasted as plain text in Slack → command wasn't run; user copied raw Markdown instead of executing the pipeline.