Skip to content

Instantly share code, notes, and snippets.

@johnmcc
Last active March 15, 2017 10:25
Show Gist options
  • Save johnmcc/11df41de5bb2deb4ea8053cd61d11c86 to your computer and use it in GitHub Desktop.
Save johnmcc/11df41de5bb2deb4ea8053cd61d11c86 to your computer and use it in GitHub Desktop.
# USE THIS SCRIPT AT YOUR OWN RISK
# Make sure your work is backed up / in version control.
# Quick and dirty script to recursively replace all
# headers of the format ###heading with ### heading.
# (Works through all .md files in the directory, and subdirectories)
filelist = Dir.glob("**/*.md")
for filename in filelist
text = File.read(filename)
new_contents = text.gsub(/^(#+)(\w+)/, '\1 \2')
File.open(filename, "w") {|file| file.puts new_contents }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment