No release in over 3 years
Lightweight converter for common Markdown to Slack mrkdwn syntax with a simple CLI. No dependencies, fast conversion.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

markdown_to_mrkdwn

CI codecov Ruby

Convert Markdown to Slack mrkdwn (lightweight, no dependencies).

Installation

Install the gem:

gem install markdown_to_mrkdwn

Or add to your Gemfile:

gem "markdown_to_mrkdwn"

For development, clone and setup:

git clone https://github.com/emp823/markdown_to_mrkdwn.git
cd markdown_to_mrkdwn
bin/setup

Usage

Ruby API

require "markdown_to_mrkdwn"

mrkdwn = MarkdownToMrkdwn.convert(<<~MARKDOWN)
  # Heading

  **Bold** and *italic* and ~~strike~~ and `code`.

  ```ruby
  puts "hello"

Alt MARKDOWN

puts mrkdwn


### Command Line

```bash
# Convert from stdin
echo "# Title\n**bold** and _italic_." | markdown_to_mrkdwn

# Convert a file
markdown_to_mrkdwn README.md

# Use options
markdown_to_mrkdwn --plain-headings README.md

What’s converted

  • Headings #..###### → bold line (or plain with --plain-headings).
  • Bold **text** or __text__*text*.
  • Italic *text* or _text__text_.
  • Strikethrough ~~text~~~text~.
  • Inline code `code``code` (unchanged).
  • Fenced code blocks lang ... ... (language hint removed).
  • Links [label](url)<url|label>.
  • Images ![alt](url)<url|alt>.
  • Horizontal rules → em dash line (or keep with --keep-hr).

Notes:

  • Lists, blockquotes, and paragraphs are mostly compatible with Slack already and are left as-is.
  • Code (inline and blocks) is protected from other conversions.
  • This is a pragmatic converter; edge cases of Markdown are not fully supported.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-new-feature)
  3. Make your changes and add tests
  4. Run the test suite (bundle exec rake test)
  5. Ensure code style passes (bundle exec rubocop)
  6. Commit your changes (git commit -am 'Add some feature')
  7. Push to the branch (git push origin feature/my-new-feature)
  8. Create a Pull Request

See CONTRIBUTING.md for detailed guidelines.

License

MIT - See LICENSE file for details.