Last active
March 15, 2017 10:25
-
-
Save johnmcc/11df41de5bb2deb4ea8053cd61d11c86 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
# 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