Skip to content

Instantly share code, notes, and snippets.

@hsbt
Created July 5, 2013 04:20
Show Gist options
  • Save hsbt/5931575 to your computer and use it in GitHub Desktop.
Save hsbt/5931575 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
Dir.glob('*').each do |file|
body = File.read(file)
body.gsub!(/\{\{\{([^\n]+?)\}\}\}/, '`\1`')
body.gsub!(/\{\{\{(.+?)\}\}\}/m){|m| m.each_line.map{|x| "\t#{x}".gsub(/[\{\}]{3}/,'')}.join}
body.gsub!(/\=\=\=\=\s(.+?)\s\=\=\=\=/, '### \1')
body.gsub!(/\=\=\=\s(.+?)\s\=\=\=/, '## \1')
body.gsub!(/\=\=\s(.+?)\s\=\=/, '# \1')
body.gsub!(/\=\s(.+?)\s\=[\s\n]*/, '')
body.gsub!(/\[(http[^\s\[\]]+)\s([^\[\]]+)\]/, '[\2](\1)')
body.gsub!(/\!(([A-Z][a-z0-9]+){2,})/, '\1')
body.gsub!(/'''(.+)'''/, '*\1*')
body.gsub!(/''(.+)''/, '_\1_')
body.gsub!(/^\s\*/, '*')
body.gsub!(/^\s\d\./, '1.')
File.open(file, 'w').write(body)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment