Last active
August 29, 2015 14:12
-
-
Save e-jigsaw/9311442c27bd1e48f8b4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| fs = require 'fs' | |
| fs.readdir 'posts', (err, files)-> files.forEach (filename)-> fs.readFile "posts/#{filename}", (err, file)-> | |
| text = file.toString().split('\n') | |
| title = /title: "(.*)"/.exec(text[1])[1] | |
| output = [].concat(["# #{title}", ''], text.slice(7)).join('\n') | |
| fs.writeFile "posts/#{filename}", output, (err)-> if err? then console.log filename, err else console.log "convert success: #{filename}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment