Created
May 28, 2014 19:00
-
-
Save kevinsawicki/8639af373bec9312bcfd to your computer and use it in GitHub Desktop.
Convert Campfire Transcript
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
#!/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