Skip to content

Instantly share code, notes, and snippets.

@jeremyevans
Created December 7, 2013 05:42
Show Gist options
  • Save jeremyevans/7837679 to your computer and use it in GitHub Desktop.
Save jeremyevans/7837679 to your computer and use it in GitHub Desktop.
Toto to Jekyll converter used to convert the sequel blog
# Run from jekyll dir
Dir['/path/to/toto/articles/*.txt'].sort.each do |path|
file = File.basename(path)
new_file = "_posts/#{file.sub(/\.txt\z/, '.md')}"
text = File.read(path)
headers, md = text.split("\n\n", 2)
raise "No title" unless headers =~ /^title: (.+)$/
title = $1
File.write(new_file, "---\n layout: post\n title: #{title}\n---\n\n#{md}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment