No commit activity in last 3 years
No release in over 3 years
Evaluates Ruby code in your markdown, for awesome examples.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 1.8
>= 0
~> 10.0
>= 0
~> 3.7
~> 2.0

Runtime

 Project Readme

Redcarpet::Render::SeeingIsBelieving

Build Status

Powerup the Ruby examples in your markdown. Combines the excellent Redcarpet (a markdown parser) with Seeing Is Believing, which shows the evaluated result from each line of code.

If your markdown includes a fenced code block with ruby+ specified as the language:

```ruby+
  animals = ["Aardvark", "Butterfly", "Camel"]
  animals.map(&:upcase)
```

Then you'll see the result of each line of code:

Example HTML

Usage

Add the following line to your Gemfile and bundle install:

gem "redcarpet-render-seeing_is_believing"

Then prepend the module in your renderer:

require "redcarpet/render/seeing_is_believing"
require "redcarpet"

class MyCustomHtmlRenderer < Redcarpet::Render::HTML
  prepend Redcarpet::Render::SeeingIsBelieving

  def block_code(code, language)
    "<pre><code>#{code}</code></pre>"
  end
end

Redcarpet::Markdown.new(MyCustomHtmlRenderer, fenced_code_blocks: true).
  render("some markdown!")

or combine with Rouge syntax highlighter:

require "redcarpet/render/seeing_is_believing"
require "redcarpet"
require "rouge"
require "rouge/plugins/redcarpet"

class MyCustomHtmlRenderer < Redcarpet::Render::HTML
  include Rouge::Plugins::Redcarpet
  prepend Redcarpet::Render::SeeingIsBelieving
end

Redcarpet::Markdown.new(MyCustomHtmlRenderer, fenced_code_blocks: true).
  render("some markdown!")

Options

You can pass additional options after the ruby+ language hint:

  • ruby+e: Hints exceptions are expected, and should be displayed. Exceptions are hidden by default.

TODO

  • Allow comments to be scoped to specific lines
  • Wrap comments to the following line when the overall length is greater than 80 chars