Skip to content

Instantly share code, notes, and snippets.

@upinetree
Created August 28, 2015 05:24
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 upinetree/46583e24a44fdb5c88cd to your computer and use it in GitHub Desktop.
Save upinetree/46583e24a44fdb5c88cd to your computer and use it in GitHub Desktop.
out_filename_suffix = '.text'
conversions = [
{ from: ' ', to: ' ' },
{ from: /^## (.*)/, to: "\\1\n------------------------------" },
{ from: /^### /, to: '■ ' },
]
in_filename = ARGV.shift
out_filename = in_filename + out_filename_suffix
buf = ''
File.open(in_filename, 'r') do |f|
buf = f.read
conversions.each { |c| buf.gsub!(c[:from], c[:to]) }
end
File.open(out_filename, 'w') do |f|
f.write(buf)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment