Skip to content

Instantly share code, notes, and snippets.

@rmosolgo
Forked from chrismytton/README.md
Last active December 14, 2015 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmosolgo/5160599 to your computer and use it in GitHub Desktop.
Save rmosolgo/5160599 to your computer and use it in GitHub Desktop.
Run ruby from inside Markdown. Denote code by leading TAB. (four spaces won't work)

Literate Ruby

Inspired by Literate CoffeeScript.

$ cat hello.litrb
Here's a simple program

    puts "Hello, world"
$ ruby litrb.rb < hello.litrb
Hello, world
eval ARGF.readlines.select { |line| line[/^\t/] }.map { |line| line[1..-1] }.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment