Created
October 21, 2013 19:14
-
-
Save david-hodgetts/7089284 to your computer and use it in GitHub Desktop.
convert md from showoff to reveal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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