Created
August 28, 2015 05:24
-
-
Save upinetree/46583e24a44fdb5c88cd to your computer and use it in GitHub Desktop.
This file contains 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
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