Skip to content

Instantly share code, notes, and snippets.

@kevinsawicki
Created May 28, 2014 19:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kevinsawicki/8639af373bec9312bcfd to your computer and use it in GitHub Desktop.
Save kevinsawicki/8639af373bec9312bcfd to your computer and use it in GitHub Desktop.
Convert Campfire Transcript
#!/usr/bin/env coffee
fs = require 'fs'
log = fs.readFileSync('log.txt', 'utf8')
lines = log.split('\n')
lines = lines.filter (line) -> not /\thas entered the room$/.test(line)
lines = lines.filter (line) -> not /\thas left the room$/.test(line)
lines = lines.map (line, index) ->
if /\d?\d:\d\d [AP]M/.test(line)
"_#{line}_"
else
tab = line.indexOf '\t'
if tab > 0
author = line.substring(0, tab).trim()
message = line.substring(tab).trim()
"__#{author}__: #{message}"
else
line
fs.writeFileSync('log.md', lines.join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment