Our chimpy flavour of Redcarpet Markdown with a few escaping tricks for merge tags and content writer friendly extensions.
In your Gemfile:
gem "mc_markdown", git: '[email protected]:mailchimp/mc_markdown.git'
Then bundle install
Rendering with the Base renderer
MCMarkdown.render "# Hello World"
# => '<h1>Hello World</h1>'
MCMarkdown.render "*|MERGE_TASTIC|*"
# => '<p>*|MERGE_TASTIC|*</p>'
MCMarkdown.render "[Sign Up {btn}](/signup)"
# => '<a href="/signup" class="btn">Sign Up</a>'
Getting a renderer to use
html = MCMarkdown::Renderers.use :html
# => MCMarkdown::HTML initialized for Redcarpet::Markdown
html.render '# Hello World'
# => '<h1>Hello World</h1>'
Can also extract frontmatter
frontmatter, html = MCMarkdown.render_with_frontmatter "---\nfoo:bar\n---\n\n# Hello World"
# => { "foo" => "bar" }, "<h1>Hello World\n"
Renderers
Our "top level" objects, they coordinate collections of formatters and take the #render
method to render our input markdown.
Formatters
Formatters are the individual parts that differ from the base Redcarpet implementation. Some implement something like "shortag" codes in markdown.
$ rspec
# => runs the test suite
If there is any thing you'd like to contribute or fix, please:
- Fork the repo
- Add tests for any new functionality
- Make your changes
- Verify all existing tests work properly
- Make a pull request
The mc_markdown
gem is distributed under the BSD 3.0 license.