Skip to content

Instantly share code, notes, and snippets.

@david-hodgetts
Created October 21, 2013 19:14
Show Gist options
  • Save david-hodgetts/7089284 to your computer and use it in GitHub Desktop.
Save david-hodgetts/7089284 to your computer and use it in GitHub Desktop.
convert md from showoff to reveal
#!/usr/bin/env ruby
# encoding: utf-8
class Proc
def self.compose(f, g)
lambda { |*args| f[g[*args]] }
end
def *(g)
Proc.compose(self, g)
end
end
reveal_slide_separator = '--'
convert_fn =->(l) { l =~ /^!SLIDE/ ? reveal_slide_separator : l } *
->(l) { l =~ /^.notes/ ? '' : l } *
->(l) { l.sub(/@@@ .*/, "" ) } *
->(l) { l.sub(/^# /, '## ') } *
->(l) { l.sub(/^- /, '') }
input = ARGV[0]
exit(1) unless input
converted = File.readlines(input).map(&convert_fn)
puts converted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment