raine

copy-to-slack

0
0
# Install this skill:
npx skills add raine/skills --skill "copy-to-slack"

Install specific skill from multi-skill repository

# Description

Convert markdown to Slack-ready rich text and copy to clipboard.

# SKILL.md


name: copy-to-slack
description: Convert markdown to Slack-ready rich text and copy to clipboard.
allowed-tools: Bash, Read


Convert a markdown file to rich text and copy it to the clipboard so it can be
pasted into Slack with formatting intact.

Input

The user provides either:

  • A file path as $ARGUMENTS
  • A file path from recent conversation context

Steps

  1. Read the markdown file
  2. Manually convert the markdown to HTML (do NOT use pandoc or any external
    tool). Apply these conversions:
  3. **bold** β†’ <strong>bold</strong>
  4. _italic_ / *italic* β†’ <em>italic</em>
  5. `code` β†’ <code>code</code>
  6. Fenced code blocks β†’ <pre><code>...</code></pre>
  7. - item / * item β†’ <ul><li>item</li></ul>
  8. 1. item β†’ <ol><li>item</li></ol>
  9. [text](url) β†’ <a href="url">text</a>
  10. # Header β†’ <strong>Header</strong> (Slack has no native headers)
  11. Paragraph breaks β†’ <br><br> (Slack ignores <p> margins, so use
    <br><br> between paragraphs for visible spacing)
  12. Also prepare a plain-text version (strip markdown syntax)
  13. Copy to clipboard with both HTML and plain-text representations. Use >|
    instead of > for redirects (zsh has noclobber set). Use this snippet:
html_file=$(mktemp)
plain_file=$(mktemp)

printf '%s' "$html" >| "$html_file"
printf '%s' "$plain" >| "$plain_file"

swift -e "
import AppKit
let html = try! String(contentsOfFile: \"$html_file\", encoding: .utf8)
let plain = try! String(contentsOfFile: \"$plain_file\", encoding: .utf8)
let pb = NSPasteboard.general
pb.clearContents()
pb.setString(html, forType: .html)
pb.setString(plain, forType: .string)
"

rm -f "$html_file" "$plain_file"
  1. Confirm to the user what was copied

Markdown β†’ Slack formatting mapping

Slack's rich text paste interprets HTML. Key mappings:

  • **bold** β†’ <strong> β†’ bold in Slack
  • _italic_ β†’ <em> β†’ italic in Slack
  • `code` β†’ <code> β†’ inline code in Slack
  • Code blocks β†’ <pre><code> β†’ code blocks in Slack
  • - item β†’ <ul><li> β†’ bullet lists in Slack
  • [text](url) β†’ <a href> β†’ clickable links in Slack
  • Headers β†’ bold text (Slack doesn't have native headers)

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.